You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 9, 2022. It is now read-only.
: To add parameters to the functions, specify them in the params annotations.
22
24
: Example
@@ -124,9 +126,17 @@ function ext:get(
124
126
125
127
126
128
127
-
(: POST - update a process instance, potentially completing it (e.g. human step) :)
129
+
(:
130
+
: POST - update a process instance, potentially completing it (e.g. human step)
131
+
:
132
+
: POST process?processid=1234 -> Updates data only, does not lock or unlock item. DEPRECATED in current form - In future this will respect locks. Does not yet.
133
+
: POST process?processid=1234&complete=true -> Completes work item. Respects locks. (optionally) updates work item data.
134
+
: POST process?processid=1234&lock=true -> Locks the work item for the current user. (optionally) updates work item data. Respects locks.
135
+
: POST process?processid=1234&unlock=true -> Unlocks the work item if locked by current user. (optionally) update work item data. Respects locks.
136
+
:)
128
137
declare
129
138
%roxy:params("")
139
+
%rapi:transaction-mode("update")
130
140
functionext:post(
131
141
$context as map:map,
132
142
$params as map:map,
@@ -135,6 +145,8 @@ function ext:post(
135
145
136
146
let $preftype := if ("application/xml" = map:get($context,"accept-types")) then"application/xml"else"application/json"
137
147
148
+
let $part := (map:get($params,"part"),"document")[1]
149
+
138
150
let $_ := xdmp:log($input)
139
151
let $pid := map:get($params,"processid")
140
152
(:let $proc := wfu:get($pid):)
@@ -165,8 +177,63 @@ function ext:post(
165
177
(: error - cannot call complete on non completable task :)
166
178
<ext:updateResponse><ext:outcome>FAILURE</ext:outcome><ext:message>Cannot call complete on non completable task: {$props/wf:step-type/text()}</ext:message></ext:updateResponse>
167
179
else
168
-
(: TODO perform a data update but leave incomplete :)
169
-
<ext:updateResponse><ext:outcome>SUCCESS</ext:outcome><ext:message>No complete parameter, or complete parameter false. Leaving incomplete.</ext:message></ext:updateResponse>
180
+
181
+
if ("true" = map:get($params,"lock")) then
182
+
(: Lock the work item, and return its details as if get had been called. If already locked, instead return an error :)
<ext:updateResponse><ext:outcome>FAILURE</ext:outcome><ext:message>Work item could not be locked by user.</ext:message><ext:feedback>{$feedback}</ext:feedback></ext:updateResponse>
198
+
return
199
+
if (fn:empty($feedback)) then
200
+
let $fb := wfa:update-userTask($pid,$input/ext:updateRequest/wf:data/node(),$input/ext:updateRequest/wf:attachments/node())
201
+
return
202
+
if (fn:not(fn:empty($fb))) then
203
+
<ext:updateResponse><ext:outcome>FAILURE</ext:outcome><ext:message>Could not update userTask</ext:message><ext:feedback>{$fb}</ext:feedback></ext:updateResponse>
<ext:updateResponse><ext:outcome>FAILURE</ext:outcome><ext:message>Work item could not be unlocked by user.</ext:message><ext:feedback>{$feedback}</ext:feedback></ext:updateResponse>
225
+
return
226
+
if (fn:empty($feedback)) then
227
+
let $fb := wfa:update-userTask($pid,$input/ext:updateRequest/wf:data/node(),$input/ext:updateRequest/wf:attachments/node())
228
+
return
229
+
if (fn:not(fn:empty($fb))) then
230
+
<ext:updateResponse><ext:outcome>FAILURE</ext:outcome><ext:message>Could not update userTask</ext:message><ext:feedback>{$fb}</ext:feedback></ext:updateResponse>
231
+
else
232
+
$update
233
+
else
234
+
$update
235
+
else
236
+
() (: Just default to updating the data, but doing nothing around locking :)
170
237
171
238
172
239
let $out := ($res,<ext:updateResponse><ext:outcome>SUCCESS</ext:outcome></ext:updateResponse>)[1]
0 commit comments