-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-latest-nanopubs-for-subset.rq
73 lines (64 loc) · 4.4 KB
/
get-latest-nanopubs-for-subset.rq
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
#+ endpoint: https://query.knowledgepixels.com/repo/meta
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix foaf: <http://xmlns.com/foaf/0.1/>
select distinct ?np ?label (group_concat(distinct ?type; separator=" ") as ?types) (group_concat(distinct ?userid; separator=" ") as ?creators) ?signer ?pkh ?date {
graph npa:graph {
?np dct:created ?date .
optional { ?np rdfs:label ?label . }
#=================== MULTI-VALUE PLACEHOLDER ====================#------ config: ------
{ select ?type { # <- VAR type
bind(?__types as ?v) # <- VAR __types
optional {<x:> <x:> ?__types} # (for grlc to pick it up) # <- VAR __types
{select*{optional{?a ?b ?c}}limit 1} # (for some Virtuoso v.) #
values ?x{0 1 2 3 4 5 6 7 8 9} values ?y{0 1 2 3 4 5 6 7 8 9} #
bind((10*?x)+?y as ?n) # (works for a maximum of 100 values) #
bind(" " as ?sep) # (separator as regex-compatible character) # <- CONST sep
bind(concat("^([^",?sep,"]*",?sep,"){",str(?n),"}") as ?p) #
bind(concat(?sep,".*") as ?p0) #
filter(if(?n=0,true,regex(?v,?p))) # (=0 check for Virtuoso) #
bind(replace(if(?n=0,?v,replace(?v,?p,"")),?p0,"") as ?val) #
bind(uri(?val) as ?type) # <- VAR type
} } #
#================================================================#---------------------
?np npx:hasNanopubType ?type .
filter not exists { ?np npx:hasNanopubType npx:ExampleNanopub . }
#=================== MULTI-VALUE PLACEHOLDER ====================#------ config: ------
{ select ?pkh { # <- VAR pkh
bind(?__pubkeyhashes as ?v) # <- VAR __pubkeyhashes
optional {<x:> <x:> ?__pubkeyhashes} # (for grlc to pick i...) # <- VAR __pubkeyhashes
{select*{optional{?a ?b ?c}}limit 1} # (for some Virtuoso v.) #
values ?x{0 1 2 3 4 5 6 7 8 9} values ?y{0 1 2 3 4 5 6 7 8 9} #
bind((10*?x)+?y as ?n) # (works for a maximum of 100 values) #
bind(" " as ?sep) # (separator as regex-compatible character) # <- CONST sep
bind(concat("^([^",?sep,"]*",?sep,"){",str(?n),"}") as ?p) #
bind(concat(?sep,".*") as ?p0) #
filter(if(?n=0,true,regex(?v,?p))) # (=0 check for Virtuoso) #
bind(replace(if(?n=0,?v,replace(?v,?p,"")),?p0,"") as ?pkh) # <- VAR pkh
} } #
#================================================================#---------------------
?np npa:hasValidSignatureForPublicKeyHash ?pkh .
filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pkh . }
#=================== MULTI-VALUE PLACEHOLDER ====================#------ config: ------
{ select ?userid { # <- VAR userid
bind(?__users as ?v) # <- VAR __users
optional {<x:> <x:> ?__users} # (for grlc to pick it up) # <- VAR __users
{select*{optional{?a ?b ?c}}limit 1} # (for some Virtuoso v.) #
values ?x{0 1 2 3 4 5 6 7 8 9} values ?y{0 1 2 3 4 5 6 7 8 9} #
bind((10*?x)+?y as ?n) # (works for a maximum of 100 values) #
bind(" " as ?sep) # (separator as regex-compatible character) # <- CONST sep
bind(concat("^([^",?sep,"]*",?sep,"){",str(?n),"}") as ?p) #
bind(concat(?sep,".*") as ?p0) #
filter(if(?n=0,true,regex(?v,?p))) # (=0 check for Virtuoso) #
bind(replace(if(?n=0,?v,replace(?v,?p,"")),?p0,"") as ?val) #
bind(uri(?val) as ?userid) # <- VAR userid
} } #
#================================================================#---------------------
?np dct:creator ?userid .
optional { ?np npx:signedBy ?signer . }
}
} group by ?np ?label ?signer ?pkh ?date order by desc(?date) limit 50