1 | <accessor debug="false"> |
---|
2 | <name>ISOcat.access.data.dcs.update</name> |
---|
3 | <descr>Update an existing DCS.</descr> |
---|
4 | <param mandatory="true"> |
---|
5 | <name>id</name> |
---|
6 | <descr>the DCS id</descr> |
---|
7 | <type canonical="true">string</type> |
---|
8 | </param> |
---|
9 | <param mandatory="true"> |
---|
10 | <name>dcs</name> |
---|
11 | <descr>the DCS update</descr> |
---|
12 | </param> |
---|
13 | <idoc> |
---|
14 | <!-- validate the new DCS content --> |
---|
15 | <instr> |
---|
16 | <type>validateRNG</type> |
---|
17 | <operand>var:dcs</operand> |
---|
18 | <operator>active:ISOcat.access.data.dcs.schema</operator> |
---|
19 | <target>var:valid</target> |
---|
20 | </instr> |
---|
21 | <if> |
---|
22 | <cond> |
---|
23 | <instr> |
---|
24 | <type>copy</type> |
---|
25 | <operand>var:valid</operand> |
---|
26 | <target>this:cond</target> |
---|
27 | </instr> |
---|
28 | </cond> |
---|
29 | <then> |
---|
30 | <instr> |
---|
31 | <type>sloot.xquery</type> |
---|
32 | <operator> |
---|
33 | <xquery> |
---|
34 | declare variable $dcs as node() external; |
---|
35 | |
---|
36 | <sql> |
---|
37 | DELETE FROM |
---|
38 | core_selected_data_category |
---|
39 | WHERE |
---|
40 | dcs = {string($dcs)} |
---|
41 | ; |
---|
42 | </sql> |
---|
43 | </xquery> |
---|
44 | </operator> |
---|
45 | <dcs>var:id</dcs> |
---|
46 | <target>var:sql</target> |
---|
47 | </instr> |
---|
48 | <accessor-debug> |
---|
49 | <instr> |
---|
50 | <type>copy</type> |
---|
51 | <operand>var:sql</operand> |
---|
52 | <target>ffcpl:/trace/dcs_update.delete.sql.xml</target> |
---|
53 | </instr> |
---|
54 | </accessor-debug> |
---|
55 | <instr> |
---|
56 | <type>isocat.sqlUpdate</type> |
---|
57 | <operand>var:sql</operand> |
---|
58 | <target>var:result</target> |
---|
59 | </instr> |
---|
60 | <instr> |
---|
61 | <type>xslt2</type> |
---|
62 | <operand>var:dcs</operand> |
---|
63 | <operator> |
---|
64 | <xsl:stylesheet |
---|
65 | version="2.0" |
---|
66 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
67 | > |
---|
68 | <xsl:param name="id"/> |
---|
69 | |
---|
70 | <xsl:template match="/dcs"> |
---|
71 | <batch> |
---|
72 | <xsl:apply-templates/> |
---|
73 | </batch> |
---|
74 | </xsl:template> |
---|
75 | |
---|
76 | <xsl:template match="dc"> |
---|
77 | <sql> |
---|
78 | INSERT INTO |
---|
79 | core_selected_data_category |
---|
80 | ( |
---|
81 | dcs |
---|
82 | ) |
---|
83 | VALUES |
---|
84 | ( |
---|
85 | <xsl:value-of select="$id"/> |
---|
86 | ) |
---|
87 | ; |
---|
88 | </sql> |
---|
89 | <sql> |
---|
90 | INSERT INTO |
---|
91 | core_selected_<xsl:value-of select="if (@type = ('simple','container')) then (@type) else ('complex')"/>_data_category |
---|
92 | ( |
---|
93 | id, |
---|
94 | dc |
---|
95 | ) |
---|
96 | VALUES |
---|
97 | ( |
---|
98 | currval('core_selected_data_category_id_seq'::regclass), |
---|
99 | <xsl:value-of select="@ref"/> |
---|
100 | ) |
---|
101 | ; |
---|
102 | </sql> |
---|
103 | </xsl:template> |
---|
104 | </xsl:stylesheet> |
---|
105 | </operator> |
---|
106 | <id>var:id</id> |
---|
107 | <target>var:sql</target> |
---|
108 | </instr> |
---|
109 | <accessor-debug> |
---|
110 | <instr> |
---|
111 | <type>copy</type> |
---|
112 | <operand>var:sql</operand> |
---|
113 | <target>ffcpl:/trace/dcs_update.insert.sql.xml</target> |
---|
114 | </instr> |
---|
115 | </accessor-debug> |
---|
116 | <instr> |
---|
117 | <type>isocat.sqlBatch</type> |
---|
118 | <operand>var:sql</operand> |
---|
119 | <target>var:result</target> |
---|
120 | </instr> |
---|
121 | <accessor-debug> |
---|
122 | <instr> |
---|
123 | <type>copy</type> |
---|
124 | <operand>var:result</operand> |
---|
125 | <target>ffcpl:/trace/dcs_update.result.xml</target> |
---|
126 | </instr> |
---|
127 | </accessor-debug> |
---|
128 | <!-- create short response document --> |
---|
129 | <instr> |
---|
130 | <type>xslt2</type> |
---|
131 | <operand>var:dcs</operand> |
---|
132 | <operator> |
---|
133 | <xsl:stylesheet |
---|
134 | version="2.0" |
---|
135 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
136 | > |
---|
137 | <xsl:template match="/dcs"> |
---|
138 | <xsl:copy> |
---|
139 | <xsl:copy-of select="@*"/> |
---|
140 | </xsl:copy> |
---|
141 | </xsl:template> |
---|
142 | </xsl:stylesheet> |
---|
143 | </operator> |
---|
144 | <target>this:response</target> |
---|
145 | </instr> |
---|
146 | <instr> |
---|
147 | <type>xslt2</type> |
---|
148 | <operand>this:response</operand> |
---|
149 | <operator> |
---|
150 | <xsl:stylesheet |
---|
151 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
152 | version="2.0" |
---|
153 | > |
---|
154 | <xsl:template match="/dcs"> |
---|
155 | <msg>INF: <xsl:value-of select="current-dateTime()"/>: update DCS[<xsl:value-of select="@key"/>][<xsl:value-of select="@name"/> owned by <xsl:value-of select="@owner"/>]</msg> |
---|
156 | </xsl:template> |
---|
157 | </xsl:stylesheet> |
---|
158 | </operator> |
---|
159 | <target>var:msg</target> |
---|
160 | </instr> |
---|
161 | <instr> |
---|
162 | <type>sloot.log</type> |
---|
163 | <operand>var:msg</operand> |
---|
164 | </instr> |
---|
165 | <!-- touch the updated DCS --> |
---|
166 | <instr> |
---|
167 | <type>ISOcat.access.data.dcs.touch</type> |
---|
168 | <dcs>var:id</dcs> |
---|
169 | <target>var:void</target> |
---|
170 | </instr> |
---|
171 | <!-- hug the context of this DCS --> |
---|
172 | <instr> |
---|
173 | <type>ISOcat.access.data.dcs.hug</type> |
---|
174 | <dcs>var:id</dcs> |
---|
175 | <target>var:void</target> |
---|
176 | </instr> |
---|
177 | </then> |
---|
178 | <else> |
---|
179 | <instr> |
---|
180 | <type>copy</type> |
---|
181 | <operand>var:content</operand> |
---|
182 | <target>ffcpl:/trace/dcs_update.content.xml</target> |
---|
183 | </instr> |
---|
184 | <instr> |
---|
185 | <type>copy</type> |
---|
186 | <operand>var:valid</operand> |
---|
187 | <target>ffcpl:/trace/dcs_update.content.invalid.xml</target> |
---|
188 | </instr> |
---|
189 | <instr> |
---|
190 | <type>throw</type> |
---|
191 | <operand> |
---|
192 | <ex> |
---|
193 | <id>ISOcat[BAD REQUEST]</id> |
---|
194 | <message>The DCS update is invalid.</message> |
---|
195 | </ex> |
---|
196 | </operand> |
---|
197 | </instr> |
---|
198 | </else> |
---|
199 | </if> |
---|
200 | </idoc> |
---|
201 | <exception> |
---|
202 | <debug/> |
---|
203 | <trace>ffcpl:/trace/dcs_update.exception.xml</trace> |
---|
204 | <throw/> |
---|
205 | </exception> |
---|
206 | <response> |
---|
207 | <mime>application/xml</mime> |
---|
208 | <expire>now</expire> |
---|
209 | </response> |
---|
210 | </accessor> |
---|