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