-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_declarations.rq
79 lines (76 loc) · 2.71 KB
/
get_declarations.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
74
75
76
77
78
79
#+ summary: Get all declarations for all communities
#+ method: GET
#+ pagination: 10000
prefix fip: <https://w3id.org/fair/fip/terms/>
prefix dct: <http://purl.org/dc/terms/>
prefix dce: <http://purl.org/dc/elements/1.1/>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix np: <http://www.nanopub.org/nschema#>
prefix dcat: <https://www.w3.org/ns/dcat#>
select distinct ?fip_index ?fip_title ?community ?c ?supercommunity ?sc ?question ?q ?sort ?nochoice ?decl ?rel ?resource_id_used ?startdate ?enddate ?date where {
?np np:hasAssertion ?assertion .
graph npa:graph { ?np dct:created ?date . }
graph ?assertion {
?decl a fip:FIP-Declaration .
values ?rel {
fip:declares-current-use-of fip:declares-planned-use-of fip:declares-planned-replacement-of
# unofficial:
fip:declares-replacement-from fip:declares-replacement-to
}
?decl ?rel ?resource_id_used .
?decl fip:refers-to-question ?question .
# grlc gives an error for some reason if these two optional statements are at the end of the graph block:
optional { ?decl dcat:startDate ?startdate . }
optional { ?decl dcat:endDate ?enddate . }
?decl fip:declared-by ?community .
}
optional {
?community dct:isPartOf ?supercommunity .
}
graph npa:graph { ?index_np npa:hasValidSignatureForPublicKey ?pubkey . }
?index_np np:hasAssertion ?index_a .
?index_np np:hasPublicationInfo ?index_i .
graph ?index_a {
?fip_index npx:includesElement ?np .
}
graph ?index_i {
?fip_index dce:title ?fip_title_l .
}
filter not exists {
?fip_newer_index npx:includesElement ?newer_np ;
dce:title ?fip_title_l .
graph npa:graph { ?newer_np dct:created ?newer_date . }
filter(?newer_date > ?date).
}
optional {
graph npa:graph {
?index_np_new npa:hasHeadGraph ?nh .
?index_np_new npa:hasValidSignatureForPublicKey ?pubkey .
}
graph ?nh {
?index_np_new np:hasPublicationInfo ?ni .
}
graph ?ni {
?index_np_new npx:supersedes ?index_np .
}
} filter(!bound(?index_np_new)).
optional {
graph npa:graph {
?index_np_r npa:hasHeadGraph ?rh .
?index_np_r npa:hasValidSignatureForPublicKey ?pubkey .
}
graph ?rh {
?index_np_r np:hasAssertion ?ra .
}
graph ?ra {
?somebody npx:retracts ?index_np .
}
} filter(!bound(?index_np_r)).
bind (replace(str(?community), ".*#", "") as ?c)
bind (replace(str(?supercommunity), ".*#", "") as ?sc)
bind (replace(str(?question), "^.*-([^-MD]+(-[MD]+)?)$", "$1") as ?q)
bind (concat(replace(?q, "F|M", "0"), "x") as ?sort)
bind (str(?fip_title_l) as ?fip_title)
bind ("" as ?nochoice)
} order by ?sort ?c ?fip_index ?decl ?resource_id_used