-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_resource_ids.rq
137 lines (133 loc) · 5.45 KB
/
get_resource_ids.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
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
#+ summary: Get all resources with their (preferred) identifiers
#+ 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 ?resource_id ?resource_pref_id ?res ?reslabel ?res_np ?res_np_date ?resourcetype ?qualification_np where {
graph npa:graph {
?res_np_pre npa:hasHeadGraph ?res_h .
?res_np_pre dct:created ?res_np_pre_date .
?res_np_pre npa:hasValidSignatureForPublicKey ?res_pubkey .
}
graph ?res_h {
?res_np_pre np:hasAssertion ?res_a .
?res_np_pre np:hasPublicationInfo ?res_i .
}
graph ?res_a {
values ?resourcetype_pre { fip:Available-FAIR-Enabling-Resource fip:FAIR-Enabling-Resource-to-be-Developed fip:FAIR-Enabling-Resource }
?resource_id a ?resourcetype_pre .
bind( exists { ?resource_id a fip:Available-FAIR-Enabling-Resource } as ?available_resource_pre )
bind( exists { ?resource_id a fip:FAIR-Enabling-Resource-to-be-Developed } as ?tobedeveloped_resource_pre )
?resource_id rdfs:label ?resourcelabel_pre .
}
graph ?res_i {
?res_np_pre (npx:introduces|npx:describes) ?resource_id .
}
optional {
graph npa:graph {
?res_np_new npa:hasHeadGraph ?rnh .
?res_np_new dct:created ?res_np_new_date .
?res_np_new npa:hasValidSignatureForPublicKey ?res_pubkey .
}
graph ?rnh {
?res_np_new np:hasAssertion ?rha .
?res_np_new np:hasPublicationInfo ?rni .
}
graph ?rha {
values ?resourcetype_new { fip:Available-FAIR-Enabling-Resource fip:FAIR-Enabling-Resource-to-be-Developed fip:FAIR-Enabling-Resource }
?resource_new a ?resourcetype_new .
bind( exists { ?resource_new a fip:Available-FAIR-Enabling-Resource } as ?available_resource_new )
bind( exists { ?resource_new a fip:FAIR-Enabling-Resource-to-be-Developed } as ?tobedeveloped_resource_new )
?resource_new rdfs:label ?resourcelabel_new .
}
graph ?rni {
?res_np_new npx:supersedes ?res_np_x .
?res_np_new (npx:introduces|npx:describes) ?resource_new .
}
# needs to be done properly:
?res_np_x npx:supersedes* ?res_np_pre .
}
bind(coalesce(?resource_new, ?resource_id) as ?resource_pref_id)
bind(coalesce(?res_np_new, ?res_np_pre) as ?res_np)
bind(coalesce(?res_np_new_date, ?res_np_pre_date) as ?res_np_date)
bind(coalesce(?resourcelabel_new, ?resourcelabel_pre) as ?resourcelabel)
bind(coalesce(?available_resource_new, ?available_resource_pre) as ?available_resource)
bind(coalesce(?tobedeveloped_resource_new, ?tobedeveloped_resource_pre) as ?tobedeveloped_resource)
bind(if(?available_resource, fip:Available-FAIR-Enabling-Resource,
if(?tobedeveloped_resource, fip:FAIR-Enabling-Resource-to-be-Developed,
fip:FAIR-Enabling-Resource
)
) as ?resourcetype )
optional {
graph npa:graph {
?res_np_r npa:hasHeadGraph ?rrh .
?res_np_r npa:hasValidSignatureForPublicKey ?res_pubkey .
}
graph ?rrh {
?res_np_r np:hasAssertion ?rra .
}
graph ?rra {
?rsomebody npx:retracts ?res_np .
}
} filter(!bound(?res_np_r)).
optional {
graph npa:graph {
?res_np_s npa:hasHeadGraph ?rsh .
?res_np_s npa:hasValidSignatureForPublicKey ?res_pubkey .
}
graph ?rsh {
?res_np_s np:hasPublicationInfo ?rsi .
}
graph ?rsi {
?res_np_s npx:supersedes ?res_np .
}
} filter(!bound(?res_np_s)).
bind (replace(str(?resource_pref_id), "^.*?(#|/)([^/#]*/?[^/#]*)/?$", "$2") as ?res)
bind (str(?resourcelabel) as ?reslabel)
optional {
values ?qpubkey {
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtpcftn7kbe6toJbOTDQaCcCssEFSWqt6J4rZ02w+TfY7/eIOgJZYOlpL6G3AzO2RNmVYWRPSlMiykaFuaRuBitvk1GKfGdprfZbvXwmeOxpqCTRBQX9EnFyQyd+Ra/ajfw/UsG8skeu1xnUEpnQbpgbQYc/fvhJNN0UwEc77mOwIDAQAB"^^xsd:string
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDO4xkU+/dGujq1raR66QtRqquMxiJ9hm2uzc2uBj7bCBBRnWhTw7M8f77BqAFHShgxqxYTr2do7/tVmoKeM51ISyttxWrh9ebZRoz5o6Muxt7HyA4sLHAmnixeZ5VJfZzsKAmVN23Y2ZiCqMoXjtcp5jO2lOC0AXaGPftnaA8b9QIDAQAB"^^xsd:string
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCFntPrMZqvg2kVhCNArNnEn37ddXGwZ/0r4C8CS4lDry7C7YkYgng9yb0UMZQUHiTVkR/5A4m/xjE+Vy+AnwcWUeB75SfGZjE5ylI6VeHjTHi9+2hh2PHYIWnkhU4WHl3COEnxSSa/VouvPzZ2BIWLH6fTrq7NNL3RF5hGegGG0QIDAQAB"^^xsd:string
}
graph npa:graph {
?qualification_np npa:hasHeadGraph ?qh .
?qualification_np npa:hasValidSignatureForPublicKey ?qpubkey .
}
graph ?qh {
?qualification_np np:hasAssertion ?qa .
}
graph ?qa {
?qualifier npx:qualifies ?res_np .
}
optional {
graph npa:graph {
?qnewversion npa:hasHeadGraph ?qnh .
?qnewversion npa:hasValidSignatureForPublicKey ?qpubkey .
}
graph ?qnh {
?qnewversion np:hasPublicationInfo ?qni .
}
graph ?qni {
?qnewversion npx:supersedes ?qualification_np .
}
} filter(!bound(?qnewversion)).
optional {
graph npa:graph {
?qretraction npa:hasHeadGraph ?qrh .
?qretraction npa:hasValidSignatureForPublicKey ?qpubkey .
}
graph ?qrh {
?qretraction np:hasAssertion ?ra .
}
graph ?qra {
?qsomebody npx:retracts ?qualification_np .
}
} filter(!bound(?qretraction)).
}
} order by ?resource_pref_id ?resource_id ?res ?reslabel ?res_np ?qualification_np