Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit b8fe672

Browse files
committed
#115 - performance improvements and bugfixes from feedback
1 parent 09d14c6 commit b8fe672

File tree

9 files changed

+113
-41
lines changed

9 files changed

+113
-41
lines changed

deploy/ml-config.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,26 @@
253253
-->
254254
</range-element-indexes>
255255
<range-element-attribute-indexes>
256+
<range-element-attribute-index>
257+
<scalar-type>string</scalar-type>
258+
<parent-namespace-uri>http://marklogic.com/workflow</parent-namespace-uri>
259+
<parent-localname>process</parent-localname>
260+
<namespace-uri/>
261+
<localname>id</localname>
262+
<collation>http://marklogic.com/collation/</collation>
263+
<range-value-positions>false</range-value-positions>
264+
<invalid-values>ignore</invalid-values>
265+
</range-element-attribute-index>
266+
<range-element-attribute-index>
267+
<scalar-type>string</scalar-type>
268+
<parent-namespace-uri>http://marklogic.com/workflow</parent-namespace-uri>
269+
<parent-localname>attachment</parent-localname>
270+
<namespace-uri/>
271+
<localname>uri</localname>
272+
<collation>http://marklogic.com/collation/</collation>
273+
<range-value-positions>false</range-value-positions>
274+
<invalid-values>ignore</invalid-values>
275+
</range-element-attribute-index>
256276
<!--
257277
Sample for:
258278
<person name="bob" xmlns="http://marklogic.com/ns/sample"/>

documentation/INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Roxy Installation
1+
### Roxy Installation
22

33
To install via roxy, within the roxy directory, edit the properties file for the target environment - for example, ``deploy/local.properties`` and run the following commands:
44

src/test/suites/e2e-rest-process-xml/015-processmodel-xml.xqy

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ return ( (:
1717
test:assert-equal('SUCCESS', xs:string($process[2]/createResponse/outcome)),
1818
test:assert-equal('015-restapi-tests__1__0', xs:string($process[2]/createResponse/modelId))
1919
);
20+
(:
21+
<ext:createResponse xmlns:ext="http://marklogic.com/rest-api/resource/processmodel">
22+
<ext:outcome>SUCCESS</ext:outcome>
23+
<ext:modelId>015-restapi-tests__1__0</ext:modelId>
24+
</ext:createResponse>
25+
:)
2026

2127
(: 02-processmodel-read :)
2228
import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy";
@@ -48,6 +54,12 @@ return ( (:
4854
test:assert-equal('SUCCESS', xs:string($result[2]/createResponse/outcome)),
4955
test:assert-equal('015-restapi-tests__1__2', xs:string($result[2]/createResponse/modelId))
5056
);
57+
(:
58+
<ext:createResponse xmlns:ext="http://marklogic.com/rest-api/resource/processmodel">
59+
<ext:outcome>SUCCESS</ext:outcome>
60+
<ext:modelId>015-restapi-tests__1__2</ext:modelId>
61+
</ext:createResponse>
62+
:)
5163

5264
(: 04-processmodel-publish :)
5365
import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy";
@@ -66,6 +78,12 @@ return ( (:
6678
test:assert-equal('SUCCESS', xs:string($result[2]/updateResponse/outcome)),
6779
test:assert-exists(xs:string($result[2]/updateResponse/domainId))
6880
);
81+
(:
82+
<ext:updateResponse xmlns:ext="http://marklogic.com/rest-api/resource/processmodel">
83+
<ext:outcome>SUCCESS</ext:outcome>
84+
<ext:domainId>16663957717060497977</ext:domainId>
85+
</ext:updateResponse>
86+
:)
6987

7088
(: there is and has never been 05 :)
7189

@@ -100,13 +118,21 @@ return (
100118
test:assert-equal('SUCCESS', xs:string($result[2]/ext:readResponse/ext:outcome)),
101119
test:assert-exists($result[2]/ext:readResponse/ext:document)
102120
);
121+
(:
122+
<ext:readResponse xmlns:ext="http://marklogic.com/rest-api/resource/process">
123+
<ext:outcome>SUCCESS</ext:outcome>
124+
<ext:document/>
125+
</ext:readResponse>
126+
:)
103127

104128
(: 08-processinbox-read :)
105129
import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy";
106130
import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy";
107131
import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy";
132+
declare namespace cpf = "http://marklogic.com/cpf";
108133
declare namespace ext = "http://marklogic.com/rest-api/resource/processinbox";
109134
declare namespace http = "xdmp:http";
135+
declare namespace prop = "http://marklogic.com/xdmp/property";
110136
declare namespace wf="http://marklogic.com/workflow";
111137

112138
let $_pause := xdmp:sleep(5000)
@@ -115,7 +141,23 @@ let $result := wrt:test-08-processinbox-read($const:xml-options)
115141
return (
116142
test:assert-equal('200', xs:string($result[1]/http:code)),
117143
test:assert-equal('SUCCESS', xs:string($result[2]/ext:readResponse/ext:outcome)),
118-
test:assert-exists($result[2]/ext:readResponse/wf:inbox/wf:task[@processid=$pid])
144+
test:assert-exists($result[2]/ext:readResponse/wf:inbox/wf:task[@processid=$pid]),
145+
let $task := $result[2]/ext:readResponse/wf:inbox/wf:task[@processid=$pid]
146+
return (
147+
test:assert-exists($task/wf:process-data/wf:process/wf:data),
148+
test:assert-exists($task/wf:process-data/wf:process/wf:attachments),
149+
test:assert-exists($task/wf:process-data/wf:process/wf:audit-trail),
150+
test:assert-exists($task/wf:process-data/wf:process/wf:metrics),
151+
test:assert-exists($task/wf:process-data/wf:process/wf:process-definition-name),
152+
let $properties := $task/wf:process-properties/prop:properties
153+
return (
154+
test:assert-equal('done', xs:string($properties/cpf:processing-status)),
155+
test:assert-equal('user', xs:string($properties/wf:currentStep/wf:type)),
156+
test:assert-equal('admin', xs:string($properties/wf:currentStep/wf:assignee)),
157+
test:assert-equal('userTask', xs:string($properties/wf:currentStep/wf:step-type)),
158+
test:assert-equal('ENTERED', xs:string($properties/wf:currentStep/wf:step-status))
159+
)
160+
)
119161
);
120162

121163
(: 09-process-update :)

src/workflowengine/actions/sendTask.xqy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ try {
5555
(: If still none, throw failure message (misconfiguration) :)
5656
return
5757
(
58-
xdmp:email($messageXml)
58+
if(fn:empty($messageXml)) then () else xdmp:email($messageXml)
5959
,
6060
wfu:complete( $cpf:document-uri, $cpf:transition, (), $st )
6161
)

src/workflowengine/models/alert-action-process.xqy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ xquery version "1.0-ml";
99

1010
import module namespace alert = "http://marklogic.com/xdmp/alert" at "/MarkLogic/alert.xqy";
1111
declare namespace wf = "http://marklogic.com/workflow";
12-
import module namespace sem = "http://marklogic.com/semantics" at "/MarkLogic/semantics.xqy";
1312

1413
import module namespace wfu="http://marklogic.com/workflow-util" at "/workflowengine/models/workflow-util.xqy";
1514

@@ -29,12 +28,12 @@ let $pid := wfu:create($procname,$alert:doc/element(),
2928
return ()
3029

3130

32-
(:)
31+
(:
3332
xdmp:document-insert($procname || "/" || sem:uuid-string() || ".xml",
3433
<process xmlns="http://marklogic.com/workflow/process">
3534
<data>
3635
{
37-
(: TODO check config for mappings options - rather than map entire document in:)
36+
( : TODO check config for mappings options - rather than map entire document in : )
3837
$alert:doc/element()
3938
}
4039
</data>

src/workflowengine/models/lib-search-subscribe.xqy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ declare function ss:unsubscribe-and-delete-search($searchname,$notificationurl)
104104
declare function ss:save-subscribe-search($searchdoc as cts:query,$searchname as xs:string,$notificationurl as xs:string,$alert-detail as xs:string?,$content-type as xs:string?) {
105105
(: use current user on app server :)
106106
( xdmp:eval(
107-
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/modules/lib-search-subscribe.xqy";',
107+
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/workflowengine/modules/lib-search-subscribe.xqy";',
108108
'declare variable $my:searchdoc as cts:query external;declare variable $my:searchname as xs:string external;',
109109
'ah:do-save($my:searchdoc,$my:searchname)'),
110110
(xs:QName("my:searchdoc"),$searchdoc,xs:QName("my:searchname"),$searchname),
@@ -160,14 +160,14 @@ declare function ss:do-subscribe-check($notificationurl as xs:string,$searchname
160160
declare function ss:do-add-action-rule($alert-name as xs:string,$notificationurl as xs:string,$alert-module as xs:string?,$alert-detail as xs:string,$content-type as xs:string,$searchname as xs:string,$cpf-domain as xs:string,$dbname as xs:string,$searchdoc as cts:query?) as xs:boolean {
161161

162162
let $e2 := xdmp:eval(
163-
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/modules/lib-search-subscribe.xqy";',
163+
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/workflowengine/modules/lib-search-subscribe.xqy";',
164164
'declare variable $my:alert-name as xs:string external;declare variable $my:alert-module as xs:string external;declare variable $my:dbname as xs:string external;',
165165
'ah:create-action($my:alert-name,$my:alert-module,$my:dbname,())'),
166166
(xs:QName("my:alert-name"),$alert-name,xs:QName("my:alert-module"),$alert-module,xs:QName("my:dbname"),$dbname),
167167
<options xmlns="xdmp:eval"><isolation>different-transaction</isolation></options>
168168
)
169169
let $e3 := xdmp:eval(
170-
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/modules/lib-search-subscribe.xqy";',
170+
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/workflowengine/modules/lib-search-subscribe.xqy";',
171171
'declare variable $my:alert-name as xs:string external;declare variable $my:alert-detail as xs:string external;declare variable $my:content-type as xs:string external;',
172172
'declare variable $my:notificationurl as xs:string external;declare variable $my:searchname as xs:string external;declare variable $my:searchdoc as cts:query external;',
173173
'ah:create-rule-notify($my:alert-name,$my:alert-detail,$my:content-type,$my:notificationurl,$my:searchname,$my:searchdoc)'),
@@ -180,15 +180,15 @@ declare function ss:do-add-action-rule($alert-name as xs:string,$notificationurl
180180

181181
declare function ss:do-subscribe($notificationurl as xs:string,$alert-module as xs:string?,$alert-detail as xs:string,$content-type as xs:string,$searchname as xs:string,$cpf-domain as xs:string,$dbname as xs:string,$searchdoc as cts:query?) as xs:boolean {
182182
let $alert-name := xdmp:eval(
183-
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/modules/lib-search-subscribe.xqy";',
183+
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/workflowengine/modules/lib-search-subscribe.xqy";',
184184
'declare variable $my:notificationurl as xs:string external;declare variable $my:searchname as xs:string external;',
185185
'ah:create-config($my:notificationurl,$my:searchname)'),
186186
(xs:QName("my:notificationurl"),$notificationurl,xs:QName("my:searchname"),$searchname),
187187
<options xmlns="xdmp:eval"><isolation>different-transaction</isolation></options>
188188
)
189189
let $e2 := ss:do-add-action-rule($alert-name,$notificationurl ,$alert-module,$alert-detail,$content-type,$searchname,$cpf-domain,$dbname,$searchdoc)
190190
let $e4 := xdmp:eval(
191-
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/modules/lib-search-subscribe.xqy";',
191+
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/workflowengine/modules/lib-search-subscribe.xqy";',
192192
'declare variable $my:alert-name as xs:string external;declare variable $my:cpf-domain as xs:string external;',
193193
'ah:cpf-enable($my:alert-name,$my:cpf-domain)'),
194194
(xs:QName("my:alert-name"),$alert-name,xs:QName("my:cpf-domain"),$cpf-domain),
@@ -207,15 +207,15 @@ declare function ss:do-unsubscribe($notificationurl as xs:string,$searchname as
207207
alert:rule-remove($alert-name,$rule/@id)
208208

209209
let $l := xdmp:eval(
210-
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/modules/lib-search-subscribe.xqy";',
210+
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/workflowengine/modules/lib-search-subscribe.xqy";',
211211
'import module namespace alert="http://marklogic.com/xdmp/alert" at "/MarkLogic/alert.xqy";',
212212
'declare variable $my:alert-name as xs:string external;',
213213
'alert:config-set-cpf-domain-names(alert:config-get($my:alert-name), ())'),
214214
(xs:QName("my:alert-name"),$alert-name),
215215
<options xmlns="xdmp:eval"><isolation>different-transaction</isolation></options>
216216
)(:)
217217
let $e1 := xdmp:eval(
218-
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/modules/lib-search-subscribe.xqy";',
218+
fn:concat('xquery version "1.0-ml"; declare namespace my="http://marklogic.com/alerts"; import module namespace ah = "http://marklogic.com/search/subscribe" at "/workflowengine/modules/lib-search-subscribe.xqy";',
219219
'import module namespace alert="http://marklogic.com/xdmp/alert" at "/MarkLogic/alert.xqy";',
220220
'declare variable $my:alert-name as xs:string external;',
221221
'alert:config-delete($my:alert-name)'),

src/workflowengine/models/workflow-actions.xqy

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ declare namespace error="http://marklogic.com/xdmp/error";
1919
(: EXTERNAL CALLABLE FUNCTIONS - update-* updates the task, but does not complete it. complete-* does update and complete. :)
2020

2121
declare function update-userTask($processId as xs:string,$data as node()*,$attachments as node()*) as node()? {
22-
let $_ := xdmp:log("In wfa:update-userTask")
22+
let $_ := xdmp:log("In wfa:update-userTask processId: "|| $processId, "debug")
2323
return
24-
update-generic($processId,$data,$attachments)
24+
update-generic($processId, $data, $attachments)
2525
};
2626

2727
(:
2828
: Complete a user task, moving it on to the next step. (Just marks as complete)
2929
:)
3030
declare function complete-userTask($processId as xs:string,$data as node()*,$attachments as node()*) as node()? {
31-
let $_ := xdmp:log("In wfa:complete-userTask")
31+
let $_ := xdmp:log("In wfa:complete-userTask processId: "|| $processId, "debug")
3232
let $unlock :=
3333
if (fn:not(fn:empty(wfu:getProperties($processId)/wf:currentStep/wf:lock))) then
3434
wfu:unlock($processId) (: We call this to ensure this user has the current lock, even though wf:currentStep will be deleted :)
@@ -51,27 +51,27 @@ declare function complete-userTask($processId as xs:string,$data as node()*,$att
5151

5252
(: INTERNAL METHODS :)
5353
declare function update-generic($processId as xs:string,$data as node()*,$attachments as node()*) as node()? {
54-
let $_ := xdmp:log("In wfa:update-generic")
55-
56-
let $previous-data := fn:doc(wfu:getProcessUri($processId))/wf:process/wf:data
57-
let $previous-attach := fn:doc(wfu:getProcessUri($processId))/wf:process/wf:attachments
54+
let $_ := xdmp:log("In wfa:update-generic processId: "|| $processId, "debug")
55+
let $doc := fn:doc(wfu:getProcessUri($processId))
56+
let $previous-data := $doc/wf:process/wf:data
57+
let $previous-attach := $doc/wf:process/wf:attachments
5858

5959
return (
60-
xdmp:node-replace(fn:doc(wfu:getProcessUri($processId))/wf:process/wf:data,
60+
xdmp:node-replace($doc/wf:process/wf:data,
6161
(: Keep previous data if not newly sent and add new elements :)
6262
element wf:data {
6363
($previous-data/* except $data/(let $qname := fn:node-name(.) return $previous-data/*[fn:node-name(.) eq $qname])),
6464
$data
6565
}
6666
),
67-
xdmp:node-replace(fn:doc(wfu:getProcessUri($processId))/wf:process/wf:attachments,
68-
(: Keep previous data if not newly sent and add new elements :)
67+
xdmp:node-replace($doc/wf:process/wf:attachments,
68+
(: Keep previous data if not newly sent and add new elements :)
6969
element wf:attachments {
7070
($previous-attach/* except $previous-attach/*[@name eq $attachments/@name]),
7171
$attachments
7272
}
7373
)
74-
)
74+
)
7575
};
7676

7777
(:

src/workflowengine/models/workflow-import.xqy

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
xquery version "1.0-ml";
22

33
module namespace m="http://marklogic.com/workflow-import";
4-
declare namespace wf="http://marklogic.com/workflow";
5-
6-
declare namespace sc="http://www.w3.org/2005/07/scxml";
7-
declare namespace b2="http://www.omg.org/spec/BPMN/20100524/MODEL";
8-
94

105
import module namespace p="http://marklogic.com/cpf/pipelines" at "/MarkLogic/cpf/pipelines.xqy";
116
import module namespace dom = "http://marklogic.com/cpf/domains" at "/MarkLogic/cpf/domains.xqy";
12-
13-
147
import module namespace stack="http://marklogic.com/stack" at "/workflowengine/models/lib-stack.xqy";
15-
16-
178
import module namespace ss = "http://marklogic.com/alerts/alerts" at "/workflowengine/models/lib-alerts.xqy";
189

10+
declare namespace wf="http://marklogic.com/workflow";
11+
declare namespace sc="http://www.w3.org/2005/07/scxml";
12+
declare namespace b2="http://www.omg.org/spec/BPMN/20100524/MODEL";
13+
1914
(: TODO replace following outgoing routes with call to m:b2getNextSteps() :)
2015

2116
(: REST API OR XQUERY PUBLIC API FUNCTIONS :)

0 commit comments

Comments
 (0)