Skip to content

Commit

Permalink
Further CQL integration
Browse files Browse the repository at this point in the history
  • Loading branch information
recalcitrantsupplant committed May 23, 2024
1 parent 9d69657 commit 98f2c30
Show file tree
Hide file tree
Showing 20 changed files with 266 additions and 238 deletions.
24 changes: 12 additions & 12 deletions demo/prez-v4-backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"
services:

fuseki:
image: "ghcr.io/zazuko/fuseki-geosparql:v3.3.0"
image: "ghcr.io/zazuko/fuseki-geosparql:v3.3.1"
ports:
- "3030:3030"
volumes:
Expand All @@ -20,14 +20,14 @@ services:
timeout: 10s
retries: 3

prez:
build:
context: ../../
dockerfile: ./Dockerfile
ports:
- "8000:8000"
environment:
SPARQL_ENDPOINT: 'http://fuseki:3030/dataset'
depends_on:
fuseki:
condition: service_healthy
# prez:
# build:
# context: ../../
# dockerfile: ./Dockerfile
# ports:
# - "8000:8000"
# environment:
# SPARQL_ENDPOINT: 'http://fuseki:3030/dataset'
# depends_on:
# fuseki:
# condition: service_healthy
2 changes: 0 additions & 2 deletions prez/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
NoProfilesException,
)
from prez.repositories import RemoteSparqlRepo, PyoxigraphRepo, OxrdflibRepo
from prez.routers.cql import router as cql_router
from prez.routers.identifier import router as identifier_router
from prez.routers.management import router as management_router
from prez.routers.ogc_router import router as ogc_records_router
Expand Down Expand Up @@ -59,7 +58,6 @@
}
)

app.include_router(cql_router)
app.include_router(management_router)
app.include_router(sparql_router)
app.include_router(search_router)
Expand Down
11 changes: 11 additions & 0 deletions prez/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ async def get_focus_node(


def handle_special_cases(ep_uri, focus_node):
"""
uris provided to the nodeshapes are those in prez/reference_data/endpoints/endpoint_nodeshapes.ttl
"""
if ep_uri == EP["system/object"]:
return NodeShape(
uri=URIRef("http://example.org/ns#Object"),
Expand All @@ -269,6 +272,13 @@ def handle_special_cases(ep_uri, focus_node):
kind="endpoint",
focus_node=focus_node,
)
elif ep_uri == EP["extended-ogc-records/cql-get"]:
return NodeShape(
uri=URIRef("http://example.org/ns#CQL"),
graph=endpoints_graph_cache,
kind="endpoint",
focus_node=focus_node,
)


async def get_endpoint_nodeshapes(
Expand All @@ -285,6 +295,7 @@ async def get_endpoint_nodeshapes(
ep_uri = endpoint_uri_type[0]
if ep_uri in [
EP["system/object"],
EP["extended-ogc-records/cql-get"],
EP["extended-ogc-records/top-concepts"],
EP["extended-ogc-records/narrowers"],
]:
Expand Down
33 changes: 0 additions & 33 deletions prez/queries/object.py

This file was deleted.

5 changes: 5 additions & 0 deletions prez/reference_data/endpoints/endpoint_metadata.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ sys:object
ont:relevantShapes ex:Profiles ;
.

ogce:cql-get
a ont:ListingEndpoint ;
ont:relevantShapes ex:CQL ;
.

ogce:catalog-listing
a ont:ListingEndpoint ;
ont:relevantShapes ex:Catalogs ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,10 @@ ex:Narrowers
a sh:NodeShape ;
sh:targetClass skos:Concept ;
ont:hierarchyLevel 1 ;
.
.

ex:CQL
a sh:NodeShape ;
sh:targetClass rdfs:Resource ;
ont:hierarchyLevel 1 ;
.
28 changes: 28 additions & 0 deletions prez/reference_data/profiles/prez_default_profiles.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX prez: <https://prez.dev/>
PREFIX prof: <http://www.w3.org/ns/dx/prof/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX reg: <http://purl.org/linked-data/registry#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
Expand Down Expand Up @@ -49,6 +51,32 @@ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
shext:bnode-depth 2 ;
.


<https://prez.dev/profile/cqlgeo>
a prof:Profile , prez:ListingProfile;
dcterms:identifier "cqlgeo"^^xsd:token ;
dcterms:description "A CQL profile targeted towards listing CQL results, including geospatial information." ;
dcterms:title "CQL Geo profile" ;
altr-ext:constrainsClass rdfs:Resource ;
altr-ext:hasDefaultResourceFormat "text/anot+turtle" ;
altr-ext:hasResourceFormat "application/ld+json" ,
"application/ld+json" ,
"application/anot+ld+json" ,
"application/rdf+xml" ,
"text/anot+turtle" ,
"text/turtle" ;
sh:property [
sh:minCount 0 ;
sh:path (
sh:union (
rdf:type
( geo:hasGeometry geo:asWKT )
)
)
] ;
.


<https://w3id.org/profile/mem>
a prof:Profile , prez:ListingProfile ;
dcterms:description "A very basic data model that lists the members of container objects only, i.e. not their other properties" ;
Expand Down
5 changes: 5 additions & 0 deletions prez/routers/ogc_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
summary="List Profiles",
name=EP["system/profile-listing"],
)
@router.get(
path="/cql",
summary="CQL GET endpoint",
name=OGCE["cql-get"],
)
@router.get(
"/catalogs",
summary="Catalog Listing",
Expand Down
2 changes: 1 addition & 1 deletion prez/services/connegp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _compose_select_query(self) -> str:
VALUES ?base_class {{ dcat:Dataset geo:FeatureCollection geo:Feature
skos:ConceptScheme skos:Concept skos:Collection
dcat:Catalog rdf:Resource dcat:Resource prof:Profile prez:SPARQLQuery
prez:SearchResult prez:CQLObjectList prez:QueryablesList prez:Object }}
prez:SearchResult prez:CQLObjectList prez:QueryablesList prez:Object rdfs:Resource }}
?profile altr-ext:constrainsClass ?class ;
altr-ext:hasResourceFormat ?format ;
dcterms:title ?title .\
Expand Down
14 changes: 9 additions & 5 deletions prez/services/listings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,20 @@ async def listing_function(
order_by=order_by,
order_by_direction=order_by_direction,
)
profile_tss_list = profile_nodeshape.tss_list
profile_construct_triples = None
if profile_tss_list:
profile_construct_triples = ConstructTriples.from_tss_list(profile_tss_list)

# merge subselect and profile triples same subject (for construct triples)
construct_tss_list = []
subselect_tss_list = subselect_kwargs.pop("construct_tss_list")
if subselect_tss_list:
construct_tss_list.extend(subselect_tss_list)
if profile_nodeshape.tss_list:
construct_tss_list.extend(profile_nodeshape.tss_list)

queries = []
main_query = PrezQueryConstructor(
construct_tss_list=construct_tss_list,
profile_triples=profile_nodeshape.tssp_list,
profile_gpnt=profile_nodeshape.gpnt_list,
profile_construct_triples=profile_construct_triples,
**subselect_kwargs,
)
queries.append(main_query.to_string())
Expand Down
7 changes: 1 addition & 6 deletions prez/services/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,10 @@ async def object_function(
**none_kwargs,
)

profile_tss_list = profile_nodeshape.tss_list
profile_construct_triples = None
if profile_tss_list:
profile_construct_triples = ConstructTriples.from_tss_list(profile_tss_list)

query = PrezQueryConstructor(
profile_triples=profile_nodeshape.tssp_list,
profile_gpnt=profile_nodeshape.gpnt_list,
profile_construct_triples=profile_construct_triples
construct_tss_list=profile_nodeshape.tss_list
).to_string()

if pmts.requested_mediatypes[0][0] == "application/sparql-query":
Expand Down
4 changes: 4 additions & 0 deletions prez/services/query_generation/concept_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ def __init__(
def construct_triples(self):
return self.construct_template.construct_triples

@property
def tss_list(self):
return [self.construct_template.construct_triples.triples]

@property
def inner_select_vars(self):
return self.where_clause.group_graph_pattern.content.graph_patterns_or_triples_blocks[0].content. \
Expand Down
Loading

0 comments on commit 98f2c30

Please sign in to comment.