You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by nm...@apache.org on 2019/08/26 09:12:50 UTC

svn commit: r1865920 - in /ofbiz/ofbiz-framework/trunk/applications/party: groovyScripts/communication/CommunicationEventServices.groovy minilang/communication/CommunicationEventServices.xml minilang/test/PartyTests.xml servicedef/services.xml

Author: nmalin
Date: Mon Aug 26 09:12:50 2019
New Revision: 1865920

URL: http://svn.apache.org/viewvc?rev=1865920&view=rev
Log:
Improved: Convert CommunicationEventServices mini lang to groovy
(OFBIZ-9992) (OFBIZ-11164)
Thanks to Carl Demus for this conversion

Added:
    ofbiz/ofbiz-framework/trunk/applications/party/groovyScripts/communication/CommunicationEventServices.groovy   (with props)
Modified:
    ofbiz/ofbiz-framework/trunk/applications/party/minilang/communication/CommunicationEventServices.xml
    ofbiz/ofbiz-framework/trunk/applications/party/minilang/test/PartyTests.xml
    ofbiz/ofbiz-framework/trunk/applications/party/servicedef/services.xml

Added: ofbiz/ofbiz-framework/trunk/applications/party/groovyScripts/communication/CommunicationEventServices.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/groovyScripts/communication/CommunicationEventServices.groovy?rev=1865920&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/groovyScripts/communication/CommunicationEventServices.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/party/groovyScripts/communication/CommunicationEventServices.groovy Mon Aug 26 09:12:50 2019
@@ -0,0 +1,493 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.ofbiz.base.util.Debug
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.base.util.UtilProperties
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.condition.EntityCondition
+import org.apache.ofbiz.entity.condition.EntityOperator
+import org.apache.ofbiz.service.ModelService
+
+import java.sql.Timestamp
+
+/**
+ * Update a CommunicationEvent
+ */
+def updateCommunicationEvent() {
+
+    GenericValue event = from("CommunicationEvent")
+            .where(parameters)
+            .queryOne()
+
+    Map fieldsMap = [*:parameters]
+    String newStatusId = null
+    if (event.statusId != parameters.statusId) {
+        newStatusId = parameters.statusId
+        fieldsMap.statusId = event.statusId
+    }
+
+    // get partyId from email address if required
+    if (!parameters.partyIdTo && parameters.contactMechIdTo) {
+
+        GenericValue partyContactMech = from("PartyAndContactMech")
+                .where(contactMechId: parameters.contactMechIdTo)
+                .filterByDate()
+                .queryFirst()
+
+        fieldsMap.partyIdTo = partyContactMech ?
+                partyContactMech.partyId : null
+    }
+
+    // if the from-party changed, change also the roles
+    if (parameters.partyIdFrom
+            && parameters.partyIdFrom != event.partyIdFrom) {
+
+        // updating partyId from old:
+        if (event.partyIdFrom) {
+            GenericValue roleFrom = from("CommunicationEventRole")
+                    .where([communicationEventId: event.communicationEventId,
+                            partyId: event.partyIdFrom,
+                            roleTypeId: "ORIGINATOR"])
+                    .queryOne()
+            roleFrom?.remove()
+        }
+
+        // add new role
+        Map createCommEventRoleMap = [partyId: parameters.partyIdFrom]
+        createCommEventRoleMap.contactMechPurposeTypeIdFrom = parameters.contactMechPurposeTypeIdFrom ?: ""
+
+        Map getPartyEmailFrom = run service: "getPartyEmail", with: createCommEventRoleMap
+        createCommEventRoleMap.contactMechId = getPartyEmailFrom.contactMechId
+        createCommEventRoleMap.communicationEventId = event.communicationEventId
+        createCommEventRoleMap.roleTypeId = "ORIGINATOR"
+
+        run service: "createCommunicationEventRole", with: createCommEventRoleMap
+        fieldsMap.contactMechIdFrom = createCommEventRoleMap.contactMechId
+    }
+
+    // if the to-party changed, change also the roles
+    if (parameters.partyIdTo
+            && parameters.partyIdTo != event.partyIdTo) {
+        if (event.partyIdTo) {
+            GenericValue roleTo = from("CommunicationEventRole")
+                    .where([communicationEventId: event.communicationEventId,
+                            partyId: event.partyIdto,
+                            roleTypeId: "ADDRESSEE"])
+                    .queryOne()
+            roleTo?.remove()
+        }
+        // add new role
+        Map createCommEventRoleMap = [partyId: parameters.partyIdTo]
+        Map getPartyEmailTo = run service: "getPartyEmail", with: createCommEventRoleMap
+        createCommEventRoleMap.contactMechId = getPartyEmailTo.contactMechId
+        createCommEventRoleMap.communicationEventId = event.communicationEventId
+        createCommEventRoleMap.roleTypeId = "ADDRESSEE"
+
+        run service: "createCommunicationEventRole", with: createCommEventRoleMap
+        fieldsMap.contactMechIdTo = createCommEventRoleMap.contactMechId
+    }
+
+    event.setNonPKFields(fieldsMap)
+    event.store()
+
+    if (newStatusId) {
+        fieldsMap.statusId = newStatusId
+        run service: "setCommunicationEventStatus", with: fieldsMap
+    }
+
+    return success()
+}
+
+/**
+ * Delete a CommunicationEvent
+ */
+def deleteCommunicationEvent() {
+
+    GenericValue event = from("CommunicationEvent")
+            .where(parameters)
+            .queryOne()
+
+    // the service can be called multiple times because event can have several recipients
+    // ignore if already deleted
+    if (!event) {
+        return success()
+    }
+
+    // remove related links to work effort and product
+    event.removeRelated("CommunicationEventWorkEff")
+    event.removeRelated("CommunicationEventProduct")
+
+    List<GenericValue> contentAssocs = event.getRelated("CommEventContentAssoc", null, null, false)
+    contentAssocs.each { contentAssoc ->
+        contentAssoc.remove()
+        //Delete content and dataresource too if requested
+        if ("Y" == parameters.delContentDataResource) {
+            List<GenericValue> contents = contentAssoc.getRelated("FromContent", null, null, false)
+            contents.each { content ->
+                content.removeRelated("ContentRole")
+                content.removeRelated("ContentKeyword")
+
+                List<GenericValue> relatedFromContentassocs = content.getRelated("FromContentAssoc", null, null, false)
+                relatedFromContentassocs.each { relatedFromContentassoc ->
+                    Map removeContentAndRelatedInmap = [contentId: relatedFromContentassoc.contentIdTo]
+                    run service: "removeContentAndRelated", with: removeContentAndRelatedInmap
+                }
+                content.removeRelated("FromContentAssoc")
+
+                List<GenericValue> relatedToContentassocs = content.getRelated("ToContentAssoc", null, null, false)
+                relatedToContentassocs.each { relatedFromContentassoc ->
+                    Map removeContentAndRelatedInmap = [contentId: relatedFromContentassoc.contentIdFrom]
+                    run service: "removeContentAndRelated", with: removeContentAndRelatedInmap
+                }
+                content.removeRelated("ToContentAssoc")
+                content.remove()
+
+                // check first if the content is used on any other communication event if yes, only delete link
+                List<GenericValue> commEvents = from("CommEventContentAssoc")
+                        .where("contentId", content.contentId)
+                        .queryList()
+
+                if (commEvents && commEvents.size() == 1) {
+                    Map removeContentAndRelatedInmap = [contentId: content.contentId]
+                    run service: "removeContentAndRelated", with: removeContentAndRelatedInmap
+                }
+            }
+        }
+    }
+
+    //delete the roles when exist and the event itself
+    event.removeRelated("CommunicationEventRole")
+    event.remove()
+
+    return success()
+}
+
+/**
+ * delete commEvent and workEffort
+ */
+def deleteCommunicationEventWorkEffort() {
+
+    GenericValue event = from("CommunicationEvent")
+            .where(parameters)
+            .queryOne()
+
+    // remove related workeffort when this is the only communicationevent connected to it
+    List<GenericValue> workEffortComs = event.getRelated("CommunicationEventWorkEff", null, null, false)
+
+    workEffortComs.each { workEffortCom ->
+        workEffortCom.remove()
+        GenericValue workEffort = workEffortCom.getRelatedOne("WorkEffort", false)
+
+        List<GenericValue> otherComs = workEffort.getRelated("CommunicationEventWorkEff", null, null, false)
+
+        if (!otherComs) {
+            Debug.logInfo("remove workeffort ${workEffort.workEffortId} and related parties and status",
+                    "CommunicationEventService.groovy")
+            workEffort.removeRelated("WorkEffortPartyAssignment")
+            workEffort.removeRelated("WorkEffortStatus")
+            workEffort.removeRelated("WorkEffortKeyword")
+            workEffort.remove()
+        }
+    }
+    run service: "deleteCommunicationEvent", with: parameters
+    return success()
+}
+
+/**
+ * Create a CommunicationEventRole
+ */
+def createCommunicationEventRole() {
+
+    // check if role already exist, then ignore
+    GenericValue communicationEventRole =
+            from("CommunicationEventRole")
+                    .where(parameters)
+                    .queryOne()
+
+    if (!communicationEventRole) {
+        GenericValue sysUserLogin = from("UserLogin").where(userLoginId: "system").queryOne()
+
+        def partyRole = parameters
+        partyRole.userLogin= sysUserLogin
+        run service: "ensurePartyRole", with: partyRole
+
+        GenericValue newEntity = makeValue("CommunicationEventRole")
+        newEntity.setPKFields(parameters)
+        newEntity.setNonPKFields(parameters)
+        newEntity.statusId = parameters.statusId ?: 'COM_ROLE_CREATED'
+
+        // if not provided get the latest contact mech id
+        if (!newEntity.contactMechId) {
+            GenericValue communicationEvent =
+                    from("CommunicationEvent").where(communicationEventId: context.communicationEventId)
+                            .queryOne()
+            GenericValue communicationEventType = communicationEvent.getRelatedOne("CommunicationEventType")
+            if (communicationEventType.contactMechTypeId) {
+                GenericValue contactMech = from("PartyAndContactMech")
+                        .where("partyId", newEntity.partyId,
+                                "contactMechTypeId", communicationEventType.contactMechTypeId)
+                        .orderBy("-fromDate")
+                        .queryFirst()
+
+                if (contactMech) {
+                    newEntity.contactMechId = contactMechs[0]
+                }
+            }
+        }
+        newEntity.create()
+        return success()
+    }
+    return success()
+}
+
+/**
+ * Remove a CommunicationEventRole
+ */
+def removeCommunicationEventRole() {
+
+    GenericValue eventRole = from("CommunicationEventRole")
+            .where(parameters)
+            .queryOne()
+
+    if (eventRole) {
+        eventRole.remove()
+
+        if ("Y" == parameters.deleteCommEventIfLast
+                && from("CommunicationEventRole")
+                    .where("communicationEventId", eventRole.communicationEventId)
+                    .queryCount() == 0) {
+                run service: "deleteCommunicationEvent", with: parameters
+        }
+    }
+    return success()
+}
+
+/**
+ * Checks for email communication events with the status COM_IN_PROGRESS and a startdate which is expired,
+ * then send the email
+ */
+def sendEmailDated() {
+    Timestamp nowDate = UtilDateTime.nowTimestamp()
+    EntityCondition conditions = EntityCondition.makeCondition([
+            EntityCondition.makeCondition("statusId", "COM_IN_PROGRESS"),
+            EntityCondition.makeCondition(EntityOperator.OR,
+                    "communicationEventTypeId", "EMAIL_COMMUNICATION",
+                    "communicationEventTypeId", "AUTO_EMAIL_COMM"),
+            EntityCondition.makeCondition([
+                    EntityCondition.makeCondition("datetimeStarted", EntityOperator.LESS_THAN, nowDate),
+                    EntityCondition.makeCondition("datetimeStarted", EntityOperator.EQUALS, null),
+            ], EntityOperator.OR)
+    ])
+
+    Map serviceContext = dispatcher.getDispatchContext().makeValidContext("sendCommEventAsEmail", ModelService.IN_PARAM, parameters)
+    List<GenericValue> communicationEvents = from("CommunicationEvent").where(conditions).queryList()
+    communicationEvents.each { communicationEvent ->
+        // run service don't cover the new transaction need
+        serviceContext.communicationEvent = communicationEvent
+        dispatcher.runSync("sendCommEventAsEmail", serviceContext, 7200, true)
+    }
+
+    // sending of internal notes of a contactlist
+    conditions = EntityCondition.makeCondition([
+            EntityCondition.makeCondition("communicationEventTypeId", "COMMENT_NOTE"),
+            EntityCondition.makeCondition("contactListId", EntityOperator.NOT_EQUAL, null),
+            EntityCondition.makeCondition("statusId", "COM_IN_PROGRESS"),
+            EntityCondition.makeCondition([
+                    EntityCondition.makeCondition("datetimeStarted", EntityOperator.LESS_THAN, nowDate),
+                    EntityCondition.makeCondition("datetimeStarted", EntityOperator.EQUALS, null),
+            ], EntityOperator.OR)
+    ])
+
+    communicationEvents = from("CommunicationEvent").where(conditions).queryList()
+    communicationEvents.each { communicationEvent ->
+
+        List<GenericValue> contactListParties = from("ContactListParty")
+                .where(contactListId: communicationEvent.contactListId)
+                .queryList()
+
+        contactListParties.each { contactListParty ->
+            Map communicationEventRole = [communicationEventId: communicationEvent.communicationEventId,
+                                          roleTypeId: "ADDRESSEE",
+                                          partyId: contactListParty.partyId]
+            run service: "createCommunicationEventRole", with: communicationEventRole
+        }
+
+        Map updCommEventStatusMap = [*:communicationEvent]
+        updCommEventStatusMap.statusId = "COM_COMPLETE"
+        run service: "setCommunicationEventStatus", with: updCommEventStatusMap
+        return success()
+    }
+}
+
+/**
+ * Set The Communication Event Status
+ */
+def setCommunicationEventStatus() {
+
+    GenericValue communicationEvent = from("CommunicationEvent")
+            .where(parameters)
+            .queryOne()
+    oldStatusId = communicationEvent.statusId
+
+    if (parameters.statusId != communicationEvent.statusId) {
+
+        GenericValue statusChange = from("StatusValidChange")
+                .where(statusId: communicationEvent.statusId,
+                        statusIdTo: parameters.statusId)
+                .queryOne()
+        if (!statusChange) {
+            Debug.logError("Cannot change from ${communicationEventRole.statusId} to ${parameters.statusId}",
+                    "CommunicationEventServices.groovy")
+            return error(UtilProperties.getMessage("ProductUiLabels",
+                            "commeventservices.communication_event_status", parameters.locale as Locale))
+        } else {
+            communicationEvent.statusId = parameters.statusId
+            communicationEvent.store()
+            if ("COM_COMPLETE" == parameters.statusId) {
+                if ("Y" == parameters.setRoleStatusToComplete) {
+                    //if the status of the communicationevent is set to complete, all roles need to be set to complete,
+                    //which means the commevent was dealt with and no further action is required by any
+                    // of the other participants/addressees
+                    List<GenericValue> roles = communicationEvent.getRelated("CommunicationEventRole", null, null, false)
+                    roles.each { role ->
+                        if ("COM_ROLE_COMPLETED" != role.statusId) {
+                            role.statusId = "COM_ROLE_COMPLETED"
+                            role.store()
+                        }
+                    }
+                }
+            } else { //make sure at least the senders role is set to complete
+
+                GenericValue communicationEventRole =
+                        from("CommunicationEventRole").where(
+                                communicationEventId: communicationEvent.communicationEventId,
+                                partyId: communicationEvent.partyIdFrom,
+                                roleTypeId: "ORIGINATOR")
+                                .queryOne()
+                //found a mispelling in minilang so ...
+                if (communicationEventRole
+                        && !"COM_ROLE_COMPLETED" == communicationEventRole.statusId) {
+                    Map updateRoleMap = [*:communicationEventRole]
+                    updateRoleMap.statusId = "COM_ROLE_COMPLETED"
+                    run service: "updateCommunicationEventRole", with: updateRoleMap
+                }
+            }
+        }
+    }
+    return success()
+}
+
+//set the status for a particular party role to the status COM_ROLE_READ
+def setCommEventRoleToRead() {
+    if (!parameters.partyId) {
+        parameters.partyId = parameters.userLogin.partyId
+    }
+
+    GenericValue eventRole
+    if (!parameters.roleTypeId) {
+        eventRole = from("CommunicationEventRole")
+                .where(communicationEventId: parameters.communicationEventId,
+                       partyId: parameters.partyId)
+                .queryFirst()
+            parameters.roleTypeId = eventRole.roleTypeId
+    } else {
+        eventRole = from("CommunicationEventRole")
+                .where(parameters)
+                .queryOne()
+    }
+
+    if (eventRole
+            && "COM_ROLE_CREATED" == eventRole.statusId) {
+        GenericValue userLogin = from("UserLogin").where(userLoginId: "system").queryOne()
+
+        Map updStatMap = [*:parameters]
+        updStatMap.statusId = "COM_ROLE_READ"
+        updStatMap.userLogin = userLogin
+        run service: "setCommunicationEventRoleStatus", with: updStatMap
+    }
+
+    return success()
+}
+
+//Set The Communication Event Status for a specific role
+def setCommunicationEventRoleStatus() {
+
+    GenericValue communicationEventRole = from("CommunicationEventRole")
+            .where(parameters)
+            .queryOne()
+
+    oldStatusId = communicationEventRole.statusId
+    if (parameters.statusId != communicationEventRole.statusId) {
+        GenericValue statusChange = from("StatusValidChange")
+                .where(statusId: communicationEventRole.statusId,
+                        statusIdTo: parameters.statusId)
+                .cache()
+                .queryOne()
+        if (!statusChange) {
+            Debug.logError("Cannot change from ${communicationEventRole.statusId} to ${parameters.statusId}",
+                    "CommunicationEventServices.groovy")
+            return error(UtilProperties.getMessage("ProductUiLabels",
+                            "commeventservices.communication_event_status", parameters.locale as Locale))
+        } else {
+            communicationEventRole.statusId = parameters.statusId
+            communicationEventRole.store()
+        }
+    }
+    return success()
+}
+
+//Create communication event and send mail to company
+def sendContactUsEmailToCompany() {
+
+    GenericValue systemUserLogin = from("UserLogin").where('userLoginId', 'system').cache().queryOne()
+    Map contactUsMap = [*:parameters]
+    contactUsMap.userLogin = systemUserLogin
+    run service: "createCommunicationEventWithoutPermission", with: contactUsMap
+
+    Map getPartyEmailMap = [partyId: parameters.partyIdTo, userLogin: systemUserLogin]
+    Map getPartyEmailResult = run service: "getPartyEmail", with: getPartyEmailMap
+
+    GenericValue productStoreEmailSetting = from("ProductStoreEmailSetting")
+            .where(parameters)
+            .queryOne()
+
+    def bodyParameters = [partyId   : parameters.partyIdTo, email: parameters.emailAddress,
+                          firstName : parameters.firstName, lastName: parameters.lastName,
+                          postalCode: parameters.postalCode, countryCode: parameters.countryCode,
+                          message   : parameters.content]
+
+    if (productStoreEmailSetting.bodyScreenLocation) {
+        Map emailParams = [bodyParameters: bodyParameters, userLogin: systemUserLogin]
+        if (getPartyEmailResult.emailAddress) {
+            emailParams.sendTo = getPartyEmailResult.emailAddress
+        } else {
+            emailParams.sendTo = productStoreEmailSetting.fromAddress
+        }
+
+        emailParams.subject = productStoreEmailSetting.subject
+        emailParams.sendFrom = productStoreEmailSetting.fromAddress
+        emailParams.contentType = productStoreEmailSetting.contentType
+        emailParams.bodyScreenUri = productStoreEmailSetting.bodyScreenLocation
+
+        run service: "sendMailFromScreen", with: emailParams
+    }
+
+    return success()
+}

Propchange: ofbiz/ofbiz-framework/trunk/applications/party/groovyScripts/communication/CommunicationEventServices.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/ofbiz-framework/trunk/applications/party/groovyScripts/communication/CommunicationEventServices.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/ofbiz-framework/trunk/applications/party/groovyScripts/communication/CommunicationEventServices.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/ofbiz-framework/trunk/applications/party/minilang/communication/CommunicationEventServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/minilang/communication/CommunicationEventServices.xml?rev=1865920&r1=1865919&r2=1865920&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/minilang/communication/CommunicationEventServices.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/minilang/communication/CommunicationEventServices.xml Mon Aug 26 09:12:50 2019
@@ -253,419 +253,4 @@ under the License.
         </if-compare>  
     </simple-method>
 
-    <simple-method method-name="updateCommunicationEvent"
-        short-description="Update a CommunicationEvent">
-        <entity-one entity-name="CommunicationEvent" value-field="event"/>
-        <if-compare-field field="event.statusId" operator="not-equals" to-field="parameters.statusId">
-            <set field="newStatusId" from-field="parameters.statusId"/>
-            <set field="parameters.statusId" from-field="event.statusId"/>
-        </if-compare-field>
-        <!-- get partyId from email address if required -->
-        <if-empty field="parameters.partyIdTo">
-            <if-not-empty field="parameters.contactMechIdTo">
-                <entity-and entity-name="PartyAndContactMech" list="partyContactMechs" filter-by-date="true">
-                    <field-map field-name="contactMechId" from-field="parameters.contactMechIdTo"/>
-                    <field-map field-name="contactMechTypeId" value="EMAIL_ADDRESS"/>
-                </entity-and>
-                <first-from-list list="partyContactMechs" entry="partyContactMech"/>
-                <set field="parameters.partyIdTo" from-field="partyContactMech.partyId"/>
-            </if-not-empty>
-        </if-empty>
-        <!-- if the from-party changed, change also the roles -->
-        <if>
-            <condition>
-                <and>
-                    <not><if-empty field="parameters.partyIdFrom"/></not>
-                    <if-compare-field field="parameters.partyIdFrom" operator="not-equals" to-field="event.partyIdFrom"/>
-                </and>
-            </condition>
-            <then>
-                <!-- updating partyId from old: -->
-                <if-not-empty field="event.partyIdFrom">
-                    <entity-one entity-name="CommunicationEventRole" value-field="roleFrom">
-                        <field-map field-name="communicationEventId" from-field="event.communicationEventId"/>
-                        <field-map field-name="partyId" from-field="event.partyIdFrom"/>
-                        <field-map field-name="roleTypeId" value="ORIGINATOR"/>
-                    </entity-one>
-                    <if-not-empty field="roleFrom">
-                        <remove-value value-field="roleFrom"/>
-                    </if-not-empty>
-                </if-not-empty>
-                <!-- add new role -->
-                <set field="newRoleFrom.partyId" from-field="parameters.partyIdFrom"/>
-                <set field="newRoleFrom.contactMechPurposeTypeId" from-field="parameters.contactMechPurposeTypeIdFrom" set-if-empty="false"/>
-                <call-service service-name="getPartyEmail" in-map-name="newRoleFrom">
-                    <result-to-field result-name="contactMechId" field="newRoleFrom.contactMechId"/>
-                </call-service>
-                <set field="newRoleFrom.communicationEventId" from-field="event.communicationEventId"/>
-                <set field="newRoleFrom.roleTypeId" value="ORIGINATOR"/>
-                <call-service service-name="createCommunicationEventRole" in-map-name="newRoleFrom"/>
-                <set field="parameters.contactMechIdFrom" from-field="newRoleFrom.contactMechId"/>
-            </then>
-        </if>
-        <!-- if the to-party changed, change also the roles -->
-        <if>
-            <condition>
-                <and>
-                    <not><if-empty field="parameters.partyIdTo"/></not>
-                    <if-compare-field field="parameters.partyIdTo" operator="not-equals" to-field="event.partyIdTo"/>
-                </and>
-            </condition>
-            <then>
-                <!-- check if role exist then delete old role -->
-                <if-not-empty field="event.partyIdTo">
-                    <entity-one entity-name="CommunicationEventRole" value-field="roleTo">
-                        <field-map field-name="communicationEventId" from-field="event.communicationEventId"/>
-                        <field-map field-name="partyId" from-field="event.partyIdTo"/>
-                        <field-map field-name="roleTypeId" value="ADDRESSEE"/>
-                    </entity-one>
-                    <if-not-empty field="roleTo">
-                        <remove-value value-field="roleTo"/>
-                    </if-not-empty>
-                </if-not-empty>
-                <!-- add new role -->
-                <set field="newRoleTo.partyId" from-field="parameters.partyIdTo"/>
-                <call-service service-name="getPartyEmail" in-map-name="newRoleTo">
-                    <result-to-field result-name="contactMechId" field="newRoleTo.contactMechId"/>
-                </call-service>
-                <set field="newRoleTo.communicationEventId" from-field="event.communicationEventId"/>
-                <set field="newRoleTo.roleTypeId" value="ADDRESSEE"/>
-                <call-service service-name="createCommunicationEventRole" in-map-name="newRoleTo"/>
-                <set field="parameters.contactMechIdTo" from-field="newRoleTo.contactMechId"/>
-            </then>
-        </if>
-        <set-nonpk-fields map="parameters" value-field="event"/>
-        <store-value value-field="event"/>
-        <!-- set status at the end if required with the com event completed -->
-        <if-not-empty field="newStatusId">
-            <set field="parameters.statusId" from-field="newStatusId"/>
-            <set-service-fields service-name="setCommunicationEventStatus" map="parameters" to-map="newStat"/>
-            <call-service service-name="setCommunicationEventStatus" in-map-name="newStat"/>
-        </if-not-empty>
-    </simple-method>
-
-    <simple-method method-name="deleteCommunicationEvent" short-description="Delete a CommunicationEvent">
-        <entity-one entity-name="CommunicationEvent" value-field="event"/>
-        <if-empty field="event"><!-- the service can be called multiple times because event can have several recipients-->
-            <return/><!-- ignore if already deleted -->
-        </if-empty>
-        <!-- remove related links to work effort and product -->
-        <remove-related relation-name="CommunicationEventWorkEff" value-field="event"/>
-        <remove-related relation-name="CommunicationEventProduct" value-field="event"/>
-        <!-- remove related links to content -->
-        <get-related value-field="event" relation-name="CommEventContentAssoc" list="contentAssocs"/>
-        <if-not-empty field="contentAssocs">
-            <iterate list="contentAssocs" entry="contentAssoc">
-                <remove-value value-field="contentAssoc"/>
-                <!-- delete content and dataresource too if requested -->
-                <if-compare field="parameters.delContentDataResource" value="Y" operator="equals">
-                    <get-related value-field="contentAssoc" relation-name="FromContent" list="contents"/>
-                    <if-not-empty field="contents">
-                        <iterate list="contents" entry="content">
-                            <remove-related value-field="content" relation-name="ContentRole"/>
-                            <remove-related value-field="content" relation-name="ContentKeyword"/>
-                            <get-related value-field="content" relation-name="FromContentAssoc" list="relatedFromContentassocs"/>
-                            <iterate list="relatedFromContentassocs" entry="relatedFromContentassoc">
-                                <set field="removeContentAndRelatedInmap.contentId" from-field="relatedFromContentassoc.contentIdTo"/>
-                                <call-service service-name="removeContentAndRelated" in-map-name="removeContentAndRelatedInmap"/>
-                            </iterate>
-                            <remove-related value-field="content" relation-name="FromContentAssoc"/>
-                            <get-related value-field="content" relation-name="ToContentAssoc" list="relatedToContentassocs"/>
-                            <iterate list="relatedToContentassocs" entry="relatedToContentassoc">
-                                <set field="removeContentAndRelatedInmap.contentId" from-field="relatedFromContentassoc.contentIdFrom"/>
-                                <call-service service-name="removeContentAndRelated" in-map-name="removeContentAndRelatedInmap"/>
-                            </iterate>
-                            <remove-related value-field="content" relation-name="ToContentAssoc"/>
-                            <remove-value value-field="content"/>
-                            <!-- check first if the content is used on any other communication event if yes, only delete link-->
-                            <entity-and entity-name="CommEventContentAssoc" list="commEvents">
-                                <field-map field-name="contentId" from-field="content.contentId"/>
-                            </entity-and>
-                            <set field="commEventsSize" value="${groovy: return(commEvents.size())}" type="Integer"/>
-                            <if-compare field="commEventsSize" operator="equals" value="1">
-                                <set field="removeContentAndRelatedInmap.contentId" from-field="content.contentId"/>
-                                <call-service service-name="removeContentAndRelated" in-map-name="removeContentAndRelatedInmap"/>
-                            </if-compare>
-                        </iterate>
-                    </if-not-empty>
-                </if-compare>
-            </iterate>
-        </if-not-empty>
-        <!-- delete the roles when exist and the event itself -->
-        <remove-related value-field="event" relation-name="CommunicationEventRole"/>
-        <remove-value value-field="event"/>
-    </simple-method>
-    <simple-method method-name="deleteCommunicationEventWorkEffort" short-description="delete commEvent and workEffort">
-
-        <entity-one entity-name="CommunicationEvent" value-field="event"/>
-        <!-- remove related workeffort when this is the only communicationevent connected to it -->
-        <get-related value-field="event" relation-name="CommunicationEventWorkEff" list="workEffortComs"/>
-        <if-not-empty field="workEffortComs">
-            <iterate list="workEffortComs" entry="workEffortCom">
-                <remove-value value-field="workEffortCom"/>
-                <get-related-one value-field="workEffortCom" relation-name="WorkEffort" to-value-field="workEffort"/>
-                <get-related value-field="workEffort" relation-name="CommunicationEventWorkEff" list="otherComs"/>
-                <if-empty field="otherComs">
-                    <log level="info" message="remove workeffort ${workEffort.workEffortId} and related parties and status"/>
-                    <remove-related value-field="workEffort" relation-name="WorkEffortPartyAssignment"/>
-                    <remove-related value-field="workEffort" relation-name="WorkEffortPartyAssignment"/>
-                    <remove-related value-field="workEffort" relation-name="WorkEffortStatus"/>
-                    <remove-related value-field="workEffort" relation-name="WorkEffortKeyword"/>
-                    <remove-value value-field="workEffort"/>
-                </if-empty>
-            </iterate>
-        </if-not-empty>
-        <!-- delete the event itself -->
-        <call-service service-name="deleteCommunicationEvent" in-map-name="parameters"/>
-    </simple-method>
-
-    <simple-method method-name="createCommunicationEventRole"
-        short-description="Create a CommunicationEventRole">
-        <!-- check if role already exist, then ignore -->
-        <entity-one entity-name="CommunicationEventRole" value-field="communicationEventRole"/>
-        <if-empty field="communicationEventRole">
-            <entity-one entity-name="UserLogin" value-field="sysUserLogin">
-                <field-map field-name="userLoginId" value="system"/>
-            </entity-one>
-
-            <set-service-fields service-name="ensurePartyRole" map="parameters" to-map="partyRole"/>
-            <set field="partyRole.userLogin" from-field="sysUserLogin"/>
-            <call-service service-name="ensurePartyRole" in-map-name="partyRole" include-user-login="false"/>
-
-            <make-value entity-name="CommunicationEventRole" value-field="newEntity"/>
-            <set-pk-fields map="parameters" value-field="newEntity"/>
-            <set-nonpk-fields map="parameters" value-field="newEntity"/>
-            <if-empty field="newEntity.statusId">
-                <set field="newEntity.statusId" value="COM_ROLE_CREATED"/>
-            </if-empty>
-
-            <!-- if not provided get the latest contact mech id -->
-            <if-empty field="newEntity.contactMechId">
-                <entity-one entity-name="CommunicationEvent" value-field="communicationEvent"/>
-                <get-related-one value-field="communicationEvent" relation-name="CommunicationEventType" to-value-field="communicationEventType"/>
-                <if-not-empty field="communicationEventType.contactMechTypeId">
-                    <entity-and entity-name="PartyAndContactMech" list="contactMechs" filter-by-date="true">
-                        <field-map field-name="partyId" from-field="newEntity.partyId"/>
-                        <field-map field-name="contactMechTypeId" from-field="communicationEventType.contactMechTypeId"/>
-                        <order-by field-name="-fromDate"/>
-                    </entity-and>
-                    <first-from-list list="contactMechs" entry="contactMech"/>
-                    <set field="newEntity.contactMechId" from-field="contactMech.contactMechId"/>
-                </if-not-empty>
-            </if-empty>
-            <create-value value-field="newEntity"/>
-        </if-empty>
-    </simple-method>
-    <simple-method method-name="updateCommunicationEventRole" short-description="Create a CommunicationEventRole">
-        <entity-one entity-name="CommunicationEventRole" value-field="eventRole"/>
-        <if-not-empty field="eventRole">
-            <set-nonpk-fields map="parameters" value-field="eventRole"/>
-            <store-value value-field="eventRole"/>
-        </if-not-empty>
-    </simple-method>
-    <simple-method method-name="removeCommunicationEventRole" short-description="Remove a CommunicationEventRole">
-        <entity-one entity-name="CommunicationEventRole" value-field="eventRole"/>
-        <if-not-empty field="eventRole">
-            <remove-value value-field="eventRole"/>
-            <if-compare field="parameters.deleteCommEventIfLast" operator="equals" value="Y">
-                <entity-and entity-name="CommunicationEventRole" list="roles">
-                    <field-map field-name="communicationEventId" from-field="eventRole.communicationEventId"/>
-                </entity-and>
-                <if-empty field="roles">
-                    <set-service-fields service-name="deleteCommunicationEvent" map="parameters" to-map="inMapDel"/>
-                    <call-service service-name="deleteCommunicationEvent" in-map-name="inMapDel"/>
-                </if-empty>
-            </if-compare>
-        </if-not-empty>
-    </simple-method>
-
-    <simple-method method-name="sendEmailDated"
-        short-description="Checks for email communication events with the status COM_IN_PROGRESS and a startdate which is expired, then send the email">
-        <now-timestamp field="nowDate"/>
-        <!-- sending of email -->
-        <entity-condition entity-name="CommunicationEvent" list="communicationEvents">
-            <condition-list combine="and">
-                <condition-list combine="or">
-                    <condition-expr field-name="communicationEventTypeId" operator="equals" value="EMAIL_COMMUNICATION"/>
-                    <condition-expr field-name="communicationEventTypeId" operator="equals" value="AUTO_EMAIL_COMM"/>
-                </condition-list>
-                <condition-expr field-name="statusId" operator="equals" value="COM_IN_PROGRESS"/>
-                <condition-list combine="or">
-                    <condition-expr field-name="datetimeStarted" operator="less" from-field="nowDate"/>
-                    <condition-expr field-name="datetimeStarted" operator="equals" from-field="nullField"/>
-                </condition-list>
-            </condition-list>
-        </entity-condition>
-        <iterate list="communicationEvents" entry="communicationEvent">
-            <set-service-fields service-name="sendCommEventAsEmail" map="communicationEvent" to-map="inMap"/>
-            <call-service service-name="sendCommEventAsEmail" in-map-name="inMap" require-new-transaction="true" break-on-error="false"/>
-        </iterate>
-        <!-- sending of internal notes of a contactlist -->
-        <entity-condition entity-name="CommunicationEvent" list="communicationEvents">
-            <condition-list combine="and">
-                <condition-expr field-name="communicationEventTypeId" operator="equals" value="COMMENT_NOTE"/>
-                <condition-expr field-name="statusId" operator="equals" value="COM_IN_PROGRESS"/>
-                <condition-expr field-name="contactListId" operator="not-equals" from-field="nullValue"/>
-                <condition-list combine="or">
-                    <condition-expr field-name="datetimeStarted" operator="less" from-field="nowDate"/>
-                    <condition-expr field-name="datetimeStarted" operator="equals" from-field="nullField"/>
-                </condition-list>
-            </condition-list>
-        </entity-condition>
-        <iterate list="communicationEvents" entry="communicationEvent">
-            <entity-and entity-name="ContactListParty" list="contactListParties">
-                <field-map field-name="contactListId" from-field="communicationEvent.contactListId"/>
-            </entity-and>
-            <set field="communicationEventRole.communicationEventId" from-field="communicationEvent.communicationEventId"/>
-            <set field="communicationEventRole.roleTypeId" value="ADDRESSEE"/>
-            <iterate list="contactListParties" entry="contactListParty">
-                <set field="communicationEventRole.partyId" from-field="contactListParty.partyId"/>
-                <call-service service-name="createCommunicationEventRole" in-map-name="communicationEventRole"/>
-            </iterate>
-            <set-service-fields service-name="setCommunicationEventStatus" map="communicationEvent" to-map="updCommEventStatus"/>
-            <set field="updCommEventStatus.statusId" value="COM_COMPLETE"/>
-            <call-service service-name="setCommunicationEventStatus" in-map-name="updCommEventStatus"/>
-        </iterate>
-    </simple-method>
-
-    <simple-method method-name="setCommunicationEventStatus" short-description="Set The Communication Event Status">
-        <entity-one entity-name="CommunicationEvent" value-field="communicationEvent"/>
-        <field-to-result field="communicationEvent.statusId" result-name="oldStatusId"/>
-        <if-compare-field field="communicationEvent.statusId" to-field="parameters.statusId" operator="not-equals">
-            <entity-one entity-name="StatusValidChange" value-field="statusChange">
-                <field-map field-name="statusId" from-field="communicationEvent.statusId"/>
-                <field-map field-name="statusIdTo" from-field="parameters.statusId"/>
-            </entity-one>
-            <if-empty field="statusChange">
-                <add-error>
-                    <fail-property resource="PartyErrorUiLabels" property="commeventservices.communication_event_status"/>
-                </add-error>
-                <log level="error" message="Cannot change from ${communicationEvent.statusId} to ${parameters.statusId}"/>
-                <check-errors/>
-                <else>
-                    <set field="communicationEvent.statusId" from-field="parameters.statusId"/>
-                    <store-value value-field="communicationEvent"/>
-                    <if-compare operator="equals" value="COM_COMPLETE" field="parameters.statusId">
-                        <if-compare operator="equals" value="Y" field="parameters.setRoleStatusToComplete">
-                            <!-- if the status of the communicationevent is set to complete, all roles need to be set to complete, 
-                                which means the commevent was dealt with and no further action is required by any of the other participants/addressees -->
-                            <get-related relation-name="CommunicationEventRole" list="roles" value-field="communicationEvent"/>
-                            <iterate entry="role" list="roles">
-                                <if-compare-field field="role.statusId" operator="not-equals" to-field="COM_ROLE_COMPLETED">
-                                    <set field="role.statusId" value="COM_ROLE_COMPLETED"/>
-                                    <store-value value-field="role"/>
-                                </if-compare-field>                    
-                            </iterate>
-                            <else><!-- make sure at least the senders role is set to complete -->
-                                <entity-one  entity-name="CommunicationEventRole" value-field="communicationEventRole">
-                                    <field-map field-name="communicationEventId" from-field="communicationEvent.communicationEventId"/>
-                                    <field-map field-name="partyId" from-field="communicationEvent.partyIdFrom"/>
-                                    <field-map field-name="roleTypeId" value="ORIGINATOR"/> 
-                                </entity-one>
-                                <if-not-empty field="communicationEventRole">
-                                    <if-compare operator="not-equals" value="COM_ROLE_COMPLETED" field="comunnicationEventRole.statusId">
-                                        <set-service-fields service-name="updateCommunicationEventRole" map="communicationEventRole" to-map="updateRole"/>
-                                        <set field="updateRole.statusId" value="COM_ROLE_COMPLETED"/>
-                                        
-                                        <call-service service-name="updateCommunicationEventRole" in-map-name="updateRole"/>
-                                    </if-compare>
-                                </if-not-empty>
-                            </else>
-                        </if-compare>
-                    </if-compare>
-                </else>
-            </if-empty>
-        </if-compare-field>
-    </simple-method>
-    <simple-method method-name="setCommEventRoleToRead" short-description="set the status for a particular party role to the status COM_ROLE_READ" login-required="false">
-        <if-empty field="parameters.partyId">
-            <set field="parameters.partyId" from-field="parameters.userLogin.partyId"/>
-        </if-empty>
-        <if-empty field="parameters.roleTypeId">
-            <entity-and entity-name="CommunicationEventRole" list="communicationEventRoles">
-                <field-map field-name="communicationEventId" from-field="parameters.communicationEventId"/>
-                <field-map field-name="partyId" from-field="parameters.partyId"/>
-            </entity-and>
-            <first-from-list list="communicationEventRoles" entry="eventRole"/>
-            <set field="parameters.roleTypeId" from-field="eventRole.roleTypeId"/>
-            <else>
-                <entity-one entity-name="CommunicationEventRole" value-field="eventRole"/>
-            </else>
-        </if-empty>
-        <if-not-empty field="eventRole">
-            <if-compare operator="equals" value="COM_ROLE_CREATED" field="eventRole.statusId">
-                <entity-one entity-name="UserLogin" value-field="userLogin">
-                    <field-map field-name="userLoginId" value="system"/>
-                </entity-one>
-                <set-service-fields service-name="setCommunicationEventRoleStatus"
-                    map="parameters" to-map="updStat"/>
-                <set field="updStat.statusId" value="COM_ROLE_READ"/>
-                <set field="updStat.userLogin" from-field="userLogin"/>
-                <call-service service-name="setCommunicationEventRoleStatus" in-map-name="updStat"
-                    include-user-login="false"/>
-            </if-compare>
-        </if-not-empty>
-    </simple-method>
-    <simple-method method-name="setCommunicationEventRoleStatus" short-description="Set The Communication Event Status for a specific role">
-        <entity-one entity-name="CommunicationEventRole" value-field="communicationEventRole"/>
-        <field-to-result field="communicationEventRole.statusId" result-name="oldStatusId"/>
-        <if-compare-field field="communicationEventRole.statusId" to-field="parameters.statusId" operator="not-equals">
-            <entity-one entity-name="StatusValidChange" value-field="statusChange">
-                <field-map field-name="statusId" from-field="communicationEventRole.statusId"/>
-                <field-map field-name="statusIdTo" from-field="parameters.statusId"/>
-            </entity-one>
-            <if-empty field="statusChange">
-               <add-error>
-                    <fail-property resource="PartyErrorUiLabels" property="commeventservices.communication_event_role_status"/>
-                </add-error>
-                <log level="error" message="Cannot change from ${communicationEventRole.statusId} to ${parameters.statusId}"/>
-                <check-errors/>
-                <else>
-                    <set field="communicationEventRole.statusId" from-field="parameters.statusId"/>
-                    <store-value value-field="communicationEventRole"/>
-                </else>
-            </if-empty>
-        </if-compare-field>
-    </simple-method>
-    
-    <simple-method method-name="sendContactUsEmailToCompany" short-description="Create communication event and send mail to company" login-required="false">
-        <entity-one entity-name="UserLogin" value-field="systemUserLogin" auto-field-map="false">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-
-        <set-service-fields service-name="createCommunicationEventWithoutPermission" map="parameters" to-map="contactUsMap"/>
-        <set field="contactUsMap.userLogin" from-field="systemUserLogin"/>
-        <call-service service-name="createCommunicationEventWithoutPermission" in-map-name="contactUsMap"/>
-
-        <!-- Get party email address -->
-        <set field="getPartyEmailMap.partyId" from-field="parameters.partyIdTo"/>
-        <set field="getPartyEmailMap.userLogin" from-field="systemUserLogin"/>
-        <call-service service-name="getPartyEmail" in-map-name="getPartyEmailMap">
-            <result-to-field result-name="emailAddress"/>
-        </call-service>
-
-        <entity-one entity-name="ProductStoreEmailSetting" value-field="productStoreEmailSetting"/>
-        <set field="bodyParameters.partyId" from-field="parameters.partyIdTo"/>
-        <set field="bodyParameters.email" from-field="parameters.emailAddress"/>
-        <set field="bodyParameters.firstName" from-field="parameters.firstName"/>
-        <set field="bodyParameters.lastName" from-field="parameters.lastName"/>
-        <set field="bodyParameters.postalCode" from-field="parameters.postalCode"/>
-        <set field="bodyParameters.countryCode" from-field="parameters.countryCode"/>
-        <set field="bodyParameters.message" from-field="parameters.content"/>
-        <if-not-empty field="productStoreEmailSetting.bodyScreenLocation">
-            <set field="emailParams.bodyParameters" from-field="bodyParameters"/>
-            <set field="emailParams.userLogin" from-field="systemUserLogin"/>
-            <if-not-empty field="emailAddress">
-                <set field="emailParams.sendTo" from-field="emailAddress"/>
-            <else>
-                <set field="emailParams.sendTo" from-field="productStoreEmailSetting.fromAddress"/>
-            </else>
-            </if-not-empty>
-            <set field="emailParams.subject" from-field="productStoreEmailSetting.subject"/>
-            <set field="emailParams.sendFrom" from-field="productStoreEmailSetting.fromAddress"/>
-            <set field="emailParams.contentType" from-field="productStoreEmailSetting.contentType"/>
-            <set field="emailParams.bodyScreenUri" from-field="productStoreEmailSetting.bodyScreenLocation"/>
-            <call-service service-name="sendMailFromScreen" in-map-name="emailParams"/>
-        </if-not-empty>
-    </simple-method>
 </simple-methods>

Modified: ofbiz/ofbiz-framework/trunk/applications/party/minilang/test/PartyTests.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/minilang/test/PartyTests.xml?rev=1865920&r1=1865919&r2=1865920&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/minilang/test/PartyTests.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/minilang/test/PartyTests.xml Mon Aug 26 09:12:50 2019
@@ -1046,28 +1046,6 @@ under the License.
         <check-errors/>
     </simple-method>
 
-    <simple-method method-name="testSetCommunicationEventRoleStatus" short-description="Test the service setCommunicationEventRoleStatus" login-required="false">
-        <set field="serviceCtx.communicationEventId" value="TestEvent-2"/>
-        <set field="serviceCtx.partyId" value="TestCompany"/>
-        <set field="serviceCtx.roleTypeId" value="ADDRESSEE"/>
-        <set field="serviceCtx.statusId" value="COM_ROLE_COMPLETED"/>
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-        <set field="serviceCtx.userLogin" from-field="userLogin"/>
-        <call-service service-name="setCommunicationEventRoleStatus" in-map-name="serviceCtx"/>
-        <entity-one entity-name="CommunicationEventRole" value-field="communicationEventRole">
-            <field-map field-name="communicationEventId" value="TestEvent-2"/>
-            <field-map field-name="partyId" value="TestCompany"/>
-            <field-map field-name="roleTypeId" value="ADDRESSEE"/>
-            <field-map field-name="statusId" value="COM_ROLE_COMPLETED"/>
-        </entity-one>
-        <assert>
-            <not><if-empty field="communicationEventRole"/></not>
-        </assert>
-        <check-errors/>
-    </simple-method>
-
     <simple-method method-name="testSetCommEventRoleToRead" short-description="Test the service setCommEventRoleToRead" login-required="false">
         <set field="serviceCtx.communicationEventId" value="TestEvent-7"/>
         <set field="serviceCtx.partyId" value="TestCompany"/>
@@ -1146,6 +1124,28 @@ under the License.
         </assert>
         <check-errors/>
     </simple-method>
+
+    <simple-method method-name="testSetCommunicationEventRoleStatus" short-description="Test the service setCommunicationEventRoleStatus" login-required="false">
+        <set field="serviceCtx.communicationEventId" value="TestEvent-2"/>
+        <set field="serviceCtx.partyId" value="TestCompany"/>
+        <set field="serviceCtx.roleTypeId" value="ADDRESSEE"/>
+        <set field="serviceCtx.statusId" value="COM_ROLE_COMPLETED"/>
+        <entity-one entity-name="UserLogin" value-field="userLogin">
+            <field-map field-name="userLoginId" value="system"/>
+        </entity-one>
+        <set field="serviceCtx.userLogin" from-field="userLogin"/>
+        <call-service service-name="setCommunicationEventRoleStatus" in-map-name="serviceCtx"/>
+        <entity-one entity-name="CommunicationEventRole" value-field="communicationEventRole">
+            <field-map field-name="communicationEventId" value="TestEvent-2"/>
+            <field-map field-name="partyId" value="TestCompany"/>
+            <field-map field-name="roleTypeId" value="ADDRESSEE"/>
+            <field-map field-name="statusId" value="COM_ROLE_COMPLETED"/>
+        </entity-one>
+        <assert>
+            <not><if-empty field="communicationEventRole"/></not>
+        </assert>
+        <check-errors/>
+    </simple-method>
 
     <simple-method method-name="testUpdateContactMech" short-description="Test the service createContactMech" login-required="false">
         <set field="serviceCtx.contactMechId" value="TestContactMech"/>

Modified: ofbiz/ofbiz-framework/trunk/applications/party/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/servicedef/services.xml?rev=1865920&r1=1865919&r2=1865920&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/servicedef/services.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/servicedef/services.xml Mon Aug 26 09:12:50 2019
@@ -748,9 +748,8 @@ under the License.
         <override name="fromDate" mode="IN" type="Timestamp" optional="true"/>
     </service>
 
-    <!-- Communication Event Services -->
-    <service name="setCommunicationEventStatus" engine="simple" default-entity-name="CommunicationEvent"
-            location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="setCommunicationEventStatus" auth="true">
+    <service name="setCommunicationEventStatus" engine="groovy" default-entity-name="CommunicationEvent"
+             location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="setCommunicationEventStatus" auth="true">
         <description>Set the Communication event Status</description>
         <permission-service service-name="partyCommunicationEventPermissionCheck" main-action="UPDATE"/>
         <auto-attributes mode="IN" include="pk" optional="false"/>
@@ -759,8 +758,9 @@ under the License.
         <attribute name="setRoleStatusToComplete" mode="IN" type="String" default-value="N"/>
         <attribute name="partyIdFrom" type="String" mode="IN" optional="true"/>
     </service>
-    <service name="setCommunicationEventRoleStatus" engine="simple" default-entity-name="CommunicationEventRole"
-            location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="setCommunicationEventRoleStatus" auth="true">
+
+    <service name="setCommunicationEventRoleStatus" engine="groovy" default-entity-name="CommunicationEventRole"
+             location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="setCommunicationEventRoleStatus" auth="true">
         <description>Set the Communication event  Status for a specific role</description>
         <permission-service service-name="partyCommunicationEventPermissionCheck" main-action="UPDATE"/>
         <auto-attributes mode="IN" include="pk" optional="false"/>
@@ -794,8 +794,8 @@ under the License.
         <implements service="createCommunicationEventInterface"/>
     </service>
 
-    <service name="updateCommunicationEvent" engine="simple"
-            location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="updateCommunicationEvent" auth="true">
+    <service name="updateCommunicationEvent" engine="groovy"
+             location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="updateCommunicationEvent" auth="true">
         <description>Update a Communication Event</description>
         <permission-service service-name="partyCommunicationEventPermissionCheck" main-action="UPDATE"/>
         <auto-attributes entity-name="CommunicationEvent" include="pk" mode="IN" optional="false"/>
@@ -806,21 +806,25 @@ under the License.
         <override name="content" allow-html="any"/>
         <override name="subject" allow-html="safe"/>
     </service>
-    <service name="deleteCommunicationEvent" engine="simple"
-        location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="deleteCommunicationEvent" auth="true">
+
+
+    <service name="deleteCommunicationEvent" engine="groovy"
+             location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="deleteCommunicationEvent" auth="true">
         <description>Delete a Communication Event, optionally delete the attached content and dataresource</description>
         <permission-service service-name="partyCommunicationEventPermissionCheck" main-action="DELETE"/>
         <auto-attributes entity-name="CommunicationEvent" include="pk" mode="IN" optional="false"/>
         <attribute name="delContentDataResource" type="String" mode="IN" optional="true"/>
     </service>
-    <service name="deleteCommunicationEventWorkEffort" engine="simple"
-        location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="deleteCommunicationEventWorkEffort" auth="true">
+
+    <service name="deleteCommunicationEventWorkEffort" engine="groovy"
+             location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="deleteCommunicationEventWorkEffort" auth="true">
         <description>Delete a Communication Event, optionally delete the attached content and dataresource
             and when this is the only communication event connected to a workeffort delete the workeffort too.</description>
         <permission-service service-name="partyCommunicationEventPermissionCheck" main-action="DELETE"/>
         <auto-attributes entity-name="CommunicationEvent" include="pk" mode="IN" optional="false"/>
         <attribute name="delContentDataResource" type="String" mode="IN" optional="true"/>
     </service>
+
     <service name="createCommunicationEventPurpose" default-entity-name="CommunicationEventPurpose" engine="entity-auto" invoke="create" auth="true">
         <description>Create a Communication Event Purpose</description>
         <permission-service service-name="partyCommunicationEventPermissionCheck" main-action="CREATE"/>
@@ -852,26 +856,29 @@ under the License.
         <auto-attributes entity-name="CommunicationEventRole" include="pk" mode="IN" optional="false"/>
         <auto-attributes entity-name="CommunicationEventRole" include="nonpk" mode="IN" optional="true"/>
     </service>
-    <service name="createCommunicationEventRole" engine="simple"
-            location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="createCommunicationEventRole" auth="true">
+
+    <service name="createCommunicationEventRole" engine="groovy"
+             location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="createCommunicationEventRole" auth="true">
         <description>Create a Communication Event Role with permission check</description>
         <permission-service service-name="partyCommunicationEventPermissionCheck" main-action="CREATE"/>
         <implements service="createCommunicationEventRoleInterface"/>
     </service>
-    <service name="createCommunicationEventRoleWithoutPermission" engine="simple"
-            location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="createCommunicationEventRole" auth="true">
+
+    <service name="createCommunicationEventRoleWithoutPermission" engine="groovy"
+            location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="createCommunicationEventRole" auth="true">
         <description>Create a Communication Event Role without permission check</description>
         <implements service="createCommunicationEventRoleInterface"/>
     </service>
-    <service name="updateCommunicationEventRole" engine="simple"
-            location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="updateCommunicationEventRole" auth="true">
+
+    <service name="updateCommunicationEventRole" engine="entity-auto" invoke="update" auth="true" default-entity-name="CommunicationEventRole">
         <description>Update a Communication Event Role</description>
         <permission-service service-name="partyCommunicationEventPermissionCheck" main-action="UPDATE"/>
         <auto-attributes entity-name="CommunicationEventRole" include="pk" mode="IN" optional="false"/>
         <auto-attributes entity-name="CommunicationEventRole" include="nonpk" mode="IN" optional="true"/>
     </service>
-    <service name="removeCommunicationEventRole" engine="simple"
-            location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="removeCommunicationEventRole" auth="true">
+
+    <service name="removeCommunicationEventRole" engine="groovy"
+             location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="removeCommunicationEventRole" auth="true">
         <description>Remove a Communication Event Role</description>
         <permission-service service-name="partyCommunicationEventPermissionCheck" main-action="DELETE"/>
         <auto-attributes entity-name="CommunicationEventRole" include="pk" mode="IN" optional="false"/>
@@ -901,8 +908,9 @@ under the License.
             </type-validate>
         </override>
     </service>
-    <service name="setCommEventRoleToRead" engine="simple" default-entity-name="CommunicationEventRole"
-        location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="setCommEventRoleToRead" auth="false">
+
+    <service name="setCommEventRoleToRead" engine="groovy" default-entity-name="CommunicationEventRole"
+             location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="setCommEventRoleToRead" auth="false">
         <description>Marks a communication event as read</description>
         <auto-attributes include="pk" mode="IN" optional="true"/>
         <override name="communicationEventId" optional="false"/>
@@ -992,8 +1000,8 @@ under the License.
         <attribute name="partyIdFrom" type="String" mode="IN" optional="true"/>
     </service>
 
-    <service name="sendEmailDated" engine="simple" use-transaction="false"
-        location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="sendEmailDated" auth="true">
+    <service name="sendEmailDated" engine="groovy" use-transaction="false"
+             location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="sendEmailDated" auth="true">
         <description>Checks for email communication events with the status COM_IN_PROGRESS and a startdate which is expired, then send the email</description>
     </service>
 
@@ -1374,8 +1382,8 @@ under the License.
         <attribute name="description" type="String" mode="OUT" optional="true"/>
     </service>
 
-    <service name="sendContactUsEmailToCompany" engine="simple"
-            location="component://party/minilang/communication/CommunicationEventServices.xml" invoke="sendContactUsEmailToCompany" auth="false">
+    <service name="sendContactUsEmailToCompany" engine="groovy"
+             location="component://party/groovyScripts/communication/CommunicationEventServices.groovy" invoke="sendContactUsEmailToCompany" auth="false">
         <description>Create communication event and send mail to company</description>
         <implements service="createCommunicationEventWithoutPermission"/>
         <attribute name="emailAddress" type="String" mode="IN" optional="true"/>