fix the new notification services using sendMailFromTemplateSetting using body parameters
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@768245 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -62,9 +62,8 @@ under the License.
|
||||
<set field="newEntity.custRequestDate" from-field="nowTimestamp"/>
|
||||
</if-empty>
|
||||
|
||||
<if-empty field="parameters.statusId">
|
||||
<set value="CRQ_SUBMITTED" field="newEntity.statusId"/>
|
||||
</if-empty>
|
||||
<!-- always start with submitted -->
|
||||
<set value="CRQ_SUBMITTED" field="newEntity.statusId"/>
|
||||
|
||||
<if-not-empty field="parameters.custRequestId">
|
||||
<set field="newEntity.custRequestId" from-field="parameters.custRequestId"/>
|
||||
@@ -77,12 +76,10 @@ under the License.
|
||||
<field-to-result field="newEntity.custRequestId" result-name="custRequestId"/>
|
||||
|
||||
<!-- set status fields and history -->
|
||||
<if-empty field="parameters.statusId">
|
||||
<set field="parameters.statusId" value="CRQ_SUBMITTED"/>
|
||||
</if-empty>
|
||||
<set field="parameters.custRequestId" from-field="newEntity.custRequestId"/>
|
||||
<set-service-fields service-name="setCustRequestStatus" map="parameters" to-map="setStat"/>
|
||||
<call-service service-name="setCustRequestStatus" in-map-name="setStat"/>
|
||||
|
||||
|
||||
<!-- create also the item if key fields are provided -->
|
||||
<if>
|
||||
@@ -363,8 +360,9 @@ under the License.
|
||||
|
||||
<simple-method method-name="setCustRequestStatus" short-description="change the customer request Status">
|
||||
<entity-one entity-name="CustRequest" value-field="custRequest"/>
|
||||
<if-not-empty field="custRequest.statusId">
|
||||
<if-not-empty field="custRequest">
|
||||
<field-to-result field="custRequest.statusId" result-name="oldStatusId"/>
|
||||
<field-to-result field="custRequest.custRequestId" result-name="custRequestId"/>
|
||||
<if-compare-field field="custRequest.statusId" to-field="parameters.statusId" operator="not-equals">
|
||||
<entity-one entity-name="StatusValidChange" value-field="statusChange">
|
||||
<field-map field-name="statusId" from-field="custRequest.statusId"/>
|
||||
@@ -381,7 +379,6 @@ under the License.
|
||||
<set field="custRequest.statusId" from-field="parameters.statusId"/>
|
||||
<store-value value-field="custRequest"/>
|
||||
<call-simple-method method-name="createCustRequestStatus"/>
|
||||
<field-to-result field="custRequest.fromPartyId" result-name="fromPartyId"/><!-- for notification -->
|
||||
</simple-method>
|
||||
|
||||
<simple-method method-name="createCustRequestFromCommEvent" short-description="Create a Customer request from a commEvent(email)">
|
||||
|
||||
@@ -326,14 +326,14 @@ under the License.
|
||||
<eca service="setCustRequestStatus" event="commit">
|
||||
<condition field-name="oldStatusId" operator="not-equals" value="CRQ_ACCEPTED"/>
|
||||
<condition field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
|
||||
<set field-name="partyIdTo" value="${fromPartyId}"/>
|
||||
<set field-name="bodyParameters.custRequestId" env-name="custRequestId"/>
|
||||
<set field-name="emailTemplateSettingId" value="CUST_REQ_ACCEPTED"/>
|
||||
<action service="sendMailFromTemplateSetting" mode="sync"/>
|
||||
</eca>
|
||||
<eca service="setCustRequestStatus" event="commit">
|
||||
<condition field-name="oldStatusId" operator="not-equals" value="CRQ_COMPLETED"/>
|
||||
<condition field-name="statusId" operator="equals" value="CRQ_COMPLETED"/>
|
||||
<set field-name="partyIdTo" value="${fromPartyId}"/>
|
||||
<set field-name="bodyParameters.custRequestId" env-name="custRequestId"/>
|
||||
<set field-name="emailTemplateSettingId" value="CUST_REQ_COMPLETED"/>
|
||||
<action service="sendMailFromTemplateSetting" mode="sync"/>
|
||||
</eca>
|
||||
|
||||
@@ -154,10 +154,9 @@ under the License.
|
||||
<service name="setCustRequestStatus" engine="simple"
|
||||
location="component://order/script/org/ofbiz/order/request/CustRequestServices.xml" invoke="setCustRequestStatus" auth="true">
|
||||
<description>Set the Customer Request Status</description>
|
||||
<attribute name="custRequestId" type="String" mode="IN" optional="false"/>
|
||||
<attribute name="custRequestId" type="String" mode="INOUT" optional="false"/>
|
||||
<attribute name="statusId" type="String" mode="IN" optional="false"/>
|
||||
<attribute name="oldStatusId" type="String" mode="OUT" optional="true"/>
|
||||
<attribute name="fromPartyId" type="String" mode="OUT"/><!-- for notification -->
|
||||
</service>
|
||||
<service name="createCustRequestFromCommEvent" engine="simple" default-entity-name="CommunicationEvent"
|
||||
location="component://order/script/org/ofbiz/order/request/CustRequestServices.xml" invoke="createCustRequestFromCommEvent" auth="true">
|
||||
|
||||
@@ -22,9 +22,11 @@ under the License.
|
||||
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
|
||||
<simple-method method-name="sendMailFromTemplateSetting" short-description="Send Mail from Email Template Setting">
|
||||
|
||||
<if-not-empty field="parameters.partyId">
|
||||
<!-- if partyIdTo provided but no emailAddress, get it from the partyContactMech -->
|
||||
<if-not-empty field="parameters.partyIdTo">
|
||||
<if-empty field="parameters.sendTo">
|
||||
<set-service-fields service-name="getPartyEmail" map="parameters" to-map="getEmail"/>
|
||||
<set field="getMail.partyId" from-field="parameters.partyIdTo"/>
|
||||
<call-service service-name="getPartyEmail" in-map-name="getEmail">
|
||||
<result-to-field result-name="emailAddress" field="parameters.sendTo"/>
|
||||
</call-service>
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.ofbiz.base.util.string.FlexibleStringExpander;
|
||||
import org.ofbiz.entity.model.ModelUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import javolution.util.FastMap;
|
||||
|
||||
/**
|
||||
* ServiceEcaSetField
|
||||
@@ -59,12 +60,35 @@ public class ServiceEcaSetField {
|
||||
Debug.log("Expanded String: " + s, module);
|
||||
}
|
||||
}
|
||||
// TODO: rewrite using the ContextAccessor.java see hack below to be able to use maps for email notifications
|
||||
// check if target is a map
|
||||
String mapName = null;
|
||||
Map<String, Object> map = null;
|
||||
if (UtilValidate.isNotEmpty(fieldName) && fieldName.indexOf('.') != -1) {
|
||||
mapName = fieldName.substring(0, fieldName.indexOf('.'));
|
||||
fieldName = fieldName.substring(fieldName.indexOf('.') +1);
|
||||
if (context.containsKey(mapName)) {
|
||||
map = (Map<String, Object>) context.get(mapName);
|
||||
} else {
|
||||
map = FastMap.newInstance();
|
||||
}
|
||||
}
|
||||
|
||||
// process the context changes
|
||||
String newValue = null;
|
||||
if (UtilValidate.isNotEmpty(value)) {
|
||||
context.put(fieldName, this.format(value, context));
|
||||
newValue = (String) this.format(value, context);
|
||||
} else if (UtilValidate.isNotEmpty(envName) && context.get(envName) != null) {
|
||||
context.put(fieldName, this.format((String) context.get(envName), context));
|
||||
newValue = (String) this.format((String) context.get(envName), context);
|
||||
}
|
||||
|
||||
if (newValue != null) {
|
||||
if (map != null) {
|
||||
map.put(fieldName, newValue);
|
||||
context.put(mapName, map);
|
||||
} else {
|
||||
context.put(fieldName, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user