This repository has been archived by the owner on Jan 5, 2018. It is now read-only.
/
TaskServices.xml
292 lines (277 loc) · 17.9 KB
/
TaskServices.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<?xml version="1.0" encoding="UTF-8"?>
<!--
This software is in the public domain under CC0 1.0 Universal plus a
Grant of Patent License.
To the extent possible under law, the author(s) have dedicated all
copyright and related and neighboring rights to this software to the
public domain worldwide. This software is distributed without any
warranty.
You should have received a copy of the CC0 Public Domain Dedication
along with this software (see the LICENSE.md file). If not, see
<http://creativecommons.org/publicdomain/zero/1.0/>.
-->
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/service-definition-1.6.xsd">
<service verb="get" noun="FullCalendarData">
<description>Get data to display WorkEffort tasks by due date (estimatedCompletionDate) with the FullCalender JS library (see http://fullcalendar.io/)</description>
<in-parameters>
<parameter name="partyId"/>
<parameter name="partyIdList" type="List"><parameter name="partyId"/></parameter>
<parameter name="start" required="true"/>
<parameter name="end" required="true"/>
<parameter name="titleGString" default-value="\${(workEffort.workEffortName ?: (workEffort.purposeEnumId ? workEffort.'WorkEffortPurpose#moqui.basic.Enumeration'.description : 'Event')) + ' [' + workEffort.workEffortId + ']'}"/>
<parameter name="urlGString"/>
</in-parameters>
<out-parameters>
<parameter name="eventList" type="List">
<parameter name="eventMap" type="Map">
<parameter name="id"/>
<parameter name="title"/>
<parameter name="start"><description>actualStartDate or estimatedStartDate as ISO8601 formatted String</description></parameter>
<parameter name="end"><description>actualCompletionDate or estimatedCompletionDate (or if null start date +
actualWorkDuration, estimatedWorkDuration, or estimatedWorkTime) as a ISO8601 (yyyy-MM-dd'T'HH:mm:ss) formatted String</description></parameter>
<!-- NOTE: consider supporting allDay, color, etc in the future with WorkEffort fields -->
<parameter name="url"><description>Only returned if urlGString is specified</description></parameter>
</parameter>
</parameter>
</out-parameters>
<actions>
<!--
<set field="startTs" from="ec.l10n.parseTimestamp(start.toString() + ' 00:00:00.000', 'yyyy-MM-dd HH:mm:ss.SSS')"/>
<set field="endTs" from="ec.l10n.parseTimestamp(end.toString() + ' 23:59:59.999', 'yyyy-MM-dd HH:mm:ss.SSS')"/>
-->
<!-- start/end are coming in as seconds since epoch so add '000' to make milliseconds -->
<set field="startTs" from="ec.l10n.parseTimestamp(start + '000', null)"/>
<set field="endTs" from="ec.l10n.parseTimestamp(end + '000', null)"/>
<!-- <log level="warn" message="=========== FullCalendarData start ${start} - ${startTs} end ${end} - ${endTs}"/> -->
<set field="partyIdSet" from="new HashSet()"/>
<if condition="partyId"><script>partyIdSet.add(partyId)</script></if>
<if condition="partyIdList"><script>partyIdSet.addAll(partyIdList)</script></if>
<entity-find entity-name="mantle.work.effort.WorkEffortAndParty" list="workEffortList">
<econdition field-name="workEffortTypeEnumId" value="WetTask"/>
<econdition field-name="partyId" operator="in" from="partyIdSet" ignore-if-empty="true"/>
<econdition field-name="estimatedCompletionDate" operator="greater-equals" from="startTs"/>
<econdition field-name="estimatedCompletionDate" operator="less-equals" from="endTs"/>
<select-field field-name="workEffortId"/><select-field field-name="purposeEnumId"/>
<select-field field-name="workEffortName"/>
<select-field field-name="description"/><select-field field-name="location"/>
<select-field field-name="actualStartDate"/><select-field field-name="actualCompletionDate"/>
<select-field field-name="actualWorkTime"/><select-field field-name="actualWorkDuration"/>
<select-field field-name="estimatedStartDate"/><select-field field-name="estimatedCompletionDate"/>
<select-field field-name="estimatedWorkTime"/><select-field field-name="estimatedWorkDuration"/>
<select-field field-name="timeUomId"/>
</entity-find>
<set field="eventList" from="[]"/>
<iterate list="workEffortList" entry="workEffortDef">
<set field="workEffort" from="workEffortDef"/><!-- put it in the context -->
<set field="title" from="ec.resource.expand(titleGString, '')"/>
<service-call name="mantle.work.WorkEffortServices.get#WorkEffortStartEnd" out-map="startEndOut"
in-map="[workEffortId:workEffort.workEffortId, workEffort:workEffort]"/>
<set field="start" from="ec.l10n.format(startEndOut.startDate, 'yyyy-MM-dd\'T\'HH:mm:ss')"/>
<set field="end" from="ec.l10n.format(startEndOut.endDate, 'yyyy-MM-dd\'T\'HH:mm:ss')"/>
<if condition="urlGString">
<set field="url" from="ec.resource.expand(urlGString, '')"/>
<else><set field="url" value=""/></else>
</if>
<set field="eventMap" from="[id:workEffort.workEffortId, title:title, start:start, end:end, url:url, allDay:true]"/>
<script>eventList.add(eventMap)</script>
</iterate>
</actions>
</service>
<service verb="create" noun="Task">
<description>Create a Task in a Project.</description>
<in-parameters>
<auto-parameters entity-name="mantle.work.effort.WorkEffort" include="nonpk"/>
<parameter name="rootWorkEffortId" required="true"><description>The ID of the Project</description></parameter>
<parameter name="milestoneWorkEffortId"/>
<parameter name="workEffortId"/>
<parameter name="workEffortName" required="true"/>
<parameter name="statusId" default-value="WeInPlanning"/>
<parameter name="resolutionEnumId" default-value="WerUnresolved"/>
<parameter name="priority" default-value="5" type="Long"/>
<parameter name="purposeEnumId" default-value="WepTask"/>
<parameter name="estimatedStartDate" type="Timestamp" format="yyyy-MM-dd"/>
<parameter name="estimatedCompletionDate" type="Timestamp" format="yyyy-MM-dd"/>
<parameter name="remainingWorkTime" type="BigDecimal" default="estimatedWorkTime"/>
<parameter name="timeUomId" default-value="TF_hr"/>
<parameter name="assignToPartyId" default="ec.user.userAccount.partyId"/>
<parameter name="requestId"/>
</in-parameters>
<out-parameters>
<parameter name="workEffortId"/>
</out-parameters>
<actions>
<set field="seqName" value="Project_${rootWorkEffortId}"/>
<if condition="!workEffortId">
<set field="workEffortId" value="${rootWorkEffortId}-${ec.entity.sequencedIdPrimary(seqName, null, null)}"/></if>
<service-call name="create#mantle.work.effort.WorkEffort" out-map="context" in-map="context + [workEffortTypeEnumId:'WetTask']"/>
<service-call name="create#mantle.work.effort.WorkEffortParty" in-map="[workEffortId:workEffortId, partyId:assignToPartyId,
roleTypeId:'Worker', fromDate:ec.user.nowTimestamp, statusId:'WeptAssigned']"/>
<if condition="milestoneWorkEffortId">
<service-call name="mantle.work.TaskServices.set#TaskMilestone" in-map="context"/></if>
<if condition="requestId">
<service-call name="create#mantle.request.RequestWorkEffort" in-map="[workEffortId:workEffortId, requestId:requestId]"/></if>
</actions>
</service>
<service verb="create" noun="SimpleTask">
<in-parameters>
<auto-parameters entity-name="mantle.work.effort.WorkEffort" include="nonpk"/>
<parameter name="workEffortName" required="true"/>
<parameter name="statusId" default-value="WeInPlanning"/>
<parameter name="resolutionEnumId" default-value="WerUnresolved"/>
<parameter name="priority" default-value="5" type="Long"/>
<parameter name="purposeEnumId" default-value="WepTask"/>
<parameter name="estimatedStartDate" type="Timestamp" format="yyyy-MM-dd"/>
<parameter name="estimatedCompletionDate" type="Timestamp" format="yyyy-MM-dd"/>
<parameter name="estimatedWorkTime" type="BigDecimal"/>
<parameter name="remainingWorkTime" type="BigDecimal" default="estimatedWorkTime"/>
<parameter name="timeUomId" default-value="TF_hr"/>
<parameter name="assignToPartyId" default="ec.user.userAccount.partyId"/>
<parameter name="requestId"/>
</in-parameters>
<out-parameters>
<parameter name="workEffortId"/>
</out-parameters>
<actions>
<service-call name="create#mantle.work.effort.WorkEffort" out-map="context" in-map="context + [workEffortTypeEnumId:'WetTask']"/>
<service-call name="create#mantle.work.effort.WorkEffortParty" in-map="[workEffortId:workEffortId, partyId:assignToPartyId,
roleTypeId:'Worker', fromDate:ec.user.nowTimestamp, statusId:'WeptAssigned']"/>
<if condition="requestId">
<service-call name="create#mantle.request.RequestWorkEffort" in-map="[workEffortId:workEffortId, requestId:requestId]"/></if>
</actions>
</service>
<service verb="update" noun="Task">
<in-parameters>
<parameter name="workEffortId" required="true"/>
<auto-parameters entity-name="mantle.work.effort.WorkEffort" include="nonpk"/>
<parameter name="milestoneWorkEffortId"/>
<parameter name="estimatedStartDate" type="Timestamp" format="yyyy-MM-dd"/>
<parameter name="estimatedCompletionDate" type="Timestamp" format="yyyy-MM-dd"/>
<parameter name="timeUomId" default-value="TF_hr"/>
</in-parameters>
<actions>
<service-call name="update#mantle.work.effort.WorkEffort" out-map="context" in-map="context"/>
<if condition="milestoneWorkEffortId">
<service-call name="mantle.work.TaskServices.set#TaskMilestone" in-map="context"/>
</if>
</actions>
</service>
<service verb="set" noun="TaskMilestone">
<in-parameters>
<parameter name="workEffortId" required="true"/>
<parameter name="milestoneWorkEffortId" required="true"/>
</in-parameters>
<actions>
<!-- if milestoneWorkEffortId is different from currently associated milestone, expire all milestones and assoc with new one -->
<entity-find entity-name="mantle.work.effort.WorkEffortAssoc" list="weaList">
<date-filter/>
<econdition field-name="toWorkEffortId" from="workEffortId"/>
<econdition field-name="workEffortAssocTypeEnumId" value="WeatMilestone"/>
</entity-find>
<set field="foundMilestone" from="false"/>
<iterate list="weaList" entry="wea"><if condition="wea.workEffortId == milestoneWorkEffortId">
<set field="foundMilestone" from="true"/>
<else><set field="wea.thruDate" from="ec.user.nowTimestamp"/><entity-update value-field="wea"/></else>
</if></iterate>
<if condition="!foundMilestone">
<service-call name="create#mantle.work.effort.WorkEffortAssoc"
in-map="[workEffortId:milestoneWorkEffortId, toWorkEffortId:workEffortId,
workEffortAssocTypeEnumId:'WeatMilestone', fromDate:ec.user.nowTimestamp]"/>
</if>
</actions>
</service>
<service verb="set" noun="TaskDefaults">
<description>This service runs by EECA rule before creates and updates to set some defaults.</description>
<in-parameters><parameter name="entityValue" type="Map"/></in-parameters>
<actions>
<set field="entityValue.actualWorkTime" from="entityValue.actualWorkTime ?: 0 as BigDecimal"/>
<if condition="entityValue.remainingWorkTime == null && entityValue.estimatedWorkTime && entityValue.estimatedWorkTime > entityValue.actualWorkTime">
<set field="entityValue.remainingWorkTime" from="entityValue.estimatedWorkTime - entityValue.actualWorkTime"/>
</if>
</actions>
</service>
<service verb="add" noun="TaskComment">
<in-parameters>
<parameter name="workEffortId" required="true"/>
<parameter name="subject"/>
<parameter name="body"/>
<parameter name="contentType" default-value="text/plain"/>
</in-parameters>
<actions>
<service-call name="create#mantle.party.communication.CommunicationEvent" out-map="context"
in-map="[communicationEventTypeId:'Comment', contactMechTypeEnumId:'CmtWebForm', statusId:'CeSent',
fromPartyId:ec.user.userAccount.partyId, entryDate:ec.user.nowTimestamp,
contentType:contentType, subject:subject, body:body]"/>
<service-call name="create#mantle.work.effort.WorkEffortCommEvent"
in-map="[workEffortId:workEffortId, communicationEventId:communicationEventId]"/>
</actions>
</service>
<service verb="add" noun="TaskTime">
<in-parameters>
<auto-parameters entity-name="mantle.work.time.TimeEntry" include="nonpk"/>
<parameter name="workEffortId" required="true"/>
<parameter name="partyId" default="ec.user.userAccount.partyId"/>
<parameter name="rateTypeEnumId" default-value="RatpStandard"/>
</in-parameters>
<out-parameters>
<parameter name="timeEntryId"/>
</out-parameters>
<actions>
<service-call name="mantle.work.TimeServices.store#TimeEntry" out-map="context" in-map="context"/>
<if condition="remainingWorkTime != null">
<then>
<service-call name="update#mantle.work.effort.WorkEffort"
in-map="[workEffortId:workEffortId, remainingWorkTime:remainingWorkTime]"/>
</then>
<else>
<!-- auto deduct from remainingWorkTime -->
<entity-find-one entity-name="mantle.work.time.TimeEntry" value-field="timeEntry"/>
<entity-find-one entity-name="mantle.work.effort.WorkEffort" value-field="task"/>
<if condition="task.remainingWorkTime">
<set field="task.remainingWorkTime" from="task.remainingWorkTime - timeEntry.hours"/>
<if condition="task.remainingWorkTime < 0"><set field="task.remainingWorkTime" from="0"/></if>
<entity-update value-field="task"/>
</if>
</else>
</if>
</actions>
</service>
<service verb="update" noun="TaskFromTime" authenticate="anonymous-all">
<in-parameters><parameter name="workEffortId" required="true"/></in-parameters>
<actions>
<entity-find entity-name="mantle.work.time.TimeEntryAndRates" list="tearList">
<econdition field-name="workEffortId"/></entity-find>
<set field="actualWorkTime" from="0"/>
<set field="actualClientCost" from="0"/>
<set field="actualCost" from="0"/>
<iterate list="tearList" entry="tear">
<set field="actualWorkTime" from="actualWorkTime + tear.hours"/>
<if condition="tear.clientRateAmount">
<set field="actualClientCost" from="actualClientCost + (tear.hours * tear.clientRateAmount)"/></if>
<if condition="tear.vendorRateAmount">
<set field="actualCost" from="actualCost + (tear.hours * tear.vendorRateAmount)"/></if>
</iterate>
<!-- <log level="warn" message="======== time for ${workEffortId}: ${actualWorkTime}, ${actualCost}, ${actualClientCost}\n${tearList}"/> -->
<service-call name="update#mantle.work.effort.WorkEffort"
in-map="[workEffortId:workEffortId, actualWorkTime:actualWorkTime,
actualCost:actualCost, actualClientCost:actualClientCost]"/>
</actions>
</service>
<service verb="update" noun="ProjectTimeFromTask" authenticate="anonymous-all">
<in-parameters><parameter name="rootWorkEffortId" required="true"/></in-parameters>
<actions>
<entity-find entity-name="mantle.work.time.TaskTimeSummary" list="ttsList">
<econdition field-name="rootWorkEffortId"/></entity-find>
<if condition="ttsList">
<entity-find-one entity-name="mantle.work.effort.WorkEffort" value-field="rootWorkEffort">
<field-map field-name="workEffortId" from="rootWorkEffortId"/>
</entity-find-one>
<set field="rootWorkEffort.actualWorkTime" from="ttsList[0].actualWorkTime"/>
<set field="rootWorkEffort.estimatedWorkTime" from="ttsList[0].estimatedWorkTime"/>
<set field="rootWorkEffort.remainingWorkTime" from="ttsList[0].remainingWorkTime"/>
<set field="rootWorkEffort.actualCost" from="ttsList[0].actualCost"/>
<set field="rootWorkEffort.actualClientCost" from="ttsList[0].actualClientCost"/>
<entity-update value-field="rootWorkEffort"/>
</if>
</actions>
</service>
</services>