Improved: When completing communicationEvent through setCommEventComplete, if datetimeEnded is null, set it to nowTimestamp (OFBIZ-10181)
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1822316 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -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>
|
||||
|
||||
+12
-2
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user