1 | <accessor debug="true" trace="false"> |
---|
2 | <name>ISOcat.access.data.dc.new</name> |
---|
3 | <descr>Insert a new DC.</descr> |
---|
4 | <param mandatory="true"> |
---|
5 | <name>dc</name> |
---|
6 | <descr>the new DC</descr> |
---|
7 | </param> |
---|
8 | <param mandatory="true"> |
---|
9 | <name>owner</name> |
---|
10 | <descr>the account owning the new DC</descr> |
---|
11 | <type canonical="true">string</type> |
---|
12 | </param> |
---|
13 | <param> |
---|
14 | <name>user</name> |
---|
15 | <descr>the user owning the change description (only used when different then the owner)</descr> |
---|
16 | <type canonical="true">string</type> |
---|
17 | <source> |
---|
18 | <param/> |
---|
19 | <default> |
---|
20 | <string/> |
---|
21 | </default> |
---|
22 | </source> |
---|
23 | </param> |
---|
24 | <param> |
---|
25 | <name>id</name> |
---|
26 | <descr>the id of the new DC</descr> |
---|
27 | <type canonical="true">string</type> |
---|
28 | <source> |
---|
29 | <param/> |
---|
30 | <default> |
---|
31 | <string/> |
---|
32 | </default> |
---|
33 | </source> |
---|
34 | </param> |
---|
35 | <param> |
---|
36 | <name>check</name> |
---|
37 | <descr>check the new DC</descr> |
---|
38 | <type canonical="true">string</type> |
---|
39 | <source> |
---|
40 | <param/> |
---|
41 | <default> |
---|
42 | <string>true</string> |
---|
43 | </default> |
---|
44 | </source> |
---|
45 | </param> |
---|
46 | <param> |
---|
47 | <name>status</name> |
---|
48 | <descr>status of the copy</descr> |
---|
49 | <type canonical="true">string</type> |
---|
50 | <source> |
---|
51 | <param/> |
---|
52 | <default> |
---|
53 | <string/> |
---|
54 | </default> |
---|
55 | </source> |
---|
56 | </param> |
---|
57 | <idoc> |
---|
58 | <!-- |
---|
59 | TODO: validate the new DC content, if we want to do that the schema will have to be very loose, maybe we should just allow everything and throw a BAD REQUEST when no SQL statements are created |
---|
60 | --> |
---|
61 | <!-- |
---|
62 | <instr> |
---|
63 | <type>throw</type> |
---|
64 | <operand> |
---|
65 | <ex> |
---|
66 | <id>ISOcat[BAD REQUEST]</id> |
---|
67 | <message>The new DC is invalid.</message> |
---|
68 | </ex> |
---|
69 | </operand> |
---|
70 | </instr> |
---|
71 | --> |
---|
72 | |
---|
73 | <accessor-trace name="owner"> |
---|
74 | <!-- get the owner id --> |
---|
75 | <instr> |
---|
76 | <type>ISOcat.access.data.owner.id</type> |
---|
77 | <owner>var:owner</owner> |
---|
78 | <target>var:owner</target> |
---|
79 | </instr> |
---|
80 | <accessor-debug> |
---|
81 | <instr> |
---|
82 | <type>copy</type> |
---|
83 | <operand>var:owner</operand> |
---|
84 | <target>ffcpl:/trace/dc_new.owner.xml</target> |
---|
85 | </instr> |
---|
86 | </accessor-debug> |
---|
87 | </accessor-trace> |
---|
88 | |
---|
89 | <accessor-trace name="user"> |
---|
90 | <choose> |
---|
91 | <cond> |
---|
92 | <instr> |
---|
93 | <type>sloot.xpath2eval</type> |
---|
94 | <operand>var:user</operand> |
---|
95 | <operator> |
---|
96 | <xpath>.!=''</xpath> |
---|
97 | </operator> |
---|
98 | <target>this:cond</target> |
---|
99 | </instr> |
---|
100 | </cond> |
---|
101 | <then> |
---|
102 | <instr> |
---|
103 | <type>ISOcat.access.data.user.id</type> |
---|
104 | <user>var:user</user> |
---|
105 | <target>var:user</target> |
---|
106 | </instr> |
---|
107 | </then> |
---|
108 | <else> |
---|
109 | <instr> |
---|
110 | <type>copy</type> |
---|
111 | <operand>var:owner</operand> |
---|
112 | <target>var:user</target> |
---|
113 | </instr> |
---|
114 | </else> |
---|
115 | </choose> |
---|
116 | <accessor-debug> |
---|
117 | <instr> |
---|
118 | <type>copy</type> |
---|
119 | <operand>var:user</operand> |
---|
120 | <target>ffcpl:/trace/dc_new.user.xml</target> |
---|
121 | </instr> |
---|
122 | </accessor-debug> |
---|
123 | </accessor-trace> |
---|
124 | |
---|
125 | <!-- trace the content --> |
---|
126 | <accessor-debug> |
---|
127 | <instr> |
---|
128 | <type>copy</type> |
---|
129 | <operand>var:dc</operand> |
---|
130 | <target>ffcpl:/trace/dc_new.dc.xml</target> |
---|
131 | </instr> |
---|
132 | </accessor-debug> |
---|
133 | |
---|
134 | <accessor-trace name="base"> |
---|
135 | <!-- create a base (empty) DCIF document --> |
---|
136 | <instr> |
---|
137 | <type>copy</type> |
---|
138 | <operand> |
---|
139 | <dcif:dataCategorySelection xmlns:dcif="http://www.isocat.org/ns/dcif" dcif-version="1.0"/> |
---|
140 | </operand> |
---|
141 | <target>var:base</target> |
---|
142 | </instr> |
---|
143 | <accessor-debug> |
---|
144 | <instr> |
---|
145 | <type>copy</type> |
---|
146 | <operand>var:base</operand> |
---|
147 | <target>ffcpl:/trace/dc_new.base.xml</target> |
---|
148 | </instr> |
---|
149 | </accessor-debug> |
---|
150 | </accessor-trace> |
---|
151 | |
---|
152 | <accessor-trace name="diff"> |
---|
153 | <!-- get the diff between the new DC content and the base DCIF document --> |
---|
154 | <instr> |
---|
155 | <type>sloot.xmldiff</type> |
---|
156 | <operand>var:dc</operand> |
---|
157 | <debug>var:accessor-debug</debug> |
---|
158 | <base>var:base</base> |
---|
159 | <target>var:diff</target> |
---|
160 | </instr> |
---|
161 | <accessor-debug> |
---|
162 | <instr> |
---|
163 | <type>copy</type> |
---|
164 | <operand>var:diff</operand> |
---|
165 | <target>ffcpl:/trace/dc_new.diff.xml</target> |
---|
166 | </instr> |
---|
167 | </accessor-debug> |
---|
168 | </accessor-trace> |
---|
169 | |
---|
170 | <accessor-trace name="id"> |
---|
171 | <if> |
---|
172 | <cond> |
---|
173 | <instr> |
---|
174 | <type>sloot.xpath2eval</type> |
---|
175 | <operand>var:id</operand> |
---|
176 | <operator> |
---|
177 | <xpath>.=''</xpath> |
---|
178 | </operator> |
---|
179 | <target>this:cond</target> |
---|
180 | </instr> |
---|
181 | </cond> |
---|
182 | <then> |
---|
183 | <!-- get the id of the new DC --> |
---|
184 | <instr> |
---|
185 | <type>sqlQuery</type> |
---|
186 | <operand> |
---|
187 | <sql> |
---|
188 | SELECT nextval('core_data_category_id_seq'::regclass) AS id; |
---|
189 | </sql> |
---|
190 | </operand> |
---|
191 | <target>var:id</target> |
---|
192 | </instr> |
---|
193 | <instr> |
---|
194 | <type>sloot.xpath2eval</type> |
---|
195 | <operand>var:id</operand> |
---|
196 | <operator> |
---|
197 | <xpath>/results/row/id</xpath> |
---|
198 | </operator> |
---|
199 | <param> |
---|
200 | <return> |
---|
201 | <canonical/> |
---|
202 | <string/> |
---|
203 | </return> |
---|
204 | </param> |
---|
205 | <target>var:id</target> |
---|
206 | </instr> |
---|
207 | </then> |
---|
208 | </if> |
---|
209 | <accessor-debug> |
---|
210 | <instr> |
---|
211 | <type>log</type> |
---|
212 | <operand>var:id</operand> |
---|
213 | </instr> |
---|
214 | </accessor-debug> |
---|
215 | </accessor-trace> |
---|
216 | |
---|
217 | <accessor-trace name="generate-sql"> |
---|
218 | <!-- transform the diff into an SQL script, and execute it --> |
---|
219 | <instr> |
---|
220 | <type>xslt2</type> |
---|
221 | <operand>var:diff</operand> |
---|
222 | <operator>dc_sql.xsl</operator> |
---|
223 | <debug>var:accessor-debug</debug> |
---|
224 | <dcid>var:id</dcid> |
---|
225 | <pid>active:ISOcat.access.system.config.admin.pid</pid> |
---|
226 | <owner>var:owner</owner> |
---|
227 | <user>var:user</user> |
---|
228 | <target>var:sql</target> |
---|
229 | </instr> |
---|
230 | <!-- add the update of the name/type fields --> |
---|
231 | <instr> |
---|
232 | <type>xslt2</type> |
---|
233 | <operand>var:sql</operand> |
---|
234 | <operator> |
---|
235 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> |
---|
236 | <xsl:param name="id"/> |
---|
237 | <xsl:template match="@*|node()"> |
---|
238 | <xsl:copy> |
---|
239 | <xsl:apply-templates select="@*|node()"/> |
---|
240 | </xsl:copy> |
---|
241 | </xsl:template> |
---|
242 | <xsl:template match="/batch"> |
---|
243 | <copy> |
---|
244 | <xsl:apply-templates select="@*|node()"/> |
---|
245 | <sql>UPDATE core_data_category SET name = get_dc_name(id) WHERE id = <xsl:value-of select="$id"/>;</sql> |
---|
246 | <sql>UPDATE core_data_category SET type = get_dc_type(id) WHERE id = <xsl:value-of select="$id"/>;</sql> |
---|
247 | </copy> |
---|
248 | </xsl:template> |
---|
249 | </xsl:stylesheet> |
---|
250 | </operator> |
---|
251 | <id>var:id</id> |
---|
252 | <target>var:sql</target> |
---|
253 | </instr> |
---|
254 | <accessor-debug> |
---|
255 | <instr> |
---|
256 | <type>copy</type> |
---|
257 | <operand>var:sql</operand> |
---|
258 | <target>ffcpl:/trace/dc_new.sql.xml</target> |
---|
259 | </instr> |
---|
260 | </accessor-debug> |
---|
261 | </accessor-trace> |
---|
262 | <accessor-trace name="execute-sql"> |
---|
263 | <instr> |
---|
264 | <type>sqlBatch</type> |
---|
265 | <operand>var:sql</operand> |
---|
266 | <target>var:result</target> |
---|
267 | </instr> |
---|
268 | <accessor-debug> |
---|
269 | <instr> |
---|
270 | <type>copy</type> |
---|
271 | <operand>var:result</operand> |
---|
272 | <target>ffcpl:/trace/dc_new.result.xml</target> |
---|
273 | </instr> |
---|
274 | </accessor-debug> |
---|
275 | </accessor-trace> |
---|
276 | |
---|
277 | <accessor-trace name="dcif"> |
---|
278 | <!-- get the DCIF of the new DC --> |
---|
279 | <instr> |
---|
280 | <type>ISOcat.access.data.dc</type> |
---|
281 | <dc>var:id</dc> |
---|
282 | <target>var:response</target> |
---|
283 | </instr> |
---|
284 | <accessor-debug> |
---|
285 | <instr> |
---|
286 | <type>copy</type> |
---|
287 | <operand>var:response</operand> |
---|
288 | <target>ffcpl:/trace/dc_new.dcif.xml</target> |
---|
289 | </instr> |
---|
290 | </accessor-debug> |
---|
291 | </accessor-trace> |
---|
292 | |
---|
293 | <!-- change and/or log the status --> |
---|
294 | <instr> |
---|
295 | <type>sloot.xpath2eval</type> |
---|
296 | <operand>var:response</operand> |
---|
297 | <operator> |
---|
298 | <xpath>//dcif:dataCategory//dcif:creation/dcif:changeDescription</xpath> |
---|
299 | </operator> |
---|
300 | <param> |
---|
301 | <return> |
---|
302 | <canonical/> |
---|
303 | <string/> |
---|
304 | </return> |
---|
305 | </param> |
---|
306 | <namespace> |
---|
307 | <namespace> |
---|
308 | <entry> |
---|
309 | <prefix>dcif</prefix> |
---|
310 | <uri>http://www.isocat.org/ns/dcif</uri> |
---|
311 | </entry> |
---|
312 | </namespace> |
---|
313 | </namespace> |
---|
314 | <target>var:message</target> |
---|
315 | </instr> |
---|
316 | <accessor-debug> |
---|
317 | <instr> |
---|
318 | <type>sloot.log</type> |
---|
319 | <operator> |
---|
320 | <msg>DBG: status message[{string($message)}]</msg> |
---|
321 | </operator> |
---|
322 | <message>var:message</message> |
---|
323 | </instr> |
---|
324 | </accessor-debug> |
---|
325 | <choose> |
---|
326 | <cond> |
---|
327 | <instr> |
---|
328 | <type>sloot.xpath2eval</type> |
---|
329 | <operand>var:status</operand> |
---|
330 | <operator> |
---|
331 | <xpath>.!=''</xpath> |
---|
332 | </operator> |
---|
333 | <target>this:cond</target> |
---|
334 | </instr> |
---|
335 | </cond> |
---|
336 | <then> |
---|
337 | <instr> |
---|
338 | <type>ISOcat.access.data.dc.status</type> |
---|
339 | <dc>var:id</dc> |
---|
340 | <status>var:status</status> |
---|
341 | <user>var:user</user> |
---|
342 | <message>var:message</message> |
---|
343 | <check> |
---|
344 | <string>false</string> |
---|
345 | </check> |
---|
346 | </instr> |
---|
347 | </then> |
---|
348 | <else> |
---|
349 | <instr> |
---|
350 | <type>sloot.xpath2eval</type> |
---|
351 | <operand>var:response</operand> |
---|
352 | <operator> |
---|
353 | <xpath>//dcif:dataCategory/dcif:administrationInformationSection/dcif:administrationRecord/isocat:administrationStatus</xpath> |
---|
354 | </operator> |
---|
355 | <param> |
---|
356 | <return> |
---|
357 | <canonical/> |
---|
358 | <string/> |
---|
359 | </return> |
---|
360 | </param> |
---|
361 | <namespace> |
---|
362 | <namespace> |
---|
363 | <entry> |
---|
364 | <prefix>dcif</prefix> |
---|
365 | <uri>http://www.isocat.org/ns/dcif</uri> |
---|
366 | </entry> |
---|
367 | <entry> |
---|
368 | <prefix>isocat</prefix> |
---|
369 | <uri>http://www.isocat.org/</uri> |
---|
370 | </entry> |
---|
371 | </namespace> |
---|
372 | </namespace> |
---|
373 | <target>var:administration</target> |
---|
374 | </instr> |
---|
375 | <instr> |
---|
376 | <type>sloot.xpath2eval</type> |
---|
377 | <operand>var:response</operand> |
---|
378 | <operator> |
---|
379 | <xpath>//dcif:dataCategory/dcif:administrationInformationSection/dcif:administrationRecord/dcif:registrationStatus</xpath> |
---|
380 | </operator> |
---|
381 | <param> |
---|
382 | <return> |
---|
383 | <canonical/> |
---|
384 | <string/> |
---|
385 | </return> |
---|
386 | </param> |
---|
387 | <namespace> |
---|
388 | <namespace> |
---|
389 | <entry> |
---|
390 | <prefix>dcif</prefix> |
---|
391 | <uri>http://www.isocat.org/ns/dcif</uri> |
---|
392 | </entry> |
---|
393 | </namespace> |
---|
394 | </namespace> |
---|
395 | <target>var:registration</target> |
---|
396 | </instr> |
---|
397 | <instr> |
---|
398 | <type>ISOcat.access.data.dc.status</type> |
---|
399 | <dc>var:id</dc> |
---|
400 | <administration>var:administration</administration> |
---|
401 | <registration>var:registration</registration> |
---|
402 | <user>var:user</user> |
---|
403 | <message>var:message</message> |
---|
404 | <check> |
---|
405 | <string>false</string> |
---|
406 | </check> |
---|
407 | </instr> |
---|
408 | </else> |
---|
409 | </choose> |
---|
410 | |
---|
411 | <accessor-trace name="touch"> |
---|
412 | <!-- touch the new DC --> |
---|
413 | <instr> |
---|
414 | <type>ISOcat.access.data.dc.touch</type> |
---|
415 | <dc>var:id</dc> |
---|
416 | <check>var:check</check> |
---|
417 | <target>var:void</target> |
---|
418 | </instr> |
---|
419 | </accessor-trace> |
---|
420 | |
---|
421 | <!-- a nice log message --> |
---|
422 | <instr> |
---|
423 | <type>xslt2</type> |
---|
424 | <operand>var:response</operand> |
---|
425 | <operator> |
---|
426 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:dcif="http://www.isocat.org/ns/dcif" xmlns:isocat="http://www.isocat.org/"> |
---|
427 | <xsl:template match="text()"/> |
---|
428 | <xsl:template match="/dcif:dataCategorySelection/dcif:dataCategory"> |
---|
429 | <msg>INF: <xsl:value-of select="current-dateTime()"/>: created DC[<xsl:value-of select="@isocat:id"/>][<xsl:value-of select="@isocat:owner"/>-<xsl:value-of select="dcif:administrationInformationSection/dcif:administrationRecord/dcif:identifier"/>-<xsl:value-of select="dcif:administrationInformationSection/dcif:administrationRecord/dcif:version"/>][<xsl:value-of select="@isocat:name"/>]</msg> |
---|
430 | </xsl:template> |
---|
431 | </xsl:stylesheet> |
---|
432 | </operator> |
---|
433 | <target>var:msg</target> |
---|
434 | </instr> |
---|
435 | <instr> |
---|
436 | <type>sloot.log</type> |
---|
437 | <operand>var:msg</operand> |
---|
438 | </instr> |
---|
439 | |
---|
440 | <instr> |
---|
441 | <type>copy</type> |
---|
442 | <operand>var:response</operand> |
---|
443 | <target>this:response</target> |
---|
444 | </instr> |
---|
445 | </idoc> |
---|
446 | <exception> |
---|
447 | <debug/> |
---|
448 | <trace>ffcpl:/trace/dc_new.exception.xml</trace> |
---|
449 | <throw/> |
---|
450 | </exception> |
---|
451 | <response> |
---|
452 | <mime>application/xml</mime> |
---|
453 | <expire>now</expire> |
---|
454 | </response> |
---|
455 | </accessor> |
---|