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.
Copy file name to clipboardExpand all lines: rest-api/ext/process.xqy
+67-3Lines changed: 67 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,14 @@ function ext:get(
134
134
135
135
136
136
137
-
(: POST - update a process instance, potentially completing it (e.g. human step) :)
137
+
(:
138
+
: POST - update a process instance, potentially completing it (e.g. human step)
139
+
:
140
+
: 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.
141
+
: POST process?processid=1234&complete=true -> Completes work item. Respects locks. (optionally) updates work item data.
142
+
: POST process?processid=1234&lock=true -> Locks the work item for the current user. (optionally) updates work item data. Respects locks.
143
+
: POST process?processid=1234&unlock=true -> Unlocks the work item if locked by current user. (optionally) update work item data. Respects locks.
144
+
:)
138
145
declare
139
146
%roxy:params("")
140
147
%rapi:transaction-mode("update")
@@ -146,6 +153,8 @@ function ext:post(
146
153
147
154
let $preftype := if ("application/xml" = map:get($context,"accept-types")) then"application/xml"else"application/json"
148
155
156
+
let $part := (map:get($params,"part"),"document")[1]
157
+
149
158
let $_ := xdmp:log($input)
150
159
let $pid := map:get($params,"processid")
151
160
(:let $proc := wfu:get($pid):)
@@ -175,8 +184,63 @@ function ext:post(
175
184
(: error - cannot call complete on non completable task :)
176
185
<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>
177
186
else
178
-
(: TODO perform a data update but leave incomplete :)
179
-
<ext:updateResponse><ext:outcome>SUCCESS</ext:outcome><ext:message>No complete parameter, or complete parameter false. Leaving incomplete.</ext:message></ext:updateResponse>
187
+
188
+
if ("true" = map:get($params,"lock")) then
189
+
(: 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>
205
+
return
206
+
if (fn:empty($feedback)) then
207
+
let $fb := wfa:update-userTask($pid,$input/ext:updateRequest/wf:data/node(),$input/ext:updateRequest/wf:attachments/node())
208
+
return
209
+
if (fn:not(fn:empty($fb))) then
210
+
<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>
232
+
return
233
+
if (fn:empty($feedback)) then
234
+
let $fb := wfa:update-userTask($pid,$input/ext:updateRequest/wf:data/node(),$input/ext:updateRequest/wf:attachments/node())
235
+
return
236
+
if (fn:not(fn:empty($fb))) then
237
+
<ext:updateResponse><ext:outcome>FAILURE</ext:outcome><ext:message>Could not update userTask</ext:message><ext:feedback>{$fb}</ext:feedback></ext:updateResponse>
238
+
else
239
+
$update
240
+
else
241
+
$update
242
+
else
243
+
() (: Just default to updating the data, but doing nothing around locking :)
180
244
181
245
182
246
let $out := ($res,<ext:updateResponse><ext:outcome>SUCCESS</ext:outcome></ext:updateResponse>)[1]
0 commit comments