Coverage report: /development/source/library/org/datagraph/spocq-shard/src/spocq-server/automation.lisp

KindCoveredAll%
expression0141 0.0
branch08 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: org.datagraph.spocq.implementation; -*-
2
 
3
 (in-package :org.datagraph.spocq.implementation)
4
 
5
 (:documentation "This file defines an activity model for the 'org.datagraph.spocq' RDF engine."
6
 
7
  (copyright
8
   "Copyright 2021 [james anderson](mailto:james.anderson@setf.de).")
9
 
10
  (long-description
11
  "Each account can include an activity repository.
12
   This stores a model of the proceses active in the repository as a replicable graph.
13
   Each activity is a resource which is represented by a its individual graph.
14
   Each rsource is autonomous, which means there are no parent/child relations, just
15
   cross-references.
16
 
17
   The repository is replicable, which permits multiple simultaneous clients to share its state.
18
   Each client works through an interactive presentation in its own web front end to create, manipulate
19
   and view the activities, and to define the activities input sources and output destinations.
20
 
21
   The activity schema is
22
 
23
   Activity
24
     identity (uuid)
25
     input (iri)
26
     output (iri)
27
     class (string | iri ?)
28
     specification (string)
29
     step -> Activity                           
30
 
31
   The input and output resources are either isolated files or remote http resources.
32
   Neither interprocessing nor internal memory streams are used in order that the
33
   steps are un-coupled.
34
   Their only relation is through their inputs/outputs.
35
 
36
   The client presentation is as an activity field.
37
   This is a geometric plane on which each activity occupies one location.
38
   "))
39
 
40
 (in-package :spocq.si)
41
 
42
 (defmethod graph-store-response :post ((resource |/:account/:repository/sparql|) request response
43
                                        (request-type mime:application/json) ;; allows mime:application/ld+json
44
                                        (response-type mime:application/sparql-query))
45
   ;; given a json-ld context, derive a query which satisfies it.
46
   ;; if a context is present, use that to establish the attributes
47
   ;; otherwise, expect an array of iri strings
48
   (let* ((content (spocq.i::parse-json (http:request-body request)))
49
          (iri-attributes (if (arrayp content)
50
                              (loop for iri across content
51
                                collect (cons (intern-iri iri) (spocq.i::iri-local-part iri)))
52
                              (loop with @context = (spocq.i::json-member-value content "@context")
53
                                with context = (json-ld:make-context @context)
54
                                for (name . value) in @context
55
                                unless (eql (char name 0) #\@)     ;; skip the meta-attributes
56
                                collect (cons (json-ld:term-definition-term (json-ld:find-term-definition context name))
57
                                              name))))
58
          (where-form (graph-store-compute-where (repository (resource-repository resource))
59
                                                 iri-attributes)))
60
     `(spocq.a:|select| ,where-form
61
               ,(loop for (nil . name) in iri-attributes
62
                  collect (spocq.i::make-variable name)))))
63
 
64
 (defmethod graph-store-response :post ((resource |/:account/:repository/sparql|) request response
65
                                        (request-type mime:application/json)
66
                                        (response-type mime:application/json))  ;; also covers sparql results
67
   (flet ((integer-arg (name default)
68
            (let ((arg (http:request-query-argument request name)))
69
              (if arg
70
                  (handler-case (parse-integer arg)
71
                    (error (c) (http:bad-request (format nil "invalid ~a: ~a" name c))))
72
                  default))))
73
   (let* ((content (spocq.i::parse-json (http:request-body request)))
74
          (iri-attributes (if (arrayp content)
75
                              (loop for iri across content
76
                                collect (cons (intern-iri iri) (spocq.i::iri-local-part iri)))
77
                              (loop with @context = (spocq.i::json-member-value content "@context")
78
                                with context = (json-ld:make-context @context)
79
                                for (name . value) in @context
80
                                unless (eql (char name 0) #\@)     ;; skip the meta-attributes
81
                                collect (cons (json-ld:term-definition-term (json-ld:find-term-definition context name))
82
                                              name))))
83
          (where-form (graph-store-compute-where (repository (resource-repository resource))
84
                                                 iri-attributes))
85
          (limit (integer-arg "limit" 32))
86
          (offset (integer-arg "offset" 0))
87
          (query `(spocq.a:|select| (spocq.a:|slice| ,where-form :count ,limit :offset ,offset)
88
                           ,(loop for (nil . name) in iri-attributes
89
                              collect (spocq.i::make-variable name)))))
90
     ;; render it as a string to fit it into the standard request pipeline
91
     (graph-store-query resource
92
                        (format nil "~/format-sparql/" query)
93
                        request response mime:application/sparql-query response-type))))
94
 
95
 
96
 (defgeneric graph-store-compute-where (repository attributes)
97
   (:method ((repository string) (attributes list))
98
     (graph-store-compute-where (repository repository) attributes))
99
   (:method ((repository repository) (attributes list))
100
     ;;(prototype (spocq.i::json-member-value content "@graph"))
101
     (let* ((iri-attributes (loop for name in attributes
102
                              collect (etypecase name
103
                                        (cons name)
104
                                        (string (cons (intern-iri name) (spocq.i::iri-local-part name)))
105
                                        (iri (cons name (spocq.i::iri-local-part name))))))
106
            (paths (spocq.i::repository-pattern-paths repository))
107
            (patterns (remove-if #'spocq.i::pattern-subclasses (spocq.i::repository-pattern-classes repository)))
108
            (pattern-sets (spocq.i::compute-covering-pattern-sets patterns paths (mapcar #'first iri-attributes))))
109
       #+(or)
110
       (if pattern-sets
111
           `(spocq.a:|select| ,(spocq.i::compute-pattern-expression pattern-sets iri-attributes) ())
112
           '(spocq.a:|select| (spocq.a:|table| spocq.a:|unit|) ()))
113
       (if pattern-sets
114
           (spocq.i::compute-pattern-expression pattern-sets iri-attributes)
115
           '(spocq.a:|table| spocq.a:|unit|)))))
116
 
117
 
118
 #+(or)
119
 (progn
120
   (in-package :spocq.i)
121
   (initialize-spocq)
122
   (compute-instance-model (repository "saam-mirror/saam") mime:application/json)
123
   (compute-instance-model (repository "saam-mirror/saam") mime:image/vnd.dydra.sparql-results+circos+svg+xml)
124
 
125
   (length (spocq.i::repository-pattern-classes (repository "saam-mirror/saam")))
126
   (length (remove-if #'pattern-subclasses (spocq.i::repository-pattern-classes (repository "saam-mirror/saam"))))
127
 (spocq.i::print-sparql
128
 (spocq.si::graph-store-compute-where "saam-mirror/saam"
129
                            '(<http://edan.si.edu/saam/id/ontologies/PE_lastname>
130
                              <http://edan.si.edu/saam/id/ontologies/PE_firstname>
131
                              <http://www.cidoc-crm.org/cidoc-crm/P69_is_associated_with>)))
132
 
133
 (spocq.i::print-sparql
134
 (spocq.si::graph-store-compute-where "saam-mirror/saam"
135
                            '(<http://edan.si.edu/saam/id/ontologies/PE_lastname>
136
                              <http://edan.si.edu/saam/id/ontologies/PE_firstname>
137
                              <http://edan.si.edu/saam/id/ontologies/PE_has_note_primaryartistbio>)))
138
 
139
 
140
 
141
 (spocq.si::graph-store-compute-where "saam-mirror/saam"
142
                            '(<http://edan.si.edu/saam/id/ontologies/PE_lastname>
143
                              <http://edan.si.edu/saam/id/ontologies/PE_firstname>))
144
 
145
 (print-sparql *)
146
 
147
 (test-sparql "
148
 SELECT count(*)
149
  WHERE { { { ?pattern1932 <http://edan.si.edu/saam/id/ontologies/PE_lastname> ?PE_lastname .
150
              ?pattern1932 <http://edan.si.edu/saam/id/ontologies/PE_firstname> ?PE_firstname }
151
            { #?pattern1935 <http://edan.si.edu/saam/id/ontologies/PE_has_note_primaryartistbio> ?PE_has_note_primaryartistbio .
152
             # ?pattern1935 <http://www.cidoc-crm.org/cidoc-crm/P48_has_preferred_identifier> ?pattern1932 .
153
              ?pattern1935 <http://www.cidoc-crm.org/cidoc-crm/P1_is_identified_by> ?pattern1932 
154
            } }}
155
 " :repository-id "saam-mirror/saam")
156
 
157
 (test-sparql "
158
 SELECT count(*)
159
  WHERE { ?pattern1935 <http://www.cidoc-crm.org/cidoc-crm/P48_has_preferred_identifier> ?pattern1932 }
160
 " :repository-id "saam-mirror/saam")
161
 
162
 (test-sparql "
163
 SELECT distinct ?p
164
  WHERE { ?pattern1932 ?p ?o .
165
          ?pattern1935 <http://www.cidoc-crm.org/cidoc-crm/P48_has_preferred_identifier> ?pattern1932 }
166
 " :repository-id "saam-mirror/saam")
167
 ;; yields neither of the intended properties !?
168
 ((|http://www.w3.org/1999/02/22-rdf-syntax-ns#|:|type|)
169
  (|http://www.w3.org/2000/01/rdf-schema#|:|label|))
170
 (?::|p|)
171
 
172
 (test-sparql "
173
 SELECT distinct ?o
174
  WHERE { ?pattern1932 a ?o .
175
          ?pattern1935 <http://www.cidoc-crm.org/cidoc-crm/P48_has_preferred_identifier> ?pattern1932 }
176
 " :repository-id "saam-mirror/saam")
177
 
178
 (find <http://www.cidoc-crm.org/cidoc-crm/P48_has_preferred_identifier> (repository-pattern-paths (repository "saam-mirror/saam"))
179
       :key #'pattern-path-object-predicate)
180
 
181
 (find <http://www.cidoc-crm.org/cidoc-crm/P1_is_identified_by> (repository-pattern-paths (repository "saam-mirror/saam"))
182
       :key #'pattern-path-object-predicate)
183
 
184
 #|
185
 # content type requires authentication for a post
186
 curl -X POST https://de17.dydra.com/saam-mirror/saam/sparql \
187
   --user ":$STORE_TOKEN" \
188
   -H "Accept: application/sparql-query" \
189
   -H "Content-Type: application/json" \
190
   --data-binary @- <<EOF
191
 ["http://edan.si.edu/saam/id/ontologies/PE_lastname",
192
  "http://edan.si.edu/saam/id/ontologies/PE_firstname",
193
  "http://www.cidoc-crm.org/cidoc-crm/P69_is_associated_with"]
194
 EOF
195
 
196
 
197
 
198
 curl -X POST https://de17.dydra.com/saam-mirror/saam/sparql \
199
   --user ":$STORE_TOKEN" \
200
   -H "Accept: application/sparql-results+json" \
201
   -H "Content-Type: application/json" \
202
   --data-binary @- <<EOF
203
 ["http://edan.si.edu/saam/id/ontologies/PE_lastname",
204
  "http://edan.si.edu/saam/id/ontologies/PE_firstname",
205
  "http://www.cidoc-crm.org/cidoc-crm/P69_is_associated_with"]
206
 EOF
207
 
208
 --user ":$STORE_TOKEN" \
209
   
210
 curl -X POST https://de17.dydra.com/saam-mirror/saam/sparql \
211
   -H "Accept: application/sparql-results+json" \
212
   -H "Content-Type: application/json" \
213
   --data-binary @- <<EOF
214
 ["http://edan.si.edu/saam/id/ontologies/PE_lastname",
215
  "http://edan.si.edu/saam/id/ontologies/PE_firstname",
216
  "http://edan.si.edu/saam/id/ontologies/PE_has_note_primaryartistbio"]
217
 EOF
218
 
219
 curl -X POST https://de17.dydra.com/saam-mirror/saam/sparql \
220
   -H "Accept: application/json" \
221
   -H "Content-Type: application/json" \
222
   --data-binary @- <<EOF
223
 ["http://edan.si.edu/saam/id/ontologies/PE_lastname",
224
  "http://edan.si.edu/saam/id/ontologies/PE_firstname",
225
  "http://edan.si.edu/saam/id/ontologies/PE_has_note_primaryartistbio"]
226
 EOF
227
 
228
 
229
 |#
230
 (compute-instance-model (repository "saam-mirror/saam") mime:application/json)
231
 
232
 (spocq.i::print-sparql
233
 (graph-store-compute-where "saam-mirror/saam"
234
                            '(
235
       ;; <http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>
236
       ;; <http://www.cidoc-crm.org/cidoc-crm/P108_has_produced>
237
       ;; <http://edan.si.edu/saam/id/ontologies/PE_property>
238
       ;; <http://www.cidoc-crm.org/cidoc-crm/P140_assigned_attribute_to>
239
       ;; <http://www.cidoc-crm.org/cidoc-crm/P141_assigned>
240
       ;; <http://edan.si.edu/saam/id/ontologies/PE_probably_is_current_or_former_member_of>
241
       ;; <http://www.cidoc-crm.org/cidoc-crm/P82_at_some_time_within>
242
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_researchnotes>
243
       ;; <http://www.cidoc-crm.org/cidoc-crm/P74_has_current_or_former_residence>
244
       ;; <http://edan.si.edu/saam/id/ontologies/PE_suffix>
245
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_videoclip>
246
       ;; <http://edan.si.edu/saam/id/ontologies/PE_nametitle>
247
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_type_name>
248
       <http://edan.si.edu/saam/id/ontologies/PE_lastname>
249
       <http://edan.si.edu/saam/id/ontologies/PE_firstname>
250
       ;; <http://www.cidoc-crm.org/cidoc-crm/P7_took_place_at>
251
       ;; <http://www.cidoc-crm.org/cidoc-crm/P4_has_time-span>
252
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_luceartistbio>
253
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_luceartistquote>
254
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_primaryartistbio>
255
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_artistbio>
256
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_main_representation>
257
       ;; <http://www.cidoc-crm.org/cidoc-crm/P48_has_preferred_identifier>
258
       ;; <http://www.cidoc-crm.org/cidoc-crm/P100i_died_in>
259
       ;; <http://www.cidoc-crm.org/cidoc-crm/P98i_was_born>
260
       ;; <http://www.cidoc-crm.org/cidoc-crm/P107i_is_current_or_former_member_of>
261
       <http://www.cidoc-crm.org/cidoc-crm/P69_is_associated_with>
262
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_luceobjectquote>
263
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_lucecenterlabel>
264
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_newacquisitionlabel>
265
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_gallerylabel>
266
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_exibitionlabel>
267
       ;; <http://www.cidoc-crm.org/cidoc-crm/P3_has_note>
268
       ;; <http://www.cidoc-crm.org/cidoc-crm/P104_is_subject_to>
269
       ;; <http://www.cidoc-crm.org/cidoc-crm/P127_has_broader_term>
270
       ;; <http://www.w3.org/2004/02/skos/core#broader>
271
       ;; <http://www.w3.org/2004/02/skos/core#topConceptOf>
272
       ;; <http://www.w3.org/2004/02/skos/core#inScheme>
273
       ;; <http://www.w3.org/2004/02/skos/core#prefLabel>
274
       ;; |http://www.w3.org/2000/01/rdf-schema#|:|label|
275
       ;; <http://www.cidoc-crm.org/cidoc-crm/P129_is_about>
276
       ;; <http://www.cidoc-crm.org/cidoc-crm/P2_has_type>
277
       ;; <http://www.cidoc-crm.org/cidoc-crm/P1_is_identified_by>
278
       ;; <http://www.cidoc-crm.org/cidoc-crm/P55_has_current_location>
279
       ;; <http://www.cidoc-crm.org/cidoc-crm/P138i_has_representation>
280
       ;; <http://www.cidoc-crm.org/cidoc-crm/P128_carries>
281
       ;; |http://www.w3.org/1999/02/22-rdf-syntax-ns#|:|type|
282
       )))
283
 
284
 (test-sparql `(spocq.a:|select| (spocq.a:|slice|
285
                                          ,(graph-store-compute-where "saam-mirror/saam"
286
                            '(
287
                              ;; <http://www.cidoc-crm.org/cidoc-crm/P14_carried_out_by>
288
       ;; <http://www.cidoc-crm.org/cidoc-crm/P108_has_produced>
289
       ;; <http://edan.si.edu/saam/id/ontologies/PE_property>
290
       ;; <http://www.cidoc-crm.org/cidoc-crm/P140_assigned_attribute_to>
291
       ;; <http://www.cidoc-crm.org/cidoc-crm/P141_assigned>
292
       ;; <http://edan.si.edu/saam/id/ontologies/PE_probably_is_current_or_former_member_of>
293
       ;; <http://www.cidoc-crm.org/cidoc-crm/P82_at_some_time_within>
294
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_researchnotes>
295
       ;; <http://www.cidoc-crm.org/cidoc-crm/P74_has_current_or_former_residence>
296
       ;; <http://edan.si.edu/saam/id/ontologies/PE_suffix>
297
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_videoclip>
298
       ;; <http://edan.si.edu/saam/id/ontologies/PE_nametitle>
299
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_type_name>
300
       <http://edan.si.edu/saam/id/ontologies/PE_lastname>
301
       <http://edan.si.edu/saam/id/ontologies/PE_firstname>
302
       ;; <http://www.cidoc-crm.org/cidoc-crm/P7_took_place_at>
303
       ;; <http://www.cidoc-crm.org/cidoc-crm/P4_has_time-span>
304
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_luceartistbio>
305
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_luceartistquote>
306
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_primaryartistbio>
307
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_artistbio>
308
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_main_representation>
309
       ;; <http://www.cidoc-crm.org/cidoc-crm/P48_has_preferred_identifier>
310
       ;; <http://www.cidoc-crm.org/cidoc-crm/P100i_died_in>
311
       ;; <http://www.cidoc-crm.org/cidoc-crm/P98i_was_born>
312
       ;; <http://www.cidoc-crm.org/cidoc-crm/P107i_is_current_or_former_member_of>
313
       <http://www.cidoc-crm.org/cidoc-crm/P69_is_associated_with>
314
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_luceobjectquote>
315
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_lucecenterlabel>
316
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_newacquisitionlabel>
317
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_gallerylabel>
318
       ;; <http://edan.si.edu/saam/id/ontologies/PE_has_note_exibitionlabel>
319
       ;; <http://www.cidoc-crm.org/cidoc-crm/P3_has_note>
320
       ;; <http://www.cidoc-crm.org/cidoc-crm/P104_is_subject_to>
321
       ;; <http://www.cidoc-crm.org/cidoc-crm/P127_has_broader_term>
322
       ;; <http://www.w3.org/2004/02/skos/core#broader>
323
       ;; <http://www.w3.org/2004/02/skos/core#topConceptOf>
324
       ;; <http://www.w3.org/2004/02/skos/core#inScheme>
325
       ;; <http://www.w3.org/2004/02/skos/core#prefLabel>
326
       ;; |http://www.w3.org/2000/01/rdf-schema#|:|label|
327
       ;; <http://www.cidoc-crm.org/cidoc-crm/P129_is_about>
328
       ;; <http://www.cidoc-crm.org/cidoc-crm/P2_has_type>
329
       ;; <http://www.cidoc-crm.org/cidoc-crm/P1_is_identified_by>
330
       ;; <http://www.cidoc-crm.org/cidoc-crm/P55_has_current_location>
331
       ;; <http://www.cidoc-crm.org/cidoc-crm/P138i_has_representation>
332
       ;; <http://www.cidoc-crm.org/cidoc-crm/P128_carries> 
333
       ;; |http://www.w3.org/1999/02/22-rdf-syntax-ns#|:|type|
334
       )) :count 32)
335
                        ())
336
              :repository-id "saam-mirror/saam")
337
 
338
 (labels ((bgp (predicates)
339
          (let ((s (var)))
340
            (cons 'spocq.a:|bgp|
341
                  (loop for p in predicates
342
                    collect `(spocq.a:|triple| ,s ,p ,(var))))))
343
          (var () (make-variable (string (gensym "v")))))
344
   (test-sparql `(spocq.a:|select| (spocq.a:|slice|
345
                                            ,(bgp
346
 '(<http://www.cidoc-crm.org/cidoc-crm/P74_has_current_or_former_residence>
347
     <http://edan.si.edu/saam/id/ontologies/PE_has_note_luceartistbio>
348
     <http://edan.si.edu/saam/id/ontologies/PE_has_note_luceartistquote>
349
     <http://edan.si.edu/saam/id/ontologies/PE_has_note_artistbio>
350
     <http://edan.si.edu/saam/id/ontologies/PE_has_main_representation>
351
     <http://www.cidoc-crm.org/cidoc-crm/P48_has_preferred_identifier>
352
     <http://www.cidoc-crm.org/cidoc-crm/P100i_died_in>
353
     <http://www.cidoc-crm.org/cidoc-crm/P98i_was_born>
354
     <http://www.cidoc-crm.org/cidoc-crm/P107i_is_current_or_former_member_of>
355
     <http://www.cidoc-crm.org/cidoc-crm/P69_is_associated_with>
356
     <http://www.cidoc-crm.org/cidoc-crm/P1_is_identified_by>
357
     <http://www.cidoc-crm.org/cidoc-crm/P138i_has_representation>))
358
                                            :count 1)
359
                          ())
360
                :repository-id "saam-mirror/saam"))
361
 
362
 (labels ((bgp (predicates)
363
          (let ((s (var)))
364
            (cons 'spocq.a:|bgp|
365
                  (loop for p in predicates
366
                    collect `(spocq.a:|triple| ,s ,p ,(var))))))
367
          (var () (make-variable (string (gensym "v")))))
368
   (test-sparql `(spocq.a:|select|
369
                          (spocq.a:|slice|
370
                                   ,(bgp
371
                                     '(<http://edan.si.edu/saam/id/ontologies/PE_suffix>
372
                                       <http://edan.si.edu/saam/id/ontologies/PE_nametitle>
373
                                       <http://edan.si.edu/saam/id/ontologies/PE_has_type_name>
374
                                       <http://edan.si.edu/saam/id/ontologies/PE_lastname>
375
                                       <http://edan.si.edu/saam/id/ontologies/PE_firstname>
376
                                       |http://www.w3.org/2000/01/rdf-schema#|:|label|
377
                                       ))
378
                                   :count 1)
379
                          ())
380
                :repository-id "saam-mirror/saam"))
381
 
382
 (labels ((bgp (predicates)
383
          (let ((s (var)))
384
            (cons 'spocq.a:|bgp|
385
                  (loop for p in predicates
386
                    collect `(spocq.a:|triple| ,s ,p ,(var))))))
387
          (var () (make-variable (string (gensym "v")))))
388
   (test-sparql `(spocq.a:|select|
389
                          (spocq.a:|slice|
390
                                   ,(bgp
391
                                     '(<http://edan.si.edu/saam/id/ontologies/PE_suffix>
392
                                       <http://edan.si.edu/saam/id/ontologies/PE_nametitle>
393
                                       <http://edan.si.edu/saam/id/ontologies/PE_has_type_name>
394
                                       <http://edan.si.edu/saam/id/ontologies/PE_lastname>
395
                                       <http://edan.si.edu/saam/id/ontologies/PE_firstname>
396
                                       |http://www.w3.org/2000/01/rdf-schema#|:|label|
397
                                       ))
398
                                   :count 1)
399
                          ())
400
                :repository-id "saam-mirror/saam"))
401
 
402
 (labels ((bgp (predicates)
403
          (let ((s (var)))
404
            (cons 'spocq.a:|bgp|
405
                  (loop for p in predicates
406
                    collect `(spocq.a:|triple| ,s ,p ,(var))))))
407
          (var () (make-variable (string (gensym "v")))))
408
   (test-sparql `(spocq.a:|select|
409
                          (spocq.a:|slice|
410
                                   ,(bgp
411
                                     '(<http://edan.si.edu/saam/id/ontologies/PE_probably_is_current_or_former_member_of>
412
     <http://www.cidoc-crm.org/cidoc-crm/P48_has_preferred_identifier>
413
     <http://www.cidoc-crm.org/cidoc-crm/P69_is_associated_with>
414
     <http://www.cidoc-crm.org/cidoc-crm/P1_is_identified_by>))
415
                                   :count 1)
416
                          ())
417
                :repository-id "saam-mirror/saam"))
418
 
419
 (labels ((bgp (predicates)
420
          (let ((s (var)))
421
            (cons 'spocq.a:|bgp|
422
                  (loop for p in predicates
423
                    collect `(spocq.a:|triple| ,s ,p ,(var))))))
424
          (var () (make-variable (string (gensym "v")))))
425
   (test-sparql `(spocq.a:|select|
426
                          (spocq.a:|slice|
427
                                   ,(bgp
428
                                     '(<http://edan.si.edu/saam/id/ontologies/PE_has_note_luceartistbio>
429
     <http://edan.si.edu/saam/id/ontologies/PE_has_note_luceartistquote>
430
     <http://edan.si.edu/saam/id/ontologies/PE_has_note_primaryartistbio>
431
     <http://edan.si.edu/saam/id/ontologies/PE_has_note_artistbio>
432
     <http://edan.si.edu/saam/id/ontologies/PE_has_main_representation>
433
     <http://www.cidoc-crm.org/cidoc-crm/P48_has_preferred_identifier>
434
     <http://www.cidoc-crm.org/cidoc-crm/P100i_died_in>
435
     <http://www.cidoc-crm.org/cidoc-crm/P98i_was_born>
436
     <http://www.cidoc-crm.org/cidoc-crm/P107i_is_current_or_former_member_of>
437
     <http://www.cidoc-crm.org/cidoc-crm/P69_is_associated_with>
438
     <http://www.cidoc-crm.org/cidoc-crm/P1_is_identified_by>
439
     <http://www.cidoc-crm.org/cidoc-crm/P138i_has_representation>))
440
                                   :count 1)
441
                          ())
442
                :repository-id "saam-mirror/saam"))
443
 
444
 )