-
Notifications
You must be signed in to change notification settings - Fork 0
/
toy.html
276 lines (257 loc) · 12.9 KB
/
toy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<html>
<head>
<title></title>
<script src='https://www.w3.org/Tools/respec/respec-w3c-common'
defer class='remove'></script>
<!-- script src='../primer/respec-w3c-common.js' async class='remove'></script -->
<script class='remove'>
var respecConfig = {
github: "https://github.com/shapetrees/test-suite/",
specStatus: "CG-DRAFT",
shortName: "shex-semantics",
editors: [
{ name: "ericP" },
],
wg: "Solid Community Group",
wgURI: "https://www.w3.org/community/solid/",
};
</script>
<style>
body { max-width: inherit !important; }
.comment { color: #ff1500 }
.horizlist span:before { content: "• " }
</style>
</head>
<body>
<section id="sotd"></section>
<section id="abstract"></section>
<section>
<h2>Example</h2>
<img src="toy.svg" alt="ShapeTrees and decorators"/>
<caption><span style="font-weight: bold">Legend</span><br/>
<span style="color:black">🡖</span>: contains<br/>
<span style="color:blue">🡖</span>: referencess<br/>
<span style="color:green">🡖</span>: narrower<br/>
</caption>
</section>
<section>
<h2>Algorithm</h2>
<p>
The <a>generateUI</a> function which takes an <code>eco:Application</code> and language preferences and returns a tuples necessary to construct a UI for e.g. authentication.
</p>
<ul>
<li>function <dfn>generateUI</dfn> (<dfn>app</dfn>:<code>eco:Application</code>, <dfn>langPrefs</dfn>:[xsd:language])
<ul>
<li>return <a>app</a>.<code>hasAccessNeedGroup</code>.map(<dfn>Group</dfn> => {
<ul>
<li><dfn>shapeTreeUrls</dfn> is the transitive set of ShapeTrees referenced by <a>Group</a>.</li>
<li><dfn>shapeTreeDecorators</dfn> is the set of <code>ShapeTreeDecorators</code> mentioned in any <a>shapeTreeUrl</a> document that have a <code>tree:prefLabel</code> with a language tag in <a>langPrefs</a>.</li>
<li><dfn>rootAccessNeeds</dfn> is the set of <code>eco:AccessNeed</code>s refrenced by <a>Group</a>'s <code>eco:requestsAccess</code>.</li>
<li><dfn>overridesAccessNeeds</dfn> is the set of <code>AccessNeed</code>s refrenced by <a>Group</a>'s <code>eco:overridesAccess</code> property.</li>
<li><dfn>mirrorAccessNeeds</dfn> is the set of <a>rootAccessNeeds</a> UNION <a>overridesAccessNeeds</a> with a <code>eco:supports</code> property.</li>
<li><dfn>directAccessNeeds</dfn> is the set of <a>rootAccessNeeds</a> UNION <a>overridesAccessNeeds</a> without a <code>eco:supports</code> property.</li>
<li>for each <dfn>rootAccessNeed</dfn> in <a>rootAccessNeeds</a>
<ul>
<a>setAclsFromAccessNeed</a>(<a>rootAccessNeed</a>.<code>registeredShapeTree</code>, <a>rootAccessNeed</a>, <a>directAccessNeeds</a>, <a>mirrorAccessNeeds</a>, <a>shapeTreeDecorators</a>)
</ul></li>
</ul></li>
</ul>
</li>
</ul>
<p>
The following variables always have the same bindings throughout the recurssive calles to <a>setAclsFromAccessNeed</a>. They may be elided if <a>setAclsFromAccessNeed</a> is lexically scoped within <a>generateUI</a>:
<span class="horizlist">
<span><a>directAccessNeeds</a></span>
<span><a>mirrorAccessNeeds</a></span>
<span><a>shapeTreeDecorators</a></span>
</span>
.
</p>
<ul>
<li>function <dfn>setAclsFromAccessNeed</dfn> (<dfn>shapeTreeUrl</dfn>:URL, <dfn>lastAccessNeed</dfn>:AccessNeed, <a>directAccessNeeds</a>, <a>mirrorAccessNeeds</a>, <a>shapeTreeDecorators</a>)
<ul>
<li><dfn>topDecorator</dfn> is the <code>ShapeTreeDecorator</code> with a <code>tree:hasShapeTree</code> = <a>shapeTreeUrl</a>.</li>
<li>return <dfn>narrowerTree</dfn> = <a>walkDecorators</a>(<a>topDecorator</a>, <a>specificNeed</a>(<a>shapeTreeUrl</a>, <a>lastAccessNeed</a>))</li>
</ul>
</li>
</ul>
<ul>
<li>function <dfn>specificNeed</dfn> (<dfn>specificShapeTreeUrl</dfn>, <dfn>defaultAccessNeed</dfn>)
<ul>
<li>if there is an AccessNeed in <a>directAccessNeeds</a> with a <code>registeredShapeTree</code>==<a>specificShapeTreeUrl</a>, return that AccessNeed</li>
<li>else return <a>defaultAccessNeed</a></li>
</ul>
</li>
</ul>
<ul>
<li>function <dfn>walkDecorators</dfn> (<dfn>decorator</dfn>, <dfn>accessNeed</dfn>:AccessNeed)
<ul>
<li><dfn>shapeTreeNode</dfn> is the ShapeTree at <a>shapeTreeUrl</a>.</li>
<li><dfn>newEntry</dfn> is a tuple of (<a>shapeTreeUrl</a>, <a>decorator</a>, <a>accessNeed</a>, <a>shapeTreeNode</a>).</li>
<li><dfn>applicableMirrors</dfn> is the set of <a>mirrorAccessNeeds</a> with a <code>supports</code> == <a>shapeTreeUrl</a>.</li>
<li>if <a>applicableMirrors</a> is not empty,
<ul>
<li><a>newEntry</a>.<code>mirrors</code> = <a>applicableMirrors</a>.map(
<dfn>need</dfn> => a tuple of (<a>need</a>, the <code>ShapeTreeDecorator</code> with a <code>tree:hasShapeTree</code> == <a>need</a>)
)</li>
</ul></li>
<li>if <a>decorator</a>.<code>narrower</code>,
<ul>
<li><a>newEntry</a>.<code>narrower</code> = <a>decorator</a>.<code>narrower</code>.map(<dfn>narrower</dfn> => <a>walkDecorators</a>(<a>narrower</a>, <a>specificNeed</a>(<a>shapeTreeUrl</a>, <a>lastAccessNeed</a>)) <span class="comment">// e.g {repo}, labels and milestones above</span></li>
</ul>
<li>if <a>resultTree</a>.<code>shapeTreeNode</code>.<code>references</code>
<ul>
<li><a>newEntry</a>.<code>references</code> = <a>followReferences</a>(<a>narrowerTree</a>, <a>directAccessNeeds</a>, <a>mirrorAccessNeeds</a>, <a>shapeTreeDecorators</a>)</li>
</ul></li>
</li>
</ul>
</li>
</ul>
<ul>
<li>function <dfn>followReferences</dfn> (<dfn>resultTree</dfn>, <a>directAccessNeeds</a>, <a>mirrorAccessNeeds</a>, <a>shapeTreeDecorators</a>)
<ul>
<li>for each <dfn>reference</dfn> in <a>resultTree</a>.<code>shapeTreeNode</code>.<code>references</code>
<ul>
<li><a>setAclsFromAccessNeed</a>(<a>reference</a>, <a>specificNeed</a>(<a>reference</a>, <a>resultTree</a>.<code>accessNeed</code>))</li>
</ul></li>
</ul>
</li>
</ul>
<!--
<pre>
function <dfn>generateUI</dfn> (app:URL, langPrefs:[xsd:language])
<span>
app.hasAccessNeedGroup.map(<dfn>Group</dfn> => {
<span>
<dfn>shapeTreeUrls</dfn> is the transitive set of ShapeTrees referenced by <a>Group</a>.
<dfn>shapeTreeDecorators</dfn> is the set of <code>ShapeTreeDecorators</code> mentioned in any <a>shapeTreeUrl</a> document.
<dfn>rootAccessNeeds</dfn> is the set of accessNeeds refrenced by <a>Group</a>'s <code>eco:requestsAccess</code>.
<dfn>mirrorAccessNeeds</dfn> is the set of <code>AccessNeed</code>s in <a>Group</a> with a <code>eco:supports</code> property.
<dfn>directAccessNeeds</dfn> is the set of <code>AccessNeed</code>s in <a>Group</a> without a <code>eco:supports</code> property.
for each <dfn>directAccessNeed</dfn> in <a>directAccessNeeds</a>
<span>
<a>setAclsFromAccessNeed</a>(<a>directAccessNeed</a>.<code>registeredShapeTree</code>, <a>directAccessNeed</a>)
</span>
</span>
</span>
function <dfn>setAclsFromAccessNeed</dfn> (<dfn>shapeTreeUrl</dfn>:URL, <dfn>accessNeed</dfn>:AccessNeed)
<span>
<dfn>decorator</dfn> is the <code>ShapeTreeDecorator</code> with a <code>tree:hasShapeTree</code> = <a>shapeTreeUrl</a>.
<dfn>shapeTreeNode</dfn> is the ShapeTree at <a>shapeTreeUrl</a>.
<dfn>newEntry</dfn> is a tuple of (<a>shapeTreeUrl</a>, <a>decorator</a>, <a>accessNeed</a>, <a>shapeTreeNode</a>).
<dfn>results</dfn> is a list of such tuples, initially populated with <a>newEntry</a>
for each <dfn>narrower</dfn> in a recursive walk of <a>decorator</a>.<code>narrower</code>
<span>
<dfn>narrowerAccessNeed</dfn> is the accessNeed in <a>directAccessNeeds</a> with a <a>narrowerAccessNeed</a>.<code>registeredShapeTree</code>=<a>narrower</a>.<code>hasShapeTree</code>, if it exists, OR <a>accessNeed</a>.
<dfn>narrowerNode</dfn> si the ShapeTree at <a>narrower</a>.<code>hasShapeTree</code>
add a new tuple (<a>narrower</a>.<code>hasShapeTree</code>, <a>narrower</a>, <a>narrowerAccessNeed</a>, <a>narrowerNode</a>)
</span>
for each <dfn>entry</dfn> in <a>results</a>
<span>
for each <dfn>reference</dfn> in <a>entry</a>.<code>shapeTreeNode</code>.<code>references</code>
<span>
<dfn>referenceAccessNeed</dfn> is the accessNeed in <a>directAccessNeeds</a> with a <a>referenceAccessNeed</a>.<code>registeredShapeTree</code>=<a>reference</a>, if it exists, OR <a>accessNeed</a>.
<a>setAclsFromAccessNeed</a>(<a>reference</a>, <a>referenceAccessNeed</a>)
</span>
</span>
</span>
</pre>
-->
</section>
<section>
<h2>Delayed evaluation</h2>
<pre class="turtle"><caption>CarePlan ShapeTree</caption><code>
<#carePlan>
tree:validatedBy <medrecord-schema#carePlan> ;
tree:matchesUriTemplate "{id}" ;
tree:expectsType <http://www.w3.org/ns/ldp#Resource> ;
[
tree:treeStep <#patient> ;
tree:shapePath "<@medrecord-schema#carePlan>/medrecord:patient"
] ,
[
tree:treeStep <#appointment> ;
tree:shapePath "<@medrecord-schema#carePlanShape>/medrecord:appointment"
] .
<#patient>
tree:validatedBy <medrecord-schema#patient> ;
tree:matchesUriTemplate "{id}" .
<#appointment>
tree:validatedBy <medrecord-schema#appointmentShape> ;
tree:matchesUriTemplate "{id}" ;
tree:expectsType <http://www.w3.org/ns/ldp#Resource> ;
[
tree:treeStep <#diagnosticTest> ;
tree:shapePath "@<medrecord-schema#complaintShape>/medrecord:diagnosticTest"
] .
<#diagnosticTest>
tree:validatedBy <medrecord-schema#diagnosticTestShape> ;
tree:matchesUriTemplate "{id}" ;
tree:expectsType <http://www.w3.org/ns/ldp#Resource> ;
[
tree:treeStep <#condition> ;
tree:shapePath "@<medrecord-schema#diagnosticTestShape>/medrecord:condition"
] .
<#condition>
tree:validatedBy <medrecord-schema#conditionShape> ;
tree:matchesUriTemplate "{id}" ;
tree:expectsType <http://www.w3.org/ns/ldp#Resource> ;
[
tree:treeStep <#prescription> ;
tree:shapePath "@<medrecord-schema#remedialStepShape>/medrecord:prescription"
] .
<#prescription>
tree:validatedBy <medrecord-schema#prescriptionShape> ;
tree:matchesUriTemplate "{id}" ;
tree:expectsType <http://www.w3.org/ns/ldp#Resource> ;
[
tree:treeStep <#allergy> ;
tree:shapePath "@<medrecord-schema#watchOutForShape>/medrecord:medication"
] .
<#medication>
tree:validatedBy <medrecord-schema#medicationShape> ;
tree:matchesUriTemplate "{id}" ;
tree:expectsType <http://www.w3.org/ns/ldp#Resource> .
</code></pre>
<h3>Initial (empty) care plan</h3>
<pre class="turtle"><code>
<#carePlan1> :patient <#patient2> ;
:clinic <#clinic3> .
<#patient2> foaf:name "Alice" .
# index graph +=
<#carePlan1> :patient <#patient2> .
</code></pre>
<h3>add an appointment</h3>
<pre class="turtle"><code>
<#appointment4> :complaint <#complaint5> .
<#complaint5> rdfs:label "hysteria" .
,
<#carePlan1> :appointment <#appointment4> .
.
# index graph +=
<#carePlan1> :appointment <#appointment4> .
<#appointment4> :complaint <#complaint5> . # exhaustive path to #complaintShape
</code></pre>
<h3>fulfill appointment</h3>
<pre class="turtle"><code>
<#complaint5> :diagnosticTest <#diagnosticTest6> ;
<#diagnosticTest6> a :QuackProcedure ;
:condition <#condition7>
<#condition7> a :LifeSentence ;
:prescription <#prescription8> .
<#prescription8> a :Prescription ;
:tid "twice daily" ;
:medication <#gin> .
<#gin> a :Remedy .
# index graph +=
<#complaint5> :diagnosticTest <#diagnosticTest6> ;
<#diagnosticTest6> :condition <#condition7>
<#condition7> :prescription <#prescription8> .
<#prescription8> :medication <#gin> .
</code></pre>
<p>
can now follow paths through and give access to all of those items.
</p>
</section>
</body>
</html>