1 | <accessor debug="false"> |
---|
2 | <name>ISOcat.access.data.cr.new</name> |
---|
3 | <descr>Create a new change request</descr> |
---|
4 | <param mandatory="true"> |
---|
5 | <name>cr</name> |
---|
6 | <descr>the CR</descr> |
---|
7 | </param> |
---|
8 | <param mandatory="true"> |
---|
9 | <name>user</name> |
---|
10 | <descr>the user submitting the CR</descr> |
---|
11 | <type canonical="true">string</type> |
---|
12 | </param> |
---|
13 | <idoc> |
---|
14 | <accessor-debug> |
---|
15 | <instr> |
---|
16 | <type>log</type> |
---|
17 | <operand>var:cr</operand> |
---|
18 | </instr> |
---|
19 | </accessor-debug> |
---|
20 | <!-- copy flag --> |
---|
21 | <instr> |
---|
22 | <type>sloot.xpath2eval</type> |
---|
23 | <operand>var:cr</operand> |
---|
24 | <operator> |
---|
25 | <xpath>/cr/dcs/@copy eq 'true'</xpath> |
---|
26 | </operator> |
---|
27 | <target>var:copy</target> |
---|
28 | </instr> |
---|
29 | <!-- get the DCS --> |
---|
30 | <accessor-trace name="DCS"> |
---|
31 | <instr> |
---|
32 | <type>sloot.xpath2eval</type> |
---|
33 | <operand>var:cr</operand> |
---|
34 | <operator> |
---|
35 | <xpath>/cr/dcs/@ref</xpath> |
---|
36 | </operator> |
---|
37 | <param> |
---|
38 | <return> |
---|
39 | <canonical/> |
---|
40 | <string/> |
---|
41 | </return> |
---|
42 | </param> |
---|
43 | <target>var:dcs</target> |
---|
44 | </instr> |
---|
45 | <instr> |
---|
46 | <type>ISOcat.access.data.dcs</type> |
---|
47 | <dcs>var:dcs</dcs> |
---|
48 | <profs> |
---|
49 | <string>true</string> |
---|
50 | </profs> |
---|
51 | <sort> |
---|
52 | <string>dependency</string> |
---|
53 | </sort> |
---|
54 | <target>var:dcs</target> |
---|
55 | </instr> |
---|
56 | <instr> |
---|
57 | <type>sloot.xquery</type> |
---|
58 | <operator> |
---|
59 | <cr by="{$cr/cr/@by}"> |
---|
60 | {$cr/cr/(* except dcs)} |
---|
61 | {$dcs} |
---|
62 | </cr> |
---|
63 | </operator> |
---|
64 | <cr>var:cr</cr> |
---|
65 | <dcs>var:dcs</dcs> |
---|
66 | <target>var:cr</target> |
---|
67 | </instr> |
---|
68 | <accessor-debug> |
---|
69 | <instr> |
---|
70 | <type>log</type> |
---|
71 | <operand>var:cr</operand> |
---|
72 | </instr> |
---|
73 | </accessor-debug> |
---|
74 | </accessor-trace> |
---|
75 | <!-- check the change request --> |
---|
76 | <instr> |
---|
77 | <type>ISOcat.access.data.cr.check</type> |
---|
78 | <cr>var:cr</cr> |
---|
79 | <target>var:cr</target> |
---|
80 | </instr> |
---|
81 | <choose> |
---|
82 | <cond> |
---|
83 | <instr> |
---|
84 | <type>sloot.xpath2eval</type> |
---|
85 | <operand>var:cr</operand> |
---|
86 | <operator> |
---|
87 | <xpath>/cr/@check='invalid'</xpath> |
---|
88 | </operator> |
---|
89 | <target>this:cond</target> |
---|
90 | </instr> |
---|
91 | </cond> |
---|
92 | <then> |
---|
93 | <instr> |
---|
94 | <type>throw</type> |
---|
95 | <operand> |
---|
96 | <ex> |
---|
97 | <id>ISOcat[BAD REQUEST]</id> |
---|
98 | <message>The submitted change request is invalid.</message> |
---|
99 | </ex> |
---|
100 | </operand> |
---|
101 | </instr> |
---|
102 | </then> |
---|
103 | </choose> |
---|
104 | <!-- derive a name for the change request --> |
---|
105 | <instr> |
---|
106 | <type>xslt2</type> |
---|
107 | <operand>var:cr</operand> |
---|
108 | <operator> |
---|
109 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> |
---|
110 | <xsl:template match="/cr"> |
---|
111 | <string> |
---|
112 | <xsl:value-of select="format-dateTime(current-dateTime(),'[Y][M01][D01]-[H01]:[m01]')"/> |
---|
113 | <xsl:text>-</xsl:text> |
---|
114 | <xsl:value-of select="@by"/> |
---|
115 | <xsl:text>-</xsl:text> |
---|
116 | <xsl:value-of select="dcs/@name"/> |
---|
117 | </string> |
---|
118 | </xsl:template> |
---|
119 | </xsl:stylesheet> |
---|
120 | </operator> |
---|
121 | <target>var:name</target> |
---|
122 | </instr> |
---|
123 | <instr> |
---|
124 | <type>sloot.xpath2eval</type> |
---|
125 | <operand>var:cr</operand> |
---|
126 | <operator> |
---|
127 | <xpath>if (exists(/cr/td/@tdg)) then (/cr/td/@tdg) else ((/cr/td/tdg[@check='valid']/@ref)[1])</xpath> |
---|
128 | </operator> |
---|
129 | <param> |
---|
130 | <return> |
---|
131 | <canonical/> |
---|
132 | <string/> |
---|
133 | </return> |
---|
134 | </param> |
---|
135 | <target>var:tdg</target> |
---|
136 | </instr> |
---|
137 | <accessor-debug> |
---|
138 | <instr> |
---|
139 | <type>sloot.log</type> |
---|
140 | <operator> |
---|
141 | <msg>DBG: create CR[{string($name)} submitted to TDG[{string($tdg)}]]</msg> |
---|
142 | </operator> |
---|
143 | <name>var:name</name> |
---|
144 | <tdg>var:tdg</tdg> |
---|
145 | </instr> |
---|
146 | </accessor-debug> |
---|
147 | <!-- fill a new DCS --> |
---|
148 | <instr> |
---|
149 | <type>sloot.xquery</type> |
---|
150 | <operator> |
---|
151 | <dcs owner="{string($tdg)}" name="{string($name)}"/> |
---|
152 | </operator> |
---|
153 | <tdg>var:tdg</tdg> |
---|
154 | <name>var:name</name> |
---|
155 | <target>var:dcs</target> |
---|
156 | </instr> |
---|
157 | <!-- sort the dependency properly --> |
---|
158 | <instr> |
---|
159 | <type>xslt2</type> |
---|
160 | <operand>var:cr</operand> |
---|
161 | <operator> |
---|
162 | <xsl:stylesheet |
---|
163 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" |
---|
164 | xmlns:isocat="http://www.isocat.org/" |
---|
165 | > |
---|
166 | <!-- identity copy --> |
---|
167 | <xsl:template match="@*|node()"> |
---|
168 | <xsl:copy> |
---|
169 | <xsl:apply-templates select="@*|node()"/> |
---|
170 | </xsl:copy> |
---|
171 | </xsl:template> |
---|
172 | <xsl:function name="isocat:path"> |
---|
173 | <xsl:param name="dc"/> |
---|
174 | <xsl:choose> |
---|
175 | <xsl:when test="exists($dc/isa)"> |
---|
176 | <xsl:variable name="isa" select="$dc/../dc[id=$dc/isa]"/> |
---|
177 | <xsl:sequence select="concat(isocat:path($isa),'/',$dc/id)"/> |
---|
178 | </xsl:when> |
---|
179 | <xsl:otherwise> |
---|
180 | <xsl:sequence select="concat('/',$dc/id)"/> |
---|
181 | </xsl:otherwise> |
---|
182 | </xsl:choose> |
---|
183 | </xsl:function> |
---|
184 | <xsl:template match="dcs" priority="1"> |
---|
185 | <xsl:copy> |
---|
186 | <xsl:apply-templates select="dc[type='simple']"> |
---|
187 | <xsl:sort select="isocat:path(.)"/> |
---|
188 | </xsl:apply-templates> |
---|
189 | <xsl:apply-templates select="dc[type!='simple']"/> |
---|
190 | </xsl:copy> |
---|
191 | </xsl:template> |
---|
192 | </xsl:stylesheet> |
---|
193 | </operator> |
---|
194 | <target>var:cr</target> |
---|
195 | </instr> |
---|
196 | <!-- initialize a lookup map --> |
---|
197 | <instr> |
---|
198 | <type>sloot.xquery</type> |
---|
199 | <operator> |
---|
200 | <map> |
---|
201 | { |
---|
202 | for $entry in $cr//dcs/dc |
---|
203 | return |
---|
204 | <entry> |
---|
205 | <from>{string($entry/id)}</from> |
---|
206 | <to>{string($entry/id)}</to> |
---|
207 | </entry> |
---|
208 | } |
---|
209 | </map> |
---|
210 | </operator> |
---|
211 | <cr>var:cr</cr> |
---|
212 | <target>var:map</target> |
---|
213 | </instr> |
---|
214 | <accessor-debug> |
---|
215 | <instr> |
---|
216 | <type>log</type> |
---|
217 | <operand>var:map</operand> |
---|
218 | </instr> |
---|
219 | </accessor-debug> |
---|
220 | <while> |
---|
221 | <cond> |
---|
222 | <instr> |
---|
223 | <type>sloot.xpath2eval</type> |
---|
224 | <operand>var:cr</operand> |
---|
225 | <operator> |
---|
226 | <xpath>exists(/cr/dcs/dc)</xpath> |
---|
227 | </operator> |
---|
228 | <target>this:cond</target> |
---|
229 | </instr> |
---|
230 | </cond> |
---|
231 | <seq> |
---|
232 | <instr> |
---|
233 | <type>sloot.xpath2eval</type> |
---|
234 | <operand>var:cr</operand> |
---|
235 | <operator> |
---|
236 | <xpath>(cr/dcs/dc)[1]/@ref</xpath> |
---|
237 | </operator> |
---|
238 | <param> |
---|
239 | <return> |
---|
240 | <canonical/> |
---|
241 | <string/> |
---|
242 | </return> |
---|
243 | </param> |
---|
244 | <target>var:dc</target> |
---|
245 | </instr> |
---|
246 | <choose> |
---|
247 | <cond> |
---|
248 | <instr> |
---|
249 | <type>copy</type> |
---|
250 | <operand>var:copy</operand> |
---|
251 | <target>this:cond</target> |
---|
252 | </instr> |
---|
253 | </cond> |
---|
254 | <then> |
---|
255 | <!-- create a (private) copy of the DCs: |
---|
256 | - set the registration status of the old/new DCs to candidate (need a change message owned by the user) |
---|
257 | - set the administration status of the new DCs to pre-evaluation |
---|
258 | - the TDG becomes the owner of the DCS and the new DCs |
---|
259 | --> |
---|
260 | <accessor-debug> |
---|
261 | <instr> |
---|
262 | <type>sloot.log</type> |
---|
263 | <operator> |
---|
264 | <msg>DBG: copy DC[{string($dc)}]</msg> |
---|
265 | </operator> |
---|
266 | <dc>var:dc</dc> |
---|
267 | </instr> |
---|
268 | </accessor-debug> |
---|
269 | <instr> |
---|
270 | <type>sloot.xquery</type> |
---|
271 | <operator> |
---|
272 | <string>Created branch for change request '{string($name)}'.</string> |
---|
273 | </operator> |
---|
274 | <name>var:name</name> |
---|
275 | <target>var:message</target> |
---|
276 | </instr> |
---|
277 | <instr> |
---|
278 | <type>ISOcat.access.data.dc.copy</type> |
---|
279 | <dc>var:dc</dc> |
---|
280 | <owner>var:tdg</owner> |
---|
281 | <user>var:user</user> |
---|
282 | <message>var:message</message> |
---|
283 | <mode> |
---|
284 | <string>branch</string> |
---|
285 | </mode> |
---|
286 | <status> |
---|
287 | <string>pre-evaluation</string> |
---|
288 | </status> |
---|
289 | <map>var:map</map> |
---|
290 | <target>var:sdc</target> |
---|
291 | </instr> |
---|
292 | <accessor-debug> |
---|
293 | <instr> |
---|
294 | <type>log</type> |
---|
295 | <operand>var:sdc</operand> |
---|
296 | </instr> |
---|
297 | </accessor-debug> |
---|
298 | <!-- update entry in the lookup map --> |
---|
299 | <instr> |
---|
300 | <type>xslt2</type> |
---|
301 | <operand>var:map</operand> |
---|
302 | <operator> |
---|
303 | <xsl:stylesheet |
---|
304 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" |
---|
305 | xmlns:dcif="http://www.isocat.org/ns/dcif" |
---|
306 | xmlns:isocat="http://www.isocat.org/" |
---|
307 | > |
---|
308 | <xsl:param name="from"/> |
---|
309 | <xsl:param name="to"/> |
---|
310 | <!-- identity copy --> |
---|
311 | <xsl:template match="@*|node()"> |
---|
312 | <xsl:copy> |
---|
313 | <xsl:apply-templates select="@*|node()"/> |
---|
314 | </xsl:copy> |
---|
315 | </xsl:template> |
---|
316 | <!-- update to --> |
---|
317 | <xsl:template match="to[../from=$from]"> |
---|
318 | <to> |
---|
319 | <xsl:value-of select="$to//dcif:dataCategory/@isocat:id"/> |
---|
320 | </to> |
---|
321 | </xsl:template> |
---|
322 | </xsl:stylesheet> |
---|
323 | </operator> |
---|
324 | <from>var:dc</from> |
---|
325 | <to>var:sdc</to> |
---|
326 | <target>var:map</target> |
---|
327 | </instr> |
---|
328 | <accessor-debug> |
---|
329 | <instr> |
---|
330 | <type>log</type> |
---|
331 | <operand>var:map</operand> |
---|
332 | </instr> |
---|
333 | </accessor-debug> |
---|
334 | <!-- TODO: should only happen for private DCs --> |
---|
335 | <instr> |
---|
336 | <type>ISOcat.access.data.dc.status</type> |
---|
337 | <dc>var:dc</dc> |
---|
338 | <status> |
---|
339 | <string>candidate</string> |
---|
340 | </status> |
---|
341 | <user>var:user</user> |
---|
342 | <message>var:message</message> |
---|
343 | <target>var:void</target> |
---|
344 | </instr> |
---|
345 | <instr> |
---|
346 | <type>ISOcat.access.data.dc.change</type> |
---|
347 | <dc>var:dc</dc> |
---|
348 | <user>var:user</user> |
---|
349 | <change>var:message</change> |
---|
350 | <target>var:void</target> |
---|
351 | </instr> |
---|
352 | </then> |
---|
353 | <else> |
---|
354 | <!-- the TDG should become the owner of these DCs and the status should become submission --> |
---|
355 | <instr> |
---|
356 | <type>sloot.xquery</type> |
---|
357 | <operator> |
---|
358 | <string>Transferred for change request '{string($name)}'.</string> |
---|
359 | </operator> |
---|
360 | <name>var:name</name> |
---|
361 | <target>var:message</target> |
---|
362 | </instr> |
---|
363 | <instr> |
---|
364 | <type>ISOcat.access.data.dc.transfer</type> |
---|
365 | <dc>var:dc</dc> |
---|
366 | <owner>var:tdg</owner> |
---|
367 | <target>var:void</target> |
---|
368 | </instr> |
---|
369 | <instr> |
---|
370 | <type>ISOcat.access.data.dc.status</type> |
---|
371 | <dc>var:dc</dc> |
---|
372 | <status> |
---|
373 | <string>pre-evaluation</string> |
---|
374 | </status> |
---|
375 | <user>var:user</user> |
---|
376 | <message>var:message</message> |
---|
377 | <target>var:void</target> |
---|
378 | </instr> |
---|
379 | <instr> |
---|
380 | <type>ISOcat.access.data.dc.change</type> |
---|
381 | <dc>var:dc</dc> |
---|
382 | <user>var:user</user> |
---|
383 | <change>var:message</change> |
---|
384 | <target>var:void</target> |
---|
385 | </instr> |
---|
386 | <instr> |
---|
387 | <type>ISOcat.access.data.dc</type> |
---|
388 | <dc>var:dc</dc> |
---|
389 | <target>var:sdc</target> |
---|
390 | </instr> |
---|
391 | </else> |
---|
392 | </choose> |
---|
393 | <!-- add the submitted DC to the CR DCS --> |
---|
394 | <instr> |
---|
395 | <type>sloot.xquery</type> |
---|
396 | <operator> |
---|
397 | <xquery> |
---|
398 | declare namespace dcif="http://www.isocat.org/ns/dcif"; |
---|
399 | declare namespace isocat="http://www.isocat.org/"; |
---|
400 | |
---|
401 | declare variable $dc as node() external; |
---|
402 | |
---|
403 | <dc ref="{$dc//dcif:dataCategory/@isocat:id}" type="{$dc//dcif:dataCategory/@isocat:type}"/> |
---|
404 | </xquery> |
---|
405 | </operator> |
---|
406 | <dc>var:sdc</dc> |
---|
407 | <target>var:ref</target> |
---|
408 | </instr> |
---|
409 | <accessor-debug> |
---|
410 | <instr> |
---|
411 | <type>log</type> |
---|
412 | <operand>var:ref</operand> |
---|
413 | </instr> |
---|
414 | </accessor-debug> |
---|
415 | <instr> |
---|
416 | <type>stm</type> |
---|
417 | <operand>var:dcs</operand> |
---|
418 | <operator> |
---|
419 | <stm:group xmlns:stm="http://1060.org/stm"> |
---|
420 | <stm:append xpath="/dcs"> |
---|
421 | <stm:param/> |
---|
422 | </stm:append> |
---|
423 | </stm:group> |
---|
424 | </operator> |
---|
425 | <param>var:ref</param> |
---|
426 | <target>var:dcs</target> |
---|
427 | </instr> |
---|
428 | <accessor-debug> |
---|
429 | <instr> |
---|
430 | <type>log</type> |
---|
431 | <operand>var:dcs</operand> |
---|
432 | </instr> |
---|
433 | </accessor-debug> |
---|
434 | <!-- pop the DC from the list --> |
---|
435 | <instr> |
---|
436 | <type>stm</type> |
---|
437 | <operand>var:cr</operand> |
---|
438 | <operator> |
---|
439 | <stm:group xmlns:stm="http://1060.org/stm"> |
---|
440 | <stm:delete xpath="ref::xpath"> |
---|
441 | <xpath>/cr/dcs/dc[@ref='<stm:param xpath="/string/text()" />']</xpath> |
---|
442 | </stm:delete> |
---|
443 | </stm:group> |
---|
444 | </operator> |
---|
445 | <param>var:dc</param> |
---|
446 | <target>var:cr</target> |
---|
447 | </instr> |
---|
448 | </seq> |
---|
449 | </while> |
---|
450 | <accessor-debug> |
---|
451 | <instr> |
---|
452 | <type>log</type> |
---|
453 | <operand>var:dcs</operand> |
---|
454 | </instr> |
---|
455 | </accessor-debug> |
---|
456 | <!-- create the new DCS with the copies --> |
---|
457 | <instr> |
---|
458 | <type>ISOcat.access.data.dcs.new</type> |
---|
459 | <dcs>var:dcs</dcs> |
---|
460 | <target>var:dcs</target> |
---|
461 | </instr> |
---|
462 | <!-- ask for the full (refreshed) DCS --> |
---|
463 | <instr> |
---|
464 | <type>sloot.xpath2eval</type> |
---|
465 | <operand>var:dcs</operand> |
---|
466 | <operator> |
---|
467 | <xpath>/dcs/@key</xpath> |
---|
468 | </operator> |
---|
469 | <param> |
---|
470 | <return> |
---|
471 | <canonical/> |
---|
472 | <string/> |
---|
473 | </return> |
---|
474 | </param> |
---|
475 | <target>var:dcs</target> |
---|
476 | </instr> |
---|
477 | <accessor-debug> |
---|
478 | <instr> |
---|
479 | <type>sloot.log</type> |
---|
480 | <operator> |
---|
481 | <msg>DCS[{string($dcs)}]</msg> |
---|
482 | </operator> |
---|
483 | <dcs>var:dcs</dcs> |
---|
484 | </instr> |
---|
485 | </accessor-debug> |
---|
486 | <instr> |
---|
487 | <type>ISOcat.access.data.dcs</type> |
---|
488 | <dcs>var:dcs</dcs> |
---|
489 | <target>var:dcs</target> |
---|
490 | </instr> |
---|
491 | <instr> |
---|
492 | <type>sloot.xquery</type> |
---|
493 | <operator> |
---|
494 | <cr> |
---|
495 | {$cr/cr/@*} |
---|
496 | {$cr/cr/(* except dcs)} |
---|
497 | {$dcs} |
---|
498 | </cr> |
---|
499 | </operator> |
---|
500 | <cr>var:cr</cr> |
---|
501 | <dcs>var:dcs</dcs> |
---|
502 | <target>var:cr</target> |
---|
503 | </instr> |
---|
504 | <accessor-debug> |
---|
505 | <instr> |
---|
506 | <type>log</type> |
---|
507 | <operand>var:cr</operand> |
---|
508 | </instr> |
---|
509 | </accessor-debug> |
---|
510 | <!-- create the CR --> |
---|
511 | <instr> |
---|
512 | <type>xslt2</type> |
---|
513 | <operand>var:cr</operand> |
---|
514 | <operator> |
---|
515 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:isocat="http://www.isocat.org/"> |
---|
516 | <xsl:param name="user"/> |
---|
517 | <xsl:param name="name"/> |
---|
518 | <xsl:param name="tdg"/> |
---|
519 | <xsl:template match="text()"/> |
---|
520 | <xsl:template match="/cr[@check='valid']"> |
---|
521 | <batch> |
---|
522 | <!-- create the submission group --> |
---|
523 | <sql> |
---|
524 | INSERT INTO |
---|
525 | core_account |
---|
526 | DEFAULT VALUES |
---|
527 | ; |
---|
528 | </sql> |
---|
529 | <sql> |
---|
530 | INSERT INTO |
---|
531 | core_group |
---|
532 | ( |
---|
533 | id |
---|
534 | ) |
---|
535 | VALUES |
---|
536 | ( |
---|
537 | currval('core_account_id_seq'::regclass) |
---|
538 | ) |
---|
539 | ; |
---|
540 | </sql> |
---|
541 | <xsl:for-each select="group/member"> |
---|
542 | <sql> |
---|
543 | INSERT INTO |
---|
544 | link_group_members |
---|
545 | ( |
---|
546 | "group", |
---|
547 | member, |
---|
548 | role, |
---|
549 | status |
---|
550 | ) |
---|
551 | VALUES |
---|
552 | ( |
---|
553 | currval('core_account_id_seq'::regclass), |
---|
554 | <xsl:value-of select="@ref"/>, |
---|
555 | <xsl:choose> |
---|
556 | <xsl:when test="@ref = /cr/group/@initiator"> |
---|
557 | <xsl:text>'chair'</xsl:text> |
---|
558 | </xsl:when> |
---|
559 | <xsl:otherwise> |
---|
560 | <xsl:text>'member'</xsl:text> |
---|
561 | </xsl:otherwise> |
---|
562 | </xsl:choose>, |
---|
563 | <xsl:text>'accepted'</xsl:text> |
---|
564 | ) |
---|
565 | ; |
---|
566 | </sql> |
---|
567 | </xsl:for-each> |
---|
568 | <sql> |
---|
569 | INSERT INTO |
---|
570 | link_dcs_access |
---|
571 | ( |
---|
572 | dcs, |
---|
573 | account, |
---|
574 | rights, |
---|
575 | propagate |
---|
576 | ) |
---|
577 | VALUES |
---|
578 | ( |
---|
579 | <xsl:value-of select="/cr/dcs/@key"/>, |
---|
580 | currval('core_account_id_seq'::regclass), |
---|
581 | 'r', |
---|
582 | false |
---|
583 | ) |
---|
584 | ; |
---|
585 | </sql> |
---|
586 | <!-- create the change request --> |
---|
587 | <sql> |
---|
588 | INSERT INTO |
---|
589 | core_change_request |
---|
590 | ( |
---|
591 | name, |
---|
592 | tdg, |
---|
593 | submission_group, |
---|
594 | dcs |
---|
595 | ) |
---|
596 | VALUES |
---|
597 | ( |
---|
598 | '<xsl:value-of select="replace($name,"'","\\'")"/>', |
---|
599 | <xsl:value-of select="$tdg"/>, |
---|
600 | currval('core_account_id_seq'::regclass), |
---|
601 | <xsl:value-of select="/cr/dcs/@key"/> |
---|
602 | ) |
---|
603 | ; |
---|
604 | </sql> |
---|
605 | <!-- put the description log entry into generic_text with as owner the change_request and as user the submitter --> |
---|
606 | <xsl:for-each select="/cr/log/entry"> |
---|
607 | <sql> |
---|
608 | INSERT INTO |
---|
609 | generic_text |
---|
610 | ( |
---|
611 | owner, |
---|
612 | owner_type, |
---|
613 | text, |
---|
614 | "user" |
---|
615 | ) |
---|
616 | VALUES |
---|
617 | ( |
---|
618 | currval('core_change_request_id_seq'::regclass), |
---|
619 | 'change request', |
---|
620 | '<xsl:value-of select="replace(.,"'","\\'")"/>', |
---|
621 | <xsl:value-of select="/cr/group/@initiator"/> |
---|
622 | ) |
---|
623 | ; |
---|
624 | </sql> |
---|
625 | </xsl:for-each> |
---|
626 | <!-- create the TDG and DCRB decision groups --> |
---|
627 | <!-- give the decision groups access to the DCS --> |
---|
628 | <!-- - TDG decision group --> |
---|
629 | <sql> |
---|
630 | INSERT INTO |
---|
631 | core_account |
---|
632 | DEFAULT VALUES |
---|
633 | ; |
---|
634 | </sql> |
---|
635 | <sql> |
---|
636 | INSERT INTO |
---|
637 | core_group |
---|
638 | ( |
---|
639 | id |
---|
640 | ) |
---|
641 | VALUES |
---|
642 | ( |
---|
643 | currval('core_account_id_seq'::regclass) |
---|
644 | ) |
---|
645 | ; |
---|
646 | </sql> |
---|
647 | <sql> |
---|
648 | INSERT INTO |
---|
649 | link_group_members |
---|
650 | ( |
---|
651 | "group", |
---|
652 | member, |
---|
653 | role, |
---|
654 | status |
---|
655 | ) |
---|
656 | ( |
---|
657 | SELECT |
---|
658 | currval('core_account_id_seq'::regclass) AS "group", |
---|
659 | member, |
---|
660 | CASE role |
---|
661 | WHEN 'chair' THEN 'chair' |
---|
662 | ELSE 'member' |
---|
663 | END AS role, |
---|
664 | 'accepted' AS status |
---|
665 | FROM |
---|
666 | link_group_members |
---|
667 | WHERE |
---|
668 | "group" = <xsl:value-of select="$tdg"/> |
---|
669 | AND |
---|
670 | status = 'accepted' |
---|
671 | ) |
---|
672 | ; |
---|
673 | </sql> |
---|
674 | <sql> |
---|
675 | UPDATE |
---|
676 | core_change_request |
---|
677 | SET |
---|
678 | decision_group_tdg = currval('core_account_id_seq'::regclass) |
---|
679 | WHERE |
---|
680 | id = currval('core_change_request_id_seq'::regclass) |
---|
681 | ; |
---|
682 | </sql> |
---|
683 | <sql> |
---|
684 | INSERT INTO |
---|
685 | link_dcs_access |
---|
686 | ( |
---|
687 | dcs, |
---|
688 | account, |
---|
689 | rights, |
---|
690 | propagate |
---|
691 | ) |
---|
692 | VALUES |
---|
693 | ( |
---|
694 | <xsl:value-of select="/cr/dcs/@key"/>, |
---|
695 | currval('core_account_id_seq'::regclass), |
---|
696 | 'r', |
---|
697 | false |
---|
698 | ) |
---|
699 | ; |
---|
700 | </sql> |
---|
701 | <!-- - DCRB decision group --> |
---|
702 | <sql> |
---|
703 | INSERT INTO |
---|
704 | core_account |
---|
705 | DEFAULT VALUES |
---|
706 | ; |
---|
707 | </sql> |
---|
708 | <sql> |
---|
709 | INSERT INTO |
---|
710 | core_group |
---|
711 | ( |
---|
712 | id |
---|
713 | ) |
---|
714 | VALUES |
---|
715 | ( |
---|
716 | currval('core_account_id_seq'::regclass) |
---|
717 | ) |
---|
718 | ; |
---|
719 | </sql> |
---|
720 | <sql> |
---|
721 | UPDATE |
---|
722 | core_change_request |
---|
723 | SET |
---|
724 | decision_group_dcrb = currval('core_account_id_seq'::regclass) |
---|
725 | WHERE |
---|
726 | id = currval('core_change_request_id_seq'::regclass) |
---|
727 | ; |
---|
728 | </sql> |
---|
729 | <sql> |
---|
730 | INSERT INTO |
---|
731 | link_dcs_access |
---|
732 | ( |
---|
733 | dcs, |
---|
734 | account, |
---|
735 | rights, |
---|
736 | propagate |
---|
737 | ) |
---|
738 | VALUES |
---|
739 | ( |
---|
740 | <xsl:value-of select="/cr/dcs/@key"/>, |
---|
741 | currval('core_account_id_seq'::regclass), |
---|
742 | 'r', |
---|
743 | false |
---|
744 | ) |
---|
745 | ; |
---|
746 | </sql> |
---|
747 | <!-- give the submission group read access and the decision groups write access to the DCs --> |
---|
748 | <sql> |
---|
749 | INSERT INTO |
---|
750 | link_dc_access |
---|
751 | ( |
---|
752 | dc, |
---|
753 | account, |
---|
754 | rights |
---|
755 | ) |
---|
756 | SELECT |
---|
757 | * |
---|
758 | FROM |
---|
759 | ( |
---|
760 | SELECT |
---|
761 | dc, |
---|
762 | core_change_request.submission_group AS account, |
---|
763 | 'r' AS rights |
---|
764 | FROM |
---|
765 | core_change_request |
---|
766 | JOIN |
---|
767 | view_dcs |
---|
768 | ON |
---|
769 | view_dcs.dcs = core_change_request.dcs |
---|
770 | WHERE |
---|
771 | core_change_request.id = currval('core_change_request_id_seq'::regclass) |
---|
772 | UNION |
---|
773 | SELECT |
---|
774 | dc, |
---|
775 | core_change_request.decision_group_tdg AS account, |
---|
776 | 'ru' AS rights |
---|
777 | FROM |
---|
778 | core_change_request |
---|
779 | JOIN |
---|
780 | view_dcs |
---|
781 | ON |
---|
782 | view_dcs.dcs = core_change_request.dcs |
---|
783 | WHERE |
---|
784 | core_change_request.id = currval('core_change_request_id_seq'::regclass) |
---|
785 | UNION |
---|
786 | SELECT |
---|
787 | dc, |
---|
788 | core_change_request.decision_group_dcrb AS account, |
---|
789 | 'ru' AS rights |
---|
790 | FROM |
---|
791 | core_change_request |
---|
792 | JOIN |
---|
793 | view_dcs |
---|
794 | ON |
---|
795 | view_dcs.dcs = core_change_request.dcs |
---|
796 | WHERE |
---|
797 | core_change_request.id = currval('core_change_request_id_seq'::regclass) |
---|
798 | ) AS ga |
---|
799 | ; |
---|
800 | </sql> |
---|
801 | </batch> |
---|
802 | </xsl:template> |
---|
803 | </xsl:stylesheet> |
---|
804 | </operator> |
---|
805 | <user>var:user</user> |
---|
806 | <name>var:name</name> |
---|
807 | <tdg>var:tdg</tdg> |
---|
808 | <target>var:sql</target> |
---|
809 | </instr> |
---|
810 | <accessor-debug> |
---|
811 | <instr> |
---|
812 | <type>copy</type> |
---|
813 | <operand>var:sql</operand> |
---|
814 | <target>ffcpl:/trace/cr_new.sql.xml</target> |
---|
815 | </instr> |
---|
816 | </accessor-debug> |
---|
817 | <instr> |
---|
818 | <type>sqlBatch</type> |
---|
819 | <operand>var:sql</operand> |
---|
820 | <target>var:result</target> |
---|
821 | </instr> |
---|
822 | <accessor-debug> |
---|
823 | <instr> |
---|
824 | <type>copy</type> |
---|
825 | <operand>var:result</operand> |
---|
826 | <target>ffcpl:/trace/cr_new.result.xml</target> |
---|
827 | </instr> |
---|
828 | </accessor-debug> |
---|
829 | <instr> |
---|
830 | <type>sloot.xquery</type> |
---|
831 | <operator> |
---|
832 | <sql>SELECT id FROM core_change_request WHERE name = '{replace($name,"'","\\'")}';</sql> |
---|
833 | </operator> |
---|
834 | <name>var:name</name> |
---|
835 | <target>var:sql</target> |
---|
836 | </instr> |
---|
837 | <instr> |
---|
838 | <type>sqlQuery</type> |
---|
839 | <operand>var:sql</operand> |
---|
840 | <target>var:id</target> |
---|
841 | </instr> |
---|
842 | <instr> |
---|
843 | <type>sloot.xpath2eval</type> |
---|
844 | <operand>var:id</operand> |
---|
845 | <operator> |
---|
846 | <xpath>(/results/row/id)[1]</xpath> |
---|
847 | </operator> |
---|
848 | <param> |
---|
849 | <return> |
---|
850 | <canonical/> |
---|
851 | <string/> |
---|
852 | </return> |
---|
853 | </param> |
---|
854 | <target>var:id</target> |
---|
855 | </instr> |
---|
856 | <instr> |
---|
857 | <type>ISOcat.access.data.cr</type> |
---|
858 | <cr>var:id</cr> |
---|
859 | <user>var:user</user> |
---|
860 | <target>this:response</target> |
---|
861 | </instr> |
---|
862 | </idoc> |
---|
863 | <exception> |
---|
864 | <debug/> |
---|
865 | <trace>ffcpl:/trace/cr_new.exception.xml</trace> |
---|
866 | <throw/> |
---|
867 | </exception> |
---|
868 | <response> |
---|
869 | <debug>ffcpl:/trace/cr_new.response.xml</debug> |
---|
870 | <mime>application/xml</mime> |
---|
871 | <expire>now</expire> |
---|
872 | </response> |
---|
873 | </accessor> |
---|