From 49d698a532c6e0064e8178de0460e53b9daf85b7 Mon Sep 17 00:00:00 2001 From: Enrico Ottonello Date: Thu, 22 Apr 2021 16:51:44 +0200 Subject: [PATCH] optimized query using named graph --- .../sparql/read_record_data_template.sparql | 71 ++++++++++++++----- 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql b/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql index af6b0db..0411ea4 100644 --- a/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql +++ b/dnet-ariadneplus-graphdb-publisher/src/main/resources/eu/dnetlib/ariadneplus/sparql/read_record_data_template.sparql @@ -68,12 +68,8 @@ CONSTRUCT { %record aoprop:description ?description . %record aoprop:language ?language . } -from -from -from -from -from where { + graph { %record aocat:has_language / skos:prefLabel ?language . %record aocat:has_original_id ?originalId . %record aocat:is_part_of ?partOf . @@ -81,12 +77,6 @@ where { ?creator aocat:has_name ?creatorName . %record aocat:has_title ?title . %record aocat:has_type / skos:prefLabel ?resourceType . - %record aocat:has_native_subject ?nativeSubject . - ?nativeSubject skos:prefLabel ?nativeSubjectPrefLabel . - optional { - %record aocat:has_derived_subject ?derivedSubject . - ?derivedSubject skos:prefLabel ?derivedSubjectPrefLabel . - } optional { ?creator aocat:has_email ?creatorEmail . } @@ -99,23 +89,40 @@ where { optional { %record aocat:has_landing_page / rdfs:label ?landingPage . } - optional { + } + + optional { + graph { %record aocat:has_temporal_coverage ?temporalNative . - ?temporalNative aocat:has_native_period / skos:prefLabel ?temporalNativePeriodName . + ?temporalNative aocat:has_native_period ?nativeLabel . + ?nativeLabel skos:prefLabel ?temporalNativePeriodName . + } + graph { optional { ?temporalNative aocat:from ?temporalNativeFrom . ?temporalNative aocat:until ?temporalNativeUntil . } } - optional { - %record aocat:has_temporal_coverage ?temporal . - ?temporal aocat:has_period / skos:prefLabel ?temporalPeriodName . - optional { + } + + + optional { + graph { + %record aocat:has_temporal_coverage ?temporal . + } + graph { + ?temporal aocat:has_period ?label . + graph { + ?label skos:prefLabel ?temporalPeriodName . + } + optional { ?temporal aocat:from ?temporalFrom . ?temporal aocat:until ?temporalUntil . - } + } } + } + graph { { select * where { @@ -146,7 +153,9 @@ where { } } } + } + graph { { select * where { @@ -170,5 +179,31 @@ where { } } } + } + + graph { + { + select * + where { + %record aocat:has_native_subject ?nativeSubject . + ?nativeSubject skos:prefLabel ?nativeSubjectPrefLabel . + } + } + } + + graph { + { + select * + where { + optional { + %record aocat:has_derived_subject ?derivedSubject . + graph { + ?derivedSubject skos:prefLabel ?derivedSubjectPrefLabel . + } + } + } + } + } + BIND (lang(?derivedSubjectPrefLabel) as ?aatSubjectsLang) } \ No newline at end of file