Author: jonesde
Date: Tue Sep 25 18:32:37 2007 New Revision: 579424 URL: http://svn.apache.org/viewvc?rev=579424&view=rev Log: Added result-to-result feature for seca rules, based on patch from Adrian Crum but changed to be more consistent with context-to-result, AND to only copy over values that are valid for the service that triggered the eca; Jira #OFBIZ-1237 Modified: ofbiz/trunk/framework/service/dtd/service-eca.xsd ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java Modified: ofbiz/trunk/framework/service/dtd/service-eca.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/dtd/service-eca.xsd?rev=579424&r1=579423&r2=579424&view=diff ============================================================================== --- ofbiz/trunk/framework/service/dtd/service-eca.xsd (original) +++ ofbiz/trunk/framework/service/dtd/service-eca.xsd Tue Sep 25 18:32:37 2007 @@ -229,6 +229,15 @@ </xs:restriction> </xs:simpleType> </xs:attribute> + <xs:attribute name="result-to-result" default="false"> + <xs:annotation><xs:documentation>If true, and the action is successful, copies the action's result Map into the service's result Map.</xs:documentation></xs:annotation> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> <xs:attribute name="ignore-failure" default="true"> <xs:simpleType> <xs:restriction base="xs:token"> Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java?rev=579424&r1=579423&r2=579424&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java Tue Sep 25 18:32:37 2007 @@ -45,6 +45,7 @@ protected boolean newTransaction = false; protected boolean resultToContext = true; + protected boolean resultToResult = false; protected boolean ignoreFailure = false; protected boolean ignoreError = false; protected boolean persist = false; @@ -62,6 +63,8 @@ // default is true, so anything but false is true this.resultToContext = !"false".equals(action.getAttribute("result-to-context")); + // default is false, so anything but true is false + this.resultToResult = "true".equals(action.getAttribute("result-to-result")); this.newTransaction = !"false".equals(action.getAttribute("new-transaction")); this.ignoreFailure = !"false".equals(action.getAttribute("ignore-failure")); this.ignoreError = !"false".equals(action.getAttribute("ignore-error")); @@ -99,13 +102,13 @@ } } else { // standard ECA - if (serviceMode.equals("sync")) { + if (this.serviceMode.equals("sync")) { if (newTransaction) { - actionResult = dispatcher.runSync(serviceName, actionContext, -1, true); + actionResult = dispatcher.runSync(this.serviceName, actionContext, -1, true); } else { - actionResult = dispatcher.runSync(serviceName, actionContext); + actionResult = dispatcher.runSync(this.serviceName, actionContext); } - } else if (serviceMode.equals("async")) { + } else if (this.serviceMode.equals("async")) { dispatcher.runAsync(serviceName, actionContext, persist); } } @@ -123,6 +126,11 @@ // use the result to update the context fields. if (resultToContext) { context.putAll(dctx.getModelService(this.serviceName).makeValid(actionResult, ModelService.OUT_PARAM, false, null)); + } + + // use the result to update the result fields + if (resultToResult) { + result.putAll(dctx.getModelService(selfService).makeValid(actionResult, ModelService.OUT_PARAM, false, null)); } // if we aren't ignoring errors check it here... |
Free forum by Nabble | Edit this page |