source: ISOcat/trunk/mod-ISOcat-access-data/access/user_all.acc @ 2029

Last change on this file since 2029 was 2029, checked in by mwindhouwer, 12 years ago

Initial import of all the *cats, i.e., ISOcat, RELcat and SCHEMAcat.

File size: 5.0 KB
Line 
1<accessor debug="false" deadlock="true" trace="false">
2        <name>ISOcat.access.data.user.all</name>
3        <descr>Get the list of all DCs a specific user has access to.</descr>
4        <param mandatory="true">
5                <name>user</name>
6                <descr>the user</descr>
7                <type canonical="true">string</type>
8        </param>
9<!-- TODO
10        <param>
11                <name>tree</name>
12                <descr>show hierarchical DC relations (false, simple, complex, true)</descr>
13                <type canonical="true">string</type>
14                <source>
15                        <param/>
16                        <nvp/>
17                        <default>
18                                <string>false</string>
19                        </default>
20                </source>
21        </param>
22-->
23        <idoc>
24                <instr>
25                        <type>ISOcat.access.data.user.id</type>
26                        <user>var:user</user>
27                        <target>var:uid</target>
28                </instr>
29                <instr>
30                        <type>sloot.xquery</type>
31                        <operator>
32                                <xquery>
33                                        declare variable $uid as node() external;
34                                       
35                                        &lt;sql>
36                                                SELECT
37                                                        core_data_category.id AS dc,
38                                                        core_data_category.owner AS owner,
39                                                        CASE DC.scope
40                                                                WHEN 1 THEN 'private'
41                                                                WHEN 2 THEN 'shared'
42                                                                WHEN 3 THEN 'public'
43                                                        END AS scope,
44                                                        DC.write AS write
45                                                FROM (
46                                                        SELECT
47                                                           dc,
48                                                           bool_or(write) AS write,
49                                                           min(scope) AS scope
50                                                        FROM (
51                                                           ( -- all public DCs (read access)
52                                                               SELECT DISTINCT
53                                                                   id AS dc,
54                                                                   false AS write,
55                                                                   3 AS scope
56                                                               FROM
57                                                                   core_data_category
58                                                               WHERE
59                                                                   private = false
60                                                           )
61                                                           UNION
62                                                           ( -- all owned DCs (write access)
63                                                               SELECT DISTINCT
64                                                                   core_data_category.id AS dc,
65                                                                   true AS write,
66                                                                   1 AS scope
67                                                               FROM
68                                                                   core_data_category
69                                                               WHERE
70                                                                   core_data_category.owner = {string($uid)}
71                                                           )
72                                                           UNION
73                                                           ( -- shared DCs by the owner
74                                                               SELECT DISTINCT
75                                                                   dc,
76                                                                   CASE view_dc_access.rights
77                                                                       WHEN 'r' THEN false
78                                                                       ELSE true
79                                                                   END AS write,
80                                                                   2 AS scope
81                                                               FROM
82                                                                   view_dc_access
83                                                               WHERE
84                                                                   view_dc_access.account = {string($uid)}
85                                                           )
86                                                           UNION
87                                                           ( -- shared DCs by a non-owner
88                                                                   SELECT DISTINCT
89                                                                       view_dcs_dc.dc,
90                                                                       false AS write,
91                                                                       2 AS scope
92                                                                   FROM
93                                                                       view_dcs_dc
94                                                                   JOIN
95                                                                       view_dcs_access
96                                                                   ON
97                                                                       view_dcs_dc.dcs = view_dcs_access.dcs
98                                                                   WHERE
99                                                                           view_dcs_access.account = {string($uid)}
100                                                           )
101                                                           UNION
102                                                           ( -- all DCs contributed to (write access)
103                                                               SELECT DISTINCT
104                                                                   dc,
105                                                                   true AS write,
106                                                                   2 AS scope
107                                                               FROM
108                                                                   core_submission_group
109                                                               JOIN
110                                                                   link_group_members
111                                                               ON
112                                                                   core_submission_group.id = link_group_members.group
113                                                               WHERE
114                                                                   link_group_members.member = {string($uid)}
115                                                           )
116                                                        ) AS DCs
117                                                        GROUP BY
118                                                           dc
119                                                ) AS DC
120                                                JOIN
121                                                        core_data_category
122                                                ON
123                                                        core_data_category.id = DC.dc
124                                                ;
125                                        &lt;/sql>
126                                </xquery>
127                        </operator>
128                        <uid>var:uid</uid>
129                        <target>var:query</target>
130                </instr>
131                <accessor-debug>
132                        <instr>
133                                <type>copy</type>
134                                <operand>var:query</operand>
135                                <target>ffcpl:/trace/user_all.sql.xml</target>
136                        </instr>
137                </accessor-debug>
138                <instr>
139                        <type>ISOcat.access.data.query</type>
140                        <query>var:query</query>
141                        <target>var:result</target>
142                </instr>
143                <instr>
144                        <type>xslt2</type>
145                        <operand>var:result</operand>
146                        <operator>
147                                <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
148                                        <xsl:param name="user"/>
149
150                                        <xsl:template match="row">
151                                                <dc ref="{dc}" mode="{if (write='true') then ('rw') else ('r')}" scope="{scope}" owner="{owner}"/>
152                                        </xsl:template>
153
154                                        <xsl:template match="results">
155                                                <dcs type="all" key="{$user}">
156                                                        <xsl:apply-templates/>
157                                                </dcs>
158                                        </xsl:template>
159
160                                        <xsl:template match="null|void">
161                                                <dcs/>
162                                        </xsl:template>
163                                </xsl:stylesheet>
164                        </operator>
165                        <user>var:user</user>
166                        <target>this:response</target>
167                </instr>
168                <!-- attach the golden thread of this (implicit) DCS -->
169                <instr>
170                        <type>sloot.xquery</type>
171                        <operator>
172                                <xquery>
173                                        declare variable $uid as node() external;
174                                       
175                                        &lt;string>goldenthread:/user/{string($uid)}/all&lt;/string>
176                                </xquery>
177                        </operator>
178                        <uid>var:uid</uid>
179                        <target>var:thread</target>
180                </instr>
181                <instr>
182                        <type>sloot.attachGoldenThread</type>
183                        <operand>this:response</operand>
184                        <param>var:thread</param>
185                        <target>this:response</target>
186                </instr>
187        </idoc>
188        <exception>
189                <debug/>
190                <trace>ffcpl:/trace/user_all.exception.xml</trace>
191                <throw/>
192        </exception>
193        <response>
194                <debug>ffcpl:/trace/user_all.response.xml</debug>
195                <mime>application/xml</mime>
196        </response>
197</accessor>
198
Note: See TracBrowser for help on using the repository browser.