svn commit: r1822316 - in /ofbiz/ofbiz-framework/trunk/applications/party: servicedef/services.xml src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1822316 - in /ofbiz/ofbiz-framework/trunk/applications/party: servicedef/services.xml src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java

pgil
Author: pgil
Date: Fri Jan 26 15:48:02 2018
New Revision: 1822316

URL: http://svn.apache.org/viewvc?rev=1822316&view=rev
Log:
Improved: When completing communicationEvent through setCommEventComplete, if datetimeEnded is null, set it to nowTimestamp (OFBIZ-10181)

Modified:
    ofbiz/ofbiz-framework/trunk/applications/party/servicedef/services.xml
    ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java

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=1822316&r1=1822315&r2=1822316&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/servicedef/services.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/servicedef/services.xml Fri Jan 26 15:48:02 2018
@@ -939,7 +939,8 @@ under the License.
 
     <service name="setCommEventComplete" engine="java"
         location="org.apache.ofbiz.party.communication.CommunicationEventServices" invoke="setCommEventComplete" auth="true">
-        <description>Sets the status of a communication event to COM_COMPLETE using the updateCommunicationEvent service</description>
+        <description>Sets the status of a communication event to COM_COMPLETE using the updateCommunicationEvent service,
+            set datetimeEnded to now if not defined</description>
         <attribute name="communicationEventId" type="String" mode="IN" optional="false"/>
         <attribute name="partyIdFrom" type="String" mode="IN" optional="true"/>
     </service>

Modified: ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java?rev=1822316&r1=1822315&r2=1822316&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java Fri Jan 26 15:48:02 2018
@@ -508,17 +508,27 @@ public class CommunicationEventServices
 
     public static Map<String, Object> setCommEventComplete(DispatchContext dctx, Map<String, ? extends Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
+        Delegator delegator = dctx.getDelegator();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         String communicationEventId = (String) context.get("communicationEventId");
         String partyIdFrom = (String) context.get("partyIdFrom");
 
         try {
+            GenericValue communicationEvent = delegator.findOne("CommunicationEvent", true, "communicationEventId", communicationEventId);
+            if (communicationEvent == null) {
+                return ServiceUtil.returnError(UtilProperties.getMessage("PartyUiLabels", "PartyCommunicationEventNotFound",
+                        UtilMisc.toMap("communicationEventId", communicationEventId), (Locale) context.get("locale")));
+            }
+            Timestamp endDate = communicationEvent.getTimestamp("datetimeEnded");
+            if (endDate == null) {
+                endDate = UtilDateTime.nowTimestamp();
+            }
             Map<String, Object> result = dispatcher.runSync("updateCommunicationEvent", UtilMisc.<String, Object>toMap("communicationEventId", communicationEventId,
-                    "partyIdFrom", partyIdFrom, "statusId", "COM_COMPLETE", "userLogin", userLogin));
+                    "partyIdFrom", partyIdFrom, "statusId", "COM_COMPLETE", "datetimeEnded", endDate, "userLogin", userLogin));
             if (ServiceUtil.isError(result)) {
                 return ServiceUtil.returnError(ServiceUtil.getErrorMessage(result));
             }
-        } catch (GenericServiceException esx) {
+        } catch (GeneralException esx) {
             return ServiceUtil.returnError(esx.getMessage());
         }