-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-lod.html
More file actions
408 lines (392 loc) · 32 KB
/
generate-lod.html
File metadata and controls
408 lines (392 loc) · 32 KB
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PROV-A, the Provenance App</title>
<!-- External Libraries -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v6.5.0/css/all.css">
<link rel="stylesheet" href="style/codemirror.css">
<style>
.CodeMirror {
border: 1px solid #eee;
height: 350px;
}
.loader {
margin: auto;
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 150px;
height: 150px;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body style="display: flex; flex-direction: column; min-height: 100vh;">
<nav class="navbar navbar-dark navbar-expand-lg bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="index.html">PROV-A, the Provenance App</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="initialise-project.html">Initialise Project</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="structure-data.html">Structure Data</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="generate-lod.html">Generate LOD</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid mt-5">
<div id="step1" class="container">
<div class="row">
<div class="col text-center">
<button class="btn btn-success d-none" id="generateLODButton">Initialize Database</button>
<div id="noDataMessage" class="mt-3 d-none">No data found. Please <a href="initialise-project.html">initialize a new project</a>. </div>
</div>
</div>
</div>
<div id="loaderModal" class="modal" tabindex="-1" style="z-index:9999" role="dialog" aria-labelledby="loaderLabel" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
<div class="modal-dialog modal-dialog-centered text-center" role="document">
<div class="modal-content" style="background: transparent !important; border: 0 !important">
<div class="loader"></div>
<div class="mt-5 p-3 alert alert-light">Initializing Database. This may take a few minutes.</div>
</div>
</div>
</div>
<div id="loaderModalQuery" class="modal" tabindex="-1" style="z-index:9999" role="dialog" aria-labelledby="loaderLabel" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content" style="background: transparent !important; border: 0 !important">
<div class="loader"></div>
</div>
</div>
</div>
<div id="step2" class="d-none">
<div class="container">
<div class="d-flex justify-content-between align-items-center my-4">
<div>
<a type="button" class="btn btn-success me-2" id="downloadLink">
<i class="fa-solid fa-file-arrow-down"></i> Download LOD
</a>
<a type="button" class="btn btn-primary" id="updateLOD">
<i class="fa-solid fa-arrow-rotate-right"></i> Refresh LOD
</a>
</div>
<div>
<button class="btn btn-info me-2 text-white" data-bs-toggle="modal" data-bs-target="#sparqlModal"> <i class="fa-solid fa-folder-open"></i> SPARQL Queries</button>
<a href="https://github.com/prov-a/prov-a.github.io/blob/main/data-model.md" type="button" class="btn btn-secondary" target="_blank">
Data Model <i class="fa-solid fa-arrow-up-right-from-square"></i>
</a>
</div>
</div>
<div class="row">
<div class="col">
<div class="code-textarea">
<div class="line-numbers">
</div>
<textarea class="form-control code-input" rows="20" id="codeTextarea" style="resize: none;">
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX crminf: <http://www.cidoc-crm.org/crminf/>
PREFIX np: <http://www.nanopub.org/nschema#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX gvp: <http://vocab.getty.edu/ontology#>
SELECT ?subject ?predicate ?object ?graph
WHERE {
GRAPH ?graph {
?subject ?predicate ?object .
}
} LIMIT 1000</textarea>
</div>
<div class="alert alert-danger alert-query alert-dismissible mt-3 d-none" role="alert" id="error">
<button type="button" class="btn-close" onclick="$(this).closest('.alert').addClass('d-none')"></button>
<strong>Malformed SPARQL query</strong>
</div>
<div class="alert alert-warning alert-query alert-dismissible mt-3 d-none" role="alert" id="noresults">
<button type="button" class="btn-close" onclick="$(this).closest('.alert').addClass('d-none')"></button>
<strong>No Results</strong>
</div>
</div>
</div>
<div class="row text-center mt-4">
<div class="col">
<button type="submit" id="submitButton" class="btn btn-outline-primary">Submit</button>
</div>
</div>
</div>
<div class="row mt-4">
<nav class="navbar navbar-light bg-light d-none" id="resultsNav">
<div class="container-fluid">
<ul class="navbar-nav">
<li class="nav-item">
<div class="navbar-text"><span id="resultsCounter"></span> Results</div>
</li>
</ul>
<div class="d-flex">
<input class="form-control me-2" type="search" placeholder="Filter" id="searchInput">
<button class="btn btn-success text-nowrap" type="button" id="downloadButton"><i class="fa-solid fa-file-arrow-down"></i> Download Results</button>
</div>
</div>
</nav>
<div id="resultsContainer" class="mt-3 table-responsive"></div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="sparqlModal" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="sparqlModalLabel">SPARQL Queries</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="list-group" id="sparqlQueryList">
<!-- Queries will be dynamically added here -->
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script src="./src/dist/codemirror.js"></script>
<script src="./src/dist/matchbrackets.js"></script>
<script src="./src/dist/codemirror_sparql.js"></script>
<script src="src/dist/n3.js"></script>
<script type="text/javascript" src="./src/edtf.js"></script>
<script type="module">
import { generateLOD, sparql, download, initializeDatabase } from './src/plod.js';
$(document).ready(function() {
// Step 1: Check for data in localStorage
const storedJsonData = localStorage.getItem('provaData');
indexedDB.databases().then(databases => {
if (!storedJsonData) {
for (var i = 0; i < databases.length; i++) { window.indexedDB.deleteDatabase(databases[i].name) }
$('#noDataMessage').removeClass('d-none');
}
else if (databases.length > 0) {
$('#step1').addClass('d-none');
$('#step2').removeClass('d-none');
initializeDatabase().then(() => {
download();
initCodeMirror();
})
} else if (storedJsonData) {
$('#generateLODButton').removeClass('d-none');
$('#generateLODButton').on('click', function() {
$('#loaderModal').modal('show');
initializeDatabase().then(() => {
generateLOD(JSON.parse(storedJsonData)).then(() => {
$('#loaderModal').modal('hide');
$('#step1').addClass('d-none');
$('#step2').removeClass('d-none');
initCodeMirror();
}).catch((error) => {
alert('Error generating LOD: ' + error);
$('#loaderModal').modal('hide');
});
});
});
}
})
function initCodeMirror() {
// Initialize CodeMirror editor
const editor = CodeMirror.fromTextArea(document.getElementById("codeTextarea"), {
mode: "application/x-sparql-query",
lineNumbers: true,
matchBrackets: true
});
$('#updateLOD').on('click', function() {
$("#error").addClass("d-none")
$("#noresults").addClass("d-none")
$("#resultsNav").addClass("d-none")
var container = $("#resultsContainer");
container.empty()
var counter = $("#resultsCounter");
counter.empty()
container.empty()
$('#loaderModal').modal('show');
generateLOD(JSON.parse(storedJsonData)).then(() => {
$('#loaderModal').modal('hide');
}).catch((error) => {
alert('Error generating LOD: ' + error);
$('#loaderModal').modal('hide');
});
});
$('#submitButton').on('click', function() {
let textareaContent = editor.getValue();
if (textareaContent){
sparql(textareaContent)
}
});
$('#searchInput').on('input', function() {
var searchText = $(this).val().toLowerCase();
$('#resultsTable tbody tr').filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(searchText) > -1);
});
});
$('#downloadButton').on('click', function() {
var confirmDownload = confirm("Are you sure you want to download the table as CSV?");
if (confirmDownload) {
var csvContent = [];
// Add table headers to CSV
var headers = [];
$('#resultsTable thead th').each(function() {
headers.push($(this).text());
});
csvContent.push(headers.join(','));
// Add table rows to CSV
$('#resultsTable tbody tr').each(function() {
const rowData = [];
$(this).find('td').each(function() {
const cellContent = $(this).text().replace(/"/g, '""').trim();
rowData.push('"' + cellContent.replace(/\n/g, '\\n') + '"');
});
csvContent.push(rowData.join(','));
});
const csvString = csvContent.join('\n');
const encodedUri = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csvString);
const link = document.createElement('a');
link.setAttribute('href', encodedUri);
link.setAttribute('download', 'results.csv');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
});
const sparqlPrefixes = `PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX crminf: <http://www.cidoc-crm.org/crminf/>
PREFIX np: <http://www.nanopub.org/nschema#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX gvp: <http://vocab.getty.edu/ontology#>
`;
const sparqlQuerySections = [
{
category: "Queries for Physical Objects",
queries: [
{ id: 1, description: "Retrieve Titles of Physical Objects", query: `SELECT ?physical_object ?title_content\nWHERE {\n GRAPH ?object_graph {\n ?physical_object a crm:E19_Physical_Object .\n ?physical_object crm:P102_has_title ?title.\n ?title crm:P190_has_symbolic_content ?title_content.\n }\n}\n` },
{ id: 2, description: "Retrieve URLs for Physical Objects", query: `SELECT ?physical_object ?url_content\nWHERE {\n GRAPH ?object_graph {\n ?physical_object a crm:E19_Physical_Object .\n ?physical_object crm:P70i_is_documented_in ?document.\n ?document crm:P1_is_identified_by ?url.\n ?url crm:P190_has_symbolic_content ?url_content.\n }\n}\n` },
{ id: 3, description: "Retrieve Medium Information of Physical Objects", query: `SELECT ?physical_object ?medium_content\nWHERE {\n GRAPH ?object_graph {\n ?physical_object a crm:E19_Physical_Object .\n ?physical_object crm:P67i_is_referred_to_by ?linguistic_object .\n ?linguistic_object crm:P2_has_type <http://vocab.getty.edu/aat/300435429> .\n ?linguistic_object crm:P190_has_symbolic_content ?medium_content .\n }\n}\n` },
{ id: 4, description: "Retrieve Accession Numbers of Physical Objects", query: `SELECT ?physical_object ?accession\nWHERE {\n GRAPH ?object_graph {\n ?physical_object a crm:E19_Physical_Object .\n ?physical_object crm:P67i_is_referred_to_by ?linguistic_object .\n ?linguistic_object crm:P2_has_type <http://vocab.getty.edu/aat/300312355> .\n ?linguistic_object crm:P190_has_symbolic_content ?accession .\n }\n}\n` },
{ id: 5, description: "Retrieve Credit Line for Physical Objects", query: `SELECT ?physical_object ?credit_line\nWHERE {\n GRAPH ?object_graph {\n ?physical_object a crm:E19_Physical_Object .\n ?physical_object crm:P67i_is_referred_to_by ?linguistic_object .\n ?linguistic_object crm:P2_has_type <http://vocab.getty.edu/aat/300435418> .\n ?linguistic_object crm:P190_has_symbolic_content ?credit_line .\n }\n}\n` }
]
},
{
category: "Queries for Provenance Activities",
queries: [
{ id: 6, description: "Retrieve Provenance Activity Date Range", query: `SELECT DISTINCT ?provenance_activity ?begin_of_the_begin ?end_of_the_end\nWHERE {\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n ?provenance_activity crm:P4_has_time-span ?timespan .\n OPTIONAL { ?timespan crm:P82a_begin_of_the_begin ?begin_of_the_begin . }\n OPTIONAL { ?timespan crm:P82b_end_of_the_end ?end_of_the_end . }\n }\n}\n` },
{ id: 7, description: "Retrieve Provenance Event Type", query: `SELECT DISTINCT ?provenance_activity ?activity_type\nWHERE {\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n ?provenance_activity crm:P2_has_type ?activity_type\n }\n}\n` },
{ id: 8, description: "Retrieve Sender and Receiver of Ownership Transfer", query: `SELECT ?provenance_activity ?sender ?receiver ?physical_object\nWHERE {\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n ?provenance_activity crm:P9_consists_of ?acquisition .\n ?acquisition crm:P24_transferred_title_of ?physical_object .\n ?acquisition crm:P22_transferred_title_to ?receiver .\n ?acquisition crm:P23_transferred_title_from ?sender .\n }\n}\n` },
{ id: 9, description: "Retrieve Sender and Receiver of Custody Transfers", query: `SELECT ?provenance_activity ?sender ?receiver ?physical_object\nWHERE {\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n ?provenance_activity crm:P9_consists_of ?custody_change .\n ?custody_change crm:P30_transferred_custody_of ?physical_object .\n ?custody_change crm:P29_custody_received_by ?receiver .\n ?custody_change crm:P28_custody_surrendered_by ?sender .\n }\n}\n` },
{ id: 10, description: "Retrieve Agents Involved in Provenance Activities", query: `SELECT ?provenance_activity ?agent\nWHERE {\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n ?provenance_activity crm:P9_consists_of ?acquisition .\n ?acquisition crm:P14_carried_out_by ?agent .\n }\n}\n` },
]
},
{
category: "Queries for Parties",
queries: [
{ id: 11, description: "Retrieve Group Types of Parties", query: `SELECT DISTINCT ?party ?type\nWHERE {\n GRAPH ?party_graph {\n ?party a crm:E74_Group .\n ?party crm:P2_has_type ?type .\n ?type crm:P127_has_broader_term <http://vocab.getty.edu/aat/300192630> .\n }\n}\n` },
{ id: 12, description: "Retrieve Gender Classification of Individuals", query: `SELECT DISTINCT ?party ?sex\nWHERE {\n GRAPH ?party_graph {\n ?party a crm:E21_Person .\n ?party crm:P2_has_type ?sex .\n ?sex crm:P127_has_broader_term <http://vocab.getty.edu/aat/300445640> .\n }\n}\n` },
{ id: 13, description: "Retrieve Birth and Death Dates of Individuals", query: `SELECT DISTINCT ?party ?birth_begin_of_the_begin ?birth_end_of_the_end ?death_begin_of_the_begin ?death_end_of_the_end\nWHERE {\n GRAPH ?party_graph {\n ?party a crm:E21_Person .\n ?party crm:P98i_was_born ?birth .\n ?birth crm:P4_has_time-span ?birth_timespan .\n ?birth_timespan crm:P82a_begin_of_the_begin ?birth_begin_of_the_begin .\n ?birth_timespan crm:P82b_end_of_the_end ?birth_end_of_the_end .\n ?party crm:P100i_died_in ?death .\n ?death crm:P4_has_time-span ?death_timespan .\n ?death_timespan crm:P82a_begin_of_the_begin ?death_begin_of_the_begin .\n ?death_timespan crm:P82b_end_of_the_end ?death_end_of_the_end .\n }\n}\n` },
{ id: 14, description: "Retrieve Names and Appellations of Individuals", query: `SELECT ?party ?party_label (GROUP_CONCAT(DISTINCT ?appellation_content; separator='; ') AS ?appellations)\nWHERE {\n GRAPH ?party_graph {\n ?party a crm:E21_Person .\n ?party rdfs:label ?party_label .\n ?party crm:P1_is_identified_by ?appellation .\n ?appellation crm:P190_has_symbolic_content ?appellation_content .\n }\n}\nGROUP BY ?party ?party_label\n` },
{ id: 15, description: "Retrieve Locations Associated with Individuals", query: `SELECT ?party ?party_label (GROUP_CONCAT(DISTINCT ?location_label; separator='; ') AS ?locations)\nWHERE {\n GRAPH ?party_graph {\n ?party a crm:E21_Person .\n ?party rdfs:label ?party_label .\n ?party crm:P74_has_current_or_former_residence ?location .\n ?location rdfs:label ?location_label .\n }\n}\nGROUP BY ?party ?party_label\n` },
]
},
{
category: "Queries for Provenance Assessments",
queries: [
{ id: 16, description: "Retrieve Physical Objects in Provenance Assessments", query: `SELECT ?assessment ?physical_object\nWHERE {\n GRAPH ?provenance_graph {\n ?assessment a crminf:I15_Provenance_Assessment .\n ?assessment crminf:J20_is_about_the_provenance_of ?physical_object .\n }\n}\n` },
{ id: 17, description: "Retrieve Sources Used in Provenance Assessments", query: `SELECT ?assessment ?source_label\nWHERE {\n GRAPH ?provenance_graph {\n ?assessment a crminf:I15_Provenance_Assessment .\n ?assessment crm:P16_used_specific_object ?source .\n ?source rdfs:label ?source_label .\n }\n}\n` },
{ id: 18, description: "Retrieve Authors of Provenance Assessments", query: `SELECT ?assessment ?author_label\nWHERE {\n GRAPH ?provenance_graph {\n ?assessment a crminf:I15_Provenance_Assessment .\n ?assessment crm:P14_carried_out_by ?author .\n ?author rdfs:label ?author_label .\n }\n}\n` },
{ id: 19, description: "Retrieve Date Range of Provenance Assessments", query: `SELECT ?assessment ?begin_of_the_begin ?end_of_the_end\nWHERE {\n GRAPH ?provenance_graph {\n ?assessment a crminf:I15_Provenance_Assessment .\n ?assessment crm:P4_has_time-span ?timespan .\n ?timespan crm:P82a_begin_of_the_begin ?begin_of_the_begin .\n ?timespan crm:P82b_end_of_the_end ?end_of_the_end .\n }\n}\n` },
{ id: 20, description: "Retrieve Assertions in Provenance Assessments", query: `SELECT ?assessment ?assertion_graph\nWHERE {\n GRAPH ?provenance_graph {\n ?assessment a crminf:I15_Provenance_Assessment .\n ?assessment crminf:J21_concluded_provenance ?belief .\n ?belief crminf:J4_that ?assertion_graph .\n }\n}\n` }
]
},
{
category: "Queries Across Multiple Graphs",
queries: [
{ id: 21, description: "Retrieve Activities Involving Female Parties", query: `SELECT ?activity ?party ?party_label\nWHERE {\n GRAPH ?assertion_graph {\n ?activity a crm:E7_Activity .\n ?activity crm:P9_consists_of ?sub_activity .\n ?sub_activity ?role ?party .\n }\n GRAPH ?party_graph {\n ?party crm:P2_has_type <http://vocab.getty.edu/aat/300411837> .\n ?party rdfs:label ?party_label .\n }\n}\n` },
{ id: 22, description: "Retrieve Uncertain Activity Types", query: `SELECT ?provenance_activity ?activity_type\nWHERE {\n GRAPH ?provenance_graph {\n ?assessment a crminf:I15_Provenance_Assessment .\n ?assessment crminf:J21_concluded_provenance ?belief .\n ?belief crminf:J5_holds_to_be <http://vocab.getty.edu/aat/300435721> .\n ?belief crminf:J4_that ?assertion_graph .\n }\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n ?provenance_activity crm:P2_has_type ?activity_type .\n }\n}\n` },
{ id: 23, description: "Retrieve Senders and Sources in Activities", query: `SELECT ?source_label ?party_label ?sender\nWHERE {\n GRAPH ?provenance_graph {\n ?assessment a crminf:I15_Provenance_Assessment .\n ?assessment crm:P16_used_specific_object ?source .\n ?source rdfs:label ?source_label .\n ?assessment crminf:J21_concluded_provenance ?belief .\n ?belief crminf:J4_that ?assertion_graph .\n }\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n ?provenance_activity crm:P9_consists_of ?sub_activity .\n ?sub_activity ?sender ?party .\n }\n GRAPH ?party_graph {\n ?party rdfs:label ?party_label .\n }\n FILTER ( ?sender = crm:P23_transferred_title_from || ?sender = crm:P28_custody_surrendered_by )\n}\n` },
{ id: 24, description: "Retrieve Acquisition Receivers in Paris", query: `SELECT DISTINCT ?provenance_activity ?party_label\nWHERE {\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n ?provenance_activity crm:P9_consists_of ?sub_activity .\n ?sub_activity crm:P22_transferred_title_to ?party .\n }\n GRAPH ?party_graph {\n ?party rdfs:label ?party_label .\n ?party crm:P74_has_current_or_former_residence ?location .\n ?location owl:sameAs <https://www.wikidata.org/wiki/Q90> .\n }\n}\n` },
{ id: 25, description: "Retrieve Activity Dates and Object Titles", query: `SELECT DISTINCT ?title_content ?end_of_the_end\nWHERE {\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n ?provenance_activity crm:P9_consists_of ?sub_activity .\n ?sub_activity ?involved ?physical_object .\n ?provenance_activity a crm:E7_Activity .\n ?provenance_activity crm:P4_has_time-span ?timespan .\n OPTIONAL { ?timespan crm:P82b_end_of_the_end ?end_of_the_end . }\n }\n GRAPH ?object_graph {\n ?physical_object a crm:E19_Physical_Object .\n ?physical_object crm:P102_has_title ?title.\n ?title crm:P190_has_symbolic_content ?title_content.\n }\n FILTER ( ?involved = crm:P24_transferred_title_of || ?involved = crm:P30_transferred_custody_of )\n}\nORDER BY ?end_of_the_end\n` }
]
},
{
category: "Query for Incomplete Records",
queries: [
{ id: 26, description: "Retrieve Gaps Between Consecutive Activities", query: `SELECT DISTINCT ?activity_1 ?activity_2\nWHERE {\n GRAPH ?assertion_graph_1 {\n ?activity_1 crm:P9_consists_of ?sub_activity_1 .\n ?sub_activity_1 ?receiver ?party_A .\n VALUES ?receiver { crm:P29_custody_received_by crm:P22_transferred_title_to } \n }\n GRAPH ?assertion_graph_2 {\n ?activity_2 crm:P183i_starts_after_the_end_of ?activity_1 .\n FILTER NOT EXISTS {\n ?activity_2 crm:P9_consists_of ?sub_activity_2 .\n ?sub_activity_2 ?sender ?party_A .\n VALUES ?sender { crm:P28_custody_surrendered_by crm:P23_transferred_title_from } \n }\n }\n}\n` },
{ id: 27, description: "Retrieve Gaps After Object Creation", query: `SELECT DISTINCT ?activity_1 ?activity_2\nWHERE {\n GRAPH ?assertion_graph_1 {\n ?activity_1 crm:P9_consists_of ?sub_activity_1 .\n ?sub_activity_1 a crm:E12_Production .\n ?sub_activity_1 crm:P14_carried_out_by ?party_A .\n }\n GRAPH ?assertion_graph_2 {\n ?activity_2 crm:P183i_starts_after_the_end_of ?activity_1 .\n FILTER NOT EXISTS {\n ?activity_2 crm:P9_consists_of ?sub_activity_2 .\n ?sub_activity_2 ?sender ?party_A .\n VALUES ?sender { crm:P28_custody_surrendered_by crm:P23_transferred_title_from } \n }\n }\n}\n` },
{ id: 28, description: "Retrieve Activities Missing Dates", query: `SELECT DISTINCT ?provenance_activity\nWHERE {\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n FILTER NOT EXISTS {\n ?provenance_activity crm:P4_has_time-span ?timespan .\n }\n }\n}\n` },
{ id: 29, description: "Retrieve Assertions Missing Sources", query: `SELECT DISTINCT ?provenance_activity\nWHERE {\n GRAPH ?provenance_graph {\n ?assessment a crminf:I15_Provenance_Assessment .\n ?assessment crminf:J21_concluded_provenance ?belief .\n ?belief crminf:J4_that ?assertion_graph .\n FILTER NOT EXISTS { ?assessment crm:P16_used_specific_object ?source . }\n }\n GRAPH ?assertion_graph {\n ?provenance_activity a crm:E7_Activity .\n }\n}\n` },
{ id: 30, description: "Retrieve People Missing ULAN Identifiers", query: `SELECT DISTINCT ?party ?party_label\nWHERE {\n GRAPH ?party_graph {\n ?party a crm:E21_Person .\n ?party rdfs:label ?party_label .\n FILTER NOT EXISTS {\n ?party owl:sameAs ?ulan .\n FILTER(CONTAINS(STR(?ulan), 'ulan'))\n }\n }\n}\n` }
]
}
];
const $sparqlQueryList = $("#sparqlQueryList");
sparqlQuerySections.forEach((section, index) => {
const categoryId = `category-${index}`;
const $categoryTitle = $(`<h5 class="mt-3 text-primary">${section.category}</h5>`);
$sparqlQueryList.append($categoryTitle);
const $categoryAccordion = $(`
<div class="accordion" id="${categoryId}"></div>
`);
section.queries.forEach((query, queryIndex) => {
const queryId = `${categoryId}-query-${queryIndex}`;
const $queryItem = $(`
<div class="accordion-item">
<h2 class="accordion-header" id="heading-${queryId}">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-${queryId}" aria-expanded="false">
${query.description}
</button>
</h2>
<div id="collapse-${queryId}" class="accordion-collapse collapse" aria-labelledby="heading-${queryId}" data-bs-parent="#${categoryId}">
<div class="accordion-body">
<pre class="bg-light p-2 border rounded">${query.query}</pre>
<button class="btn btn-sm btn-primary use-query-btn mt-2" data-query="${query.query}">Use</button>
</div>
</div>
</div>
`);
$queryItem.find(".use-query-btn").on("click", function () {
const selectedQuery = sparqlPrefixes + $(this).data("query");
$("#codeTextarea").val(selectedQuery);
editor.setValue(selectedQuery);
$('#sparqlModal').modal('hide');
});
$categoryAccordion.append($queryItem);
});
$sparqlQueryList.append($categoryAccordion);
});
}
});
</script>
</body>
</html>