added optional surrounding union conditions, in case all those conditions do not match any statements

This commit is contained in:
Enrico Ottonello 2020-02-11 12:04:45 +01:00
parent 911ea12ac3
commit ae91617d1b
1 changed files with 123 additions and 82 deletions

View File

@ -5,26 +5,26 @@ PREFIX mine: <http://www.myprefix/>
PREFIX onto: <http://www.ontotext.com/> PREFIX onto: <http://www.ontotext.com/>
CONSTRUCT { CONSTRUCT {
?record mine:resourcetype "AriadneCatalogEntry" . ?record mine:resourcetype "AriadneCatalogEntry" .
?record mine:identifier ?record . ?record mine:identifier ?record .
?record mine:publisher ?x . ?record mine:publisher ?x .
?x a mine:AgentInfo . ?x a mine:AgentInfo .
?x mine:name ?publisherName . ?x mine:name ?publisherName .
?x mine:type ?publisherType . ?x mine:type ?publisherType .
?archeologicalResourceType a mine:archeologicalResourceType . ?archeologicalResourceType a mine:archeologicalResourceType .
?record mine:archeologicalResourceType ?archeologicalResourceType . ?record mine:archeologicalResourceType ?archeologicalResourceType .
?archeologicalResourceType mine:name ?archeologicalResourceTypeName . ?archeologicalResourceType mine:name ?archeologicalResourceTypeName .
?record mine:issued ?issued . ?record mine:issued ?issued .
?record mine:resourceType ?resourceType . ?record mine:resourceType ?resourceType .
?record mine:modified ?modified . ?record mine:modified ?modified .
?record mine:nativeSubject ?ns . ?record mine:nativeSubject ?ns .
?ns a mine:NativeSubject . ?ns a mine:NativeSubject .
?ns mine:prefLabel ?nativeSbj . ?ns mine:prefLabel ?nativeSbj .
?spatial a mine:Spatial . ?spatial a mine:Spatial .
?record mine:spatial ?spatial . ?record mine:spatial ?spatial .
?spatial mine:placeName ?spatialPlaceName . ?spatial mine:placeName ?spatialPlaceName .
?spatial mine:location ?blocation . ?spatial mine:location ?blocation .
?blocation a mine:AriadneGeoPoint . ?blocation a mine:AriadneGeoPoint .
?blocation mine:lat ?spatialLocationLat . ?blocation mine:lat ?spatialLocationLat .
?blocation mine:lon ?spatialLocationLon . ?blocation mine:lon ?spatialLocationLon .
?record mine:accessPolicy ?accessPolicy . ?record mine:accessPolicy ?accessPolicy .
@ -33,74 +33,113 @@ CONSTRUCT {
?record mine:accessRights ?accessRights . ?record mine:accessRights ?accessRights .
?record mine:description ?description . ?record mine:description ?description .
?record mine:contributor ?contributor . ?record mine:contributor ?contributor .
?contributor a mine:AgentInfo . ?contributor a mine:AgentInfo .
?contributor mine:name ?contributorName . ?contributor mine:name ?contributorName .
?contributor mine:email ?contributorEmail . ?contributor mine:email ?contributorEmail .
?contributor mine:type ?contributorType . ?contributor mine:type ?contributorType .
?record mine:originalId ?originalId . ?record mine:originalId ?originalId .
?record mine:temporal ?t . ?record mine:temporal ?t .
?t a mine:AriadneTemporal . ?t a mine:AriadneTemporal .
?t mine:periodName ?temporalPeriodName . ?t mine:periodName ?temporalPeriodName .
?t mine:from ?from . ?t mine:from ?from .
?t mine:until ?until . ?t mine:until ?until .
?record mine:language ?language . ?record mine:language ?language .
?record mine:partOf ?collection . ?record mine:partOf ?collection .
} }
#from onto:explain #from onto:explain
where { where {
?record aocat:has_title ?title ;
# aocat:has_access_rights ?accessRights ; graph ?g {
aocat:has_creator / aocat:has_name ?contributorName ; #mandatory statements in our model, to be added in all datasources
aocat:has_creator / aocat:has_email ?contributorEmail ; #?record aocat:has_title ?title ;
aocat:has_spatial_coverage ?spatial ; # aocat:has_access_rights ?accessRights ;
aocat:has_native_subject / skos:prefLabel ?nativeSbj ; # aocat:has_creator / aocat:has_name ?contributorName ;
aocat:has_original_id ?originalId ; # aocat:has_creator / aocat:has_email ?contributorEmail ;
aocat:has_language / skos:prefLabel ?language . # aocat:has_native_subject / skos:prefLabel ?nativeSbj ;
{ # aocat:has_original_id ?originalId ;
?record aocat:has_access_rights ?accessRights . ?record aocat:has_spatial_coverage ?spatial ;
} aocat:has_language / skos:prefLabel ?language .
union optional {
{ {
?record aocat:has_description ?description . ?record aocat:has_original_id ?originalId .
}
union
{
?record aocat:has_native_subject / skos:prefLabel ?nativeSbj .
}
union
{
?record aocat:has_creator / aocat:has_name ?contributorName .
}
union
{
?record aocat:has_title ?title .
}
union
{
?record aocat:has_creator / aocat:has_email ?contributorEmail .
}
union
{
?record aocat:has_access_rights ?accessRights .
}
union
{
?record aocat:has_description ?description .
}
union
{
?record aocat:has_access_policy / rdfs:label ?accessPolicy .
}
union
{
?record aocat:has_landing_page / rdfs:label ?landingPage .
}
union
{
?record aocat:is_part_of ?collection .
}
union
{
?record aocat:has_temporal_coverage ?t .
?t aocat:has_period / skos:prefLabel ?temporalPeriodName .
}
union
{
?record aocat:has_temporal_coverage ?t .
?t aocat:from ?from .
}
union
{
?record aocat:has_temporal_coverage ?t .
?t aocat:until ?until .
}
} }
union
{
?record aocat:has_access_policy / rdfs:label ?accessPolicy .
}
union
{
?record aocat:has_landing_page / rdfs:label ?landingPage .
}
union
{
?record aocat:is_part_of ?collection .
}
union
{
?record aocat:has_temporal_coverage ?t .
?t aocat:has_period / skos:prefLabel ?temporalPeriodName .
}
union
{
?record aocat:has_temporal_coverage ?t .
?t aocat:from ?from .
}
union
{
?record aocat:has_temporal_coverage ?t .
?t aocat:until ?until .
}
{ {
select * select *
where { where {
?collection aocat:has_publisher / rdfs:label ?publisherName ; #mandatory statements in our model, to be added in all datasources
aocat:has_ARIADNE_subject ?archeologicalResourceType ; #?collection aocat:has_publisher / rdfs:label ?publisherName ;
aocat:was_issued ?issued ; # aocat:has_ARIADNE_subject ?archeologicalResourceType ;
aocat:has_type / skos:prefLabel ?type . # aocat:has_type / skos:prefLabel ?type .
?archeologicalResourceType skos:prefLabel ?archeologicalResourceTypeName . ?collection aocat:was_issued ?issued .
optional {
{
?collection aocat:has_publisher / rdfs:label ?publisherName .
}
union
{
?collection aocat:has_ARIADNE_subject ?archeologicalResourceType .
?archeologicalResourceType skos:prefLabel ?archeologicalResourceTypeName .
}
union
{
?collection aocat:has_type / skos:prefLabel ?type .
}
}
#?archeologicalResourceType skos:prefLabel ?archeologicalResourceTypeName .
} }
} }
@ -108,27 +147,29 @@ where {
select * select *
where { where {
?spatial aocat:has_place_name ?spatialPlaceName . ?spatial aocat:has_place_name ?spatialPlaceName .
{ optional {
?spatial aocat:has_latitude ?spatialLocationLat . {
BIND(uri(concat('http://www.myprefix/location/', md5(str(?spatialLocationLat)))) as ?blocation) ?spatial aocat:has_place_name ?spatialPlaceName .
} ?spatial aocat:has_latitude ?spatialLocationLat .
union BIND(uri(concat('http://www.myprefix/location/', md5(str(?spatialLocationLat)))) as ?blocation)
{ }
?spatial aocat:has_longitude ?spatialLocationLon . union
BIND(uri(concat('http://www.myprefix/location/', md5(str(?spatialLocationLon)))) as ?blocation) {
} ?spatial aocat:has_place_name ?spatialPlaceName .
union ?spatial aocat:has_longitude ?spatialLocationLon .
{ BIND(uri(concat('http://www.myprefix/location/', md5(str(?spatialLocationLon)))) as ?blocation)
?spatial aocat:has_latitude ?spatialLocationLat ; }
aocat:has_longitude ?spatialLocationLon . union
BIND(uri(concat('http://www.myprefix/location/', md5(concat(str(?spatialLocationLat), str(?spatialLocationLon))))) as ?blocation) {
} ?spatial aocat:has_latitude ?spatialLocationLat ;
aocat:has_longitude ?spatialLocationLon .
BIND(uri(concat('http://www.myprefix/location/', md5(concat(str(?spatialLocationLat), str(?spatialLocationLon))))) as ?blocation)
} }
} }
}
}
BIND("organization" as ?contributorType) . BIND("organization" as ?contributorType) .
BIND("organization" as ?publisherType) . BIND("organization" as ?publisherType) .
}
} }