From d01e9df08a02f522b4dc2b588e6a41e2816fafb1 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 18 Aug 2023 10:24:44 +1000 Subject: [PATCH] Add prez:endpointComponentURI for parents in endpoints such that the URIs of parents are included in the response, and get annotated, such that labels are available for breadcrumbs. Update spaceprez profile to include dcterms:title for the OAS profile. --- .../profiles/spaceprez_default_profiles.ttl | 1 + prez/routers/object.py | 11 +++++++++++ prez/sparql/objects_listings.py | 8 ++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/prez/reference_data/profiles/spaceprez_default_profiles.ttl b/prez/reference_data/profiles/spaceprez_default_profiles.ttl index 19550ed8..fdde1cc2 100644 --- a/prez/reference_data/profiles/spaceprez_default_profiles.ttl +++ b/prez/reference_data/profiles/spaceprez_default_profiles.ttl @@ -66,6 +66,7 @@ prez:SpacePrezProfile dcterms:description "The OGC API Features specifies the behavior of Web APIs that provide access to features in a dataset in a manner independent of the underlying data store." ; dcterms:identifier "oai"^^xsd:token ; dcterms:title "OGC API Features" ; + altr-ext:hasLabelPredicate dcterms:title ; altr-ext:constrainsClass dcat:Dataset , geo:FeatureCollection , diff --git a/prez/routers/object.py b/prez/routers/object.py index 4ccc73ad..ddfb27ab 100644 --- a/prez/routers/object.py +++ b/prez/routers/object.py @@ -260,6 +260,17 @@ def generate_system_links_object( Literal(endpoint), ) ) + # TODO include the actual relationships between the object and the parent objects in the graph + for ep_result in relationship_results: + for k, v in ep_result.items(): + if k != "endpoint": + internal_links_graph.add( + ( + URIRef(object_uri), + PREZ["endpointComponentURI"], + URIRef(v["value"]), + ) + ) # def generate_system_links_non_object( diff --git a/prez/sparql/objects_listings.py b/prez/sparql/objects_listings.py index 5988d12d..13ef4658 100644 --- a/prez/sparql/objects_listings.py +++ b/prez/sparql/objects_listings.py @@ -888,16 +888,16 @@ def generate_relationship_query( for endpoint, relations in endpoint_to_relations.items(): subquery = f"""{{ SELECT ?endpoint {" ".join(["?parent_" + str(i+1) for i, _ in enumerate(relations)])} WHERE {{\n BIND("{endpoint}" as ?endpoint)\n""" - previous_uri = f"<{uri}>" + uri_str = f"<{uri}>" for i, relation in enumerate(relations): predicate, direction = relation parent = "?parent_" + str(i + 1) if predicate: if direction == Literal("parent_to_focus"): - subquery += f"{parent} <{predicate}> {previous_uri} .\n" + subquery += f"{parent} <{predicate}> {uri_str} .\n" else: # assuming the direction is "focus_to_parent" - subquery += f"{previous_uri} <{predicate}> {parent} .\n" - previous_uri = parent + subquery += f"{uri_str} <{predicate}> {parent} .\n" + uri_str = parent subquery += "}}" subqueries.append(subquery)