Skip to content

Commit

Permalink
updated queries as used in demo
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-metalinkage committed Oct 31, 2024
1 parent 3dbed69 commit e19b460
Show file tree
Hide file tree
Showing 14 changed files with 1,427 additions and 10 deletions.
15 changes: 15 additions & 0 deletions init-stardog.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
call sda db create -n geotest -o spatial.enabled=true
REM query.describe.strategy=bidirectional
REM graphql.auto.schema
REM graphql.auto.schema.source=shacl
REM auto.schema.reasoning
REM reasoning.sameas (ON,OFF, FULL)
REM tag:stardog:api:context:schema
REM reasoning.schemas prov=https://www.w3.org/ns/prov
REM reasoning.schemas.graphs https://www.w3.org/ns/prov, tag:stardog:api:context:schema
call sd data add -- --named-graph https://www.w3.org/ns/prov prov-o.ttl

call sd reasoning schema --add prov --graphs https://www.w3.org/ns/prov

call sd namespace add --prefix prov --uri "https://www.w3.org/ns/prov"
REM call sd data model --named-graph https://www.w3.org/ns/prov prov-o.ttl
2 changes: 2 additions & 0 deletions load.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REM sd data add -- build-local\tests\at\activities\aggregation\example_1_1.ttl
sd data add -- _sources\activities\derivation\examples\path.ttl
1,321 changes: 1,321 additions & 0 deletions prov-o.ttl

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions queries/getActivity.sparql
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
prefix prov: <http://www.w3.org/ns/prov#>
SELECT ?A ?p ?plabel ?o ?olabel
SELECT DISTINCT $activity ?p ?plabel ?o ?olabel
WHERE {
$entity prov:wasGeneratedBy ?A .
?A ?p ?o .
$activity ?p ?o .
OPTIONAL { ?p rdfs:label ?plabel }
OPTIONAL { ?o rdfs:label ?olabel }
OPTIONAL {
FILTER(isBlank(?o))
?o rdfs:label ?blankNodeLabel .
}

}
9 changes: 9 additions & 0 deletions queries/getActivity4Entity.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
prefix prov: <http://www.w3.org/ns/prov#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?A ?p ?plabel ?o ?olabel
WHERE {
$entity prov:wasGeneratedBy ?A .
?A ?p ?o .
OPTIONAL { ?p rdfs:label ?plabel }
OPTIONAL { ?o rdfs:label ?olabel }
}
12 changes: 12 additions & 0 deletions queries/getAgent.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix prov: <http://www.w3.org/ns/prov#>
SELECT $agent ?p ?plabel ?o ?olabel
WHERE {
$agent ?p ?o .
OPTIONAL { ?p rdfs:label ?plabel }
OPTIONAL { ?o rdfs:label ?olabel }
OPTIONAL {
FILTER(isBlank(?o))
?o rdfs:label ?blankNodeLabel .
}

}
14 changes: 14 additions & 0 deletions queries/getDimDesc.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prefix dim: <https://surroundaustralia.com/models/datadimensions/>
prefix sdo: <https://schema.org/>
SELECT DISTINCT ?targetRange ?name?order ?dimRange
WHERE
{
$object dim:value ?dv .
OPTIONAL{ $object dim:targetRange ?targetRange }
?dv dim:dimension ?d .
?d rdfs:label ?name .

OPTIONAL { ?d dim:order ?order }
OPTIONAL { ?d dim:maxValue ?dimRange }

}
13 changes: 13 additions & 0 deletions queries/getDimValues.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
prefix dim: <https://surroundaustralia.com/models/datadimensions/>
prefix sdo: <https://schema.org/>
SELECT ?d ?v
WHERE
{
$object dim:value ?dv .
?dv sdo:value ?v .
?dv dim:dimension/rdfs:label ?d .
# ?d rdfs:label ?l
# ?dc dim:dimension/dim:order ?order .
# ?dc dim:dimension/dim:order ?order .
}

10 changes: 8 additions & 2 deletions queries/getEntity.sparql
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
prefix prov: <http://www.w3.org/ns/prov#>
SELECT $entity ?p ?plabel ?o ?olabel
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
SELECT $entity ?p ?plabel ?o ?olabel ?blankNodeLabel
WHERE {
$entity ?p ?o .
OPTIONAL { ?p rdfs:label ?plabel }
OPTIONAL { ?o rdfs:label ?olabel }

FILTER ( ?p != geo:hasGeometry )
OPTIONAL {
FILTER(isBlank(?o))
?o rdfs:label ?blankNodeLabel .
}
}
12 changes: 12 additions & 0 deletions queries/getObject.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix prov: <http://www.w3.org/ns/prov#>
SELECT $object ?p ?plabel ?o ?olabel
WHERE {
$object ?p ?o .
OPTIONAL { ?p rdfs:label ?plabel }
OPTIONAL { ?o rdfs:label ?olabel }
OPTIONAL {
FILTER(isBlank(?o))
?o rdfs:label ?blankNodeLabel .
}

}
9 changes: 9 additions & 0 deletions queries/getSpatialEntity.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
prefix prov: <http://www.w3.org/ns/prov#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
SELECT $entity ?label ?geojson ?wkt
WHERE {
$entity geo:hasGeometry ?g .
OPTIONAL { ?g geo:asGeoJSON ?geojson }
OPTIONAL { ?g geo:asWKT ?wkt }
OPTIONAL { $entity rdfs:label ?label }
}
3 changes: 2 additions & 1 deletion queries/manifest.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
filename,uri,context,model
../_sources/activities/derivation/examples/a-plus-b.ttl,tag:prov:a-plus-b,tag:prov-demo,tag:prov-demo-model
../_sources/activities/derivation/examples/a-plus-b.ttl,tag:prov:a-plus-b,tag:prov-demo,tag:prov-demo-model
../_sources/activities/derivation/examples/path.ttl,tag:prov:path,tag:prov-demo,tag:prov-demo-model
2 changes: 1 addition & 1 deletion queries/runQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def main():

for pair in pairs:
key, value = pair.split('=')
params[key.strip()] = value.strip()
params["$"+key.strip()] = value.strip()
except:
print(f"No parameters found ({args.params})")
# Process files in the specified directory with the given pattern
Expand Down
6 changes: 3 additions & 3 deletions queries/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def store_query(file_path):
a system:StoredQuery, system:SharedQuery , system:ReasoningQuery ;
system:queryName "{file_base}" ;
system:queryString "{sparql_query}" ;
system:queryCreator "admin" ;
system:queryDatabase "prov-chains" .
system:queryCreator "{username}" ;
system:queryDatabase "{stardog_database}" .
'''

# Send the POST request with Basic Authentication
# Send the PUT request with Basic Authentication
response = requests.put(
stardog_url,
headers=headers,
Expand Down

0 comments on commit e19b460

Please sign in to comment.