1 | <accessor debug="false" deadlock="true" trace="false"> |
---|
2 | <name>ISOcat.access.data.user.view</name> |
---|
3 | <descr>Get the list of all DCs a specific user has access to in a specific view.</descr> |
---|
4 | <param mandatory="true"> |
---|
5 | <name>user</name> |
---|
6 | <descr>the user</descr> |
---|
7 | <type canonical="true">string</type> |
---|
8 | </param> |
---|
9 | <param> |
---|
10 | <name>view</name> |
---|
11 | <descr>return only data categories in this view</descr> |
---|
12 | <type canonical="true">string</type> |
---|
13 | <source> |
---|
14 | <param/> |
---|
15 | <default> |
---|
16 | <string>isocat</string> |
---|
17 | </default> |
---|
18 | </source> |
---|
19 | </param> |
---|
20 | <idoc> |
---|
21 | <instr> |
---|
22 | <type>ISOcat.access.data.user.id</type> |
---|
23 | <user>var:user</user> |
---|
24 | <target>var:uid</target> |
---|
25 | </instr> |
---|
26 | <accessor-debug> |
---|
27 | <instr> |
---|
28 | <type>sloot.log</type> |
---|
29 | <operator> |
---|
30 | <dbg>DBG: view[{string($view)}]</dbg> |
---|
31 | </operator> |
---|
32 | <view>var:view</view> |
---|
33 | </instr> |
---|
34 | </accessor-debug> |
---|
35 | <instr> |
---|
36 | <type>ISOcat.access.data.user.all</type> |
---|
37 | <user>var:user</user> |
---|
38 | <target>var:all</target> |
---|
39 | </instr> |
---|
40 | <choose> |
---|
41 | <cond> |
---|
42 | <instr> |
---|
43 | <type>sloot.xpath2eval</type> |
---|
44 | <operand>var:view</operand> |
---|
45 | <operator> |
---|
46 | <xpath>.='isocat'</xpath> |
---|
47 | </operator> |
---|
48 | <target>this:cond</target> |
---|
49 | </instr> |
---|
50 | </cond> |
---|
51 | <then> |
---|
52 | <instr> |
---|
53 | <type>copy</type> |
---|
54 | <operand>var:all</operand> |
---|
55 | <target>this:response</target> |
---|
56 | </instr> |
---|
57 | </then> |
---|
58 | <else> |
---|
59 | <instr> |
---|
60 | <type>sloot.xquery</type> |
---|
61 | <operator> |
---|
62 | <sql> |
---|
63 | ( |
---|
64 | -- DCs from the group's DCSs |
---|
65 | SELECT DISTINCT |
---|
66 | view_dcs.dc |
---|
67 | FROM |
---|
68 | view_dcs |
---|
69 | JOIN |
---|
70 | link_dcs_access |
---|
71 | ON |
---|
72 | link_dcs_access.dcs = view_dcs.dcs |
---|
73 | JOIN |
---|
74 | ( |
---|
75 | ( |
---|
76 | SELECT |
---|
77 | id, name |
---|
78 | FROM |
---|
79 | core_adhoc_group |
---|
80 | ) |
---|
81 | UNION |
---|
82 | ( |
---|
83 | SELECT |
---|
84 | id, name |
---|
85 | FROM |
---|
86 | core_thematic_domain_group |
---|
87 | ) |
---|
88 | ) AS grp |
---|
89 | ON |
---|
90 | link_dcs_access.account = grp.id |
---|
91 | WHERE |
---|
92 | grp.name = '{replace($view,'''','''''')}' |
---|
93 | ) |
---|
94 | UNION |
---|
95 | ( |
---|
96 | -- if the view refers to a TDG we also need to include the DCs in the TDG's profiles |
---|
97 | SELECT DISTINCT |
---|
98 | view_profile.dc |
---|
99 | FROM |
---|
100 | view_profile |
---|
101 | JOIN |
---|
102 | core_profile |
---|
103 | ON |
---|
104 | view_profile.profile = core_profile.id |
---|
105 | JOIN |
---|
106 | core_thematic_domain_group |
---|
107 | ON |
---|
108 | core_profile.tdg = core_thematic_domain_group.id |
---|
109 | WHERE |
---|
110 | core_thematic_domain_group.name = '{replace($view,'''','''''')}' |
---|
111 | ) |
---|
112 | ; |
---|
113 | </sql> |
---|
114 | </operator> |
---|
115 | <view>var:view</view> |
---|
116 | <target>var:query</target> |
---|
117 | </instr> |
---|
118 | <accessor-debug> |
---|
119 | <instr> |
---|
120 | <type>copy</type> |
---|
121 | <operand>var:query</operand> |
---|
122 | <target>ffcpl:/trace/user_view.sql.xml</target> |
---|
123 | </instr> |
---|
124 | </accessor-debug> |
---|
125 | <instr> |
---|
126 | <type>ISOcat.access.data.query</type> |
---|
127 | <query>var:query</query> |
---|
128 | <target>var:result</target> |
---|
129 | </instr> |
---|
130 | <accessor-debug> |
---|
131 | <instr> |
---|
132 | <type>copy</type> |
---|
133 | <operand>var:result</operand> |
---|
134 | <target>ffcpl:/trace/user_view.sql.result.xml</target> |
---|
135 | </instr> |
---|
136 | </accessor-debug> |
---|
137 | <instr> |
---|
138 | <type>xslt2</type> |
---|
139 | <operand>var:all</operand> |
---|
140 | <operator> |
---|
141 | <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
---|
142 | |
---|
143 | <xsl:param name="view"/> |
---|
144 | <xsl:param name="dcs"/> |
---|
145 | |
---|
146 | <xsl:key name="dc" match="dc" use="@ref"/> |
---|
147 | |
---|
148 | <xsl:template match="dc"> |
---|
149 | <!-- private and shared DCs --> |
---|
150 | <xsl:copy-of select="."/> |
---|
151 | </xsl:template> |
---|
152 | |
---|
153 | <xsl:template match="dc[@scope='public']"> |
---|
154 | <xsl:choose> |
---|
155 | <xsl:when test="contains(@mode,'w')"> |
---|
156 | <!-- public and shared --> |
---|
157 | <xsl:copy-of select="."/> |
---|
158 | </xsl:when> |
---|
159 | <xsl:when test="exists($dcs//row[dc=current()/@ref])"> |
---|
160 | <!-- public and in view --> |
---|
161 | <xsl:copy-of select="."/> |
---|
162 | </xsl:when> |
---|
163 | <!-- skip: only public and not in view --> |
---|
164 | </xsl:choose> |
---|
165 | </xsl:template> |
---|
166 | |
---|
167 | <xsl:template match="dcs"> |
---|
168 | <dcs type="view" key="{$view}"> |
---|
169 | <xsl:apply-templates/> |
---|
170 | </dcs> |
---|
171 | </xsl:template> |
---|
172 | |
---|
173 | <xsl:template match="null|void"> |
---|
174 | <dcs/> |
---|
175 | </xsl:template> |
---|
176 | |
---|
177 | </xsl:stylesheet> |
---|
178 | </operator> |
---|
179 | <view>var:view</view> |
---|
180 | <dcs>var:result</dcs> |
---|
181 | <target>this:response</target> |
---|
182 | </instr> |
---|
183 | <accessor-debug> |
---|
184 | <instr> |
---|
185 | <type>copy</type> |
---|
186 | <operand>this:response</operand> |
---|
187 | <target>ffcpl:/trace/user_view.dcs.result.xml</target> |
---|
188 | </instr> |
---|
189 | </accessor-debug> |
---|
190 | <!-- attach the golden thread of this (implicit) DCS --> |
---|
191 | <instr> |
---|
192 | <type>sloot.xquery</type> |
---|
193 | <operator> |
---|
194 | <string>goldenthread:/user/{string($uid)}/view/{string($view)}</string> |
---|
195 | </operator> |
---|
196 | <uid>var:uid</uid> |
---|
197 | <view>var:view</view> |
---|
198 | <target>var:thread</target> |
---|
199 | </instr> |
---|
200 | <instr> |
---|
201 | <type>sloot.attachGoldenThread</type> |
---|
202 | <operand>this:response</operand> |
---|
203 | <param>var:thread</param> |
---|
204 | <target>this:response</target> |
---|
205 | </instr> |
---|
206 | </else> |
---|
207 | </choose> |
---|
208 | </idoc> |
---|
209 | <exception> |
---|
210 | <debug/> |
---|
211 | <trace>ffcpl:/trace/user_view.exception.xml</trace> |
---|
212 | <throw/> |
---|
213 | </exception> |
---|
214 | <response> |
---|
215 | <debug>ffcpl:/trace/user_view.response.xml</debug> |
---|
216 | <mime>application/xml</mime> |
---|
217 | </response> |
---|
218 | </accessor> |
---|
219 | |
---|