-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueries.tsx
111 lines (96 loc) · 3.46 KB
/
Queries.tsx
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
export function fileQuery(spatialActor: string): string {
return `
prefix sg: <http://example.org/scenegraph#>
prefix ex: <http://example.org/ex#>
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 dcterms: <http://purl.org/dc/terms/>
prefix dcat: <http://www.w3.org/ns/dcat#>
prefix prov: <http://www.w3.org/ns/prov#>
SELECT ?downloadURL ?mediatype ?filename
WHERE {
<${spatialActor}> a sg:SpatialActor;
dcterms:title ?filename;
sg:hasRepresentation ?dist .
?dist a dcat:Distribution ;
dcat:downloadURL ?downloadURL;
dcterms:mediaType ?mediatype .
}
`;
}
export function selectSceneGraphActors(date: Date): string {
return `
PREFIX sg: <http://example.org/scenegraph#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT DISTINCT
?s
WHERE
{
?s a sg:SpatialActor .
?transform a sg:Transformation ;
sg:hasSpatialActor ?s ;
prov:generatedAtTime ?created .
FILTER (?created <= "${date.toISOString()}"^^xsd:dateTime)
}
`;
}
export function selectTransform(spatialActor: string, date: Date): string {
return `
PREFIX sg: <http://example.org/scenegraph#>
PREFIX ex: <http://example.org/ex#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT ?transform ?p ?o
WHERE {
<${spatialActor}> a sg:SpatialActor .
<${spatialActor}> ?p ?o .
OPTIONAL {
?transform rdf:type sg:Transformation ;
sg:hasSpatialActor <${spatialActor}> ;
?prop ?obj ;
prov:generatedAtTime ?created .
FILTER (?created <= "${date.toISOString()}"^^xsd:dateTime)
FILTER NOT EXISTS {
?otherTransform rdf:type sg:Transformation ;
sg:hasSpatialActor <${spatialActor}> ;
prov:generatedAtTime ?otherCreated .
FILTER (?otherCreated > ?created && ?otherCreated <= "${date.toISOString()}"^^xsd:date)
}
BIND(?transform AS ?latestTransform)
BIND(?created AS ?latestCreated)
}
}
ORDER BY DESC(?latestCreated)
LIMIT 1
`;
}
export function constructTransformMatrix(transformSubject: string): string {
return `
PREFIX sg: <http://example.org/scenegraph#>
PREFIX ex: <http://example.org/ex#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
CONSTRUCT {
<${transformSubject}> ?p ?o
} WHERE {
<${transformSubject}> ?p ?o
}
`;
}
export function selectDates(): string {
return `
PREFIX sg: <http://example.org/scenegraph#>
PREFIX ex: <http://example.org/ex#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT ?transformation ?created WHERE {
?transformation rdf:type sg:Transformation ;
prov:generatedAtTime ?created .
} ORDER BY DESC(?created)
`;
}