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

@ -50,14 +50,38 @@ CONSTRUCT {
#from onto:explain #from onto:explain
where { where {
?record aocat:has_title ?title ;
graph ?g {
#mandatory statements in our model, to be added in all datasources
#?record aocat:has_title ?title ;
# aocat:has_access_rights ?accessRights ; # aocat:has_access_rights ?accessRights ;
aocat:has_creator / aocat:has_name ?contributorName ; # aocat:has_creator / aocat:has_name ?contributorName ;
aocat:has_creator / aocat:has_email ?contributorEmail ; # aocat:has_creator / aocat:has_email ?contributorEmail ;
aocat:has_spatial_coverage ?spatial ; # aocat:has_native_subject / skos:prefLabel ?nativeSbj ;
aocat:has_native_subject / skos:prefLabel ?nativeSbj ; # aocat:has_original_id ?originalId ;
aocat:has_original_id ?originalId ; ?record aocat:has_spatial_coverage ?spatial ;
aocat:has_language / skos:prefLabel ?language . aocat:has_language / skos:prefLabel ?language .
optional {
{
?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 . ?record aocat:has_access_rights ?accessRights .
} }
@ -92,28 +116,46 @@ where {
?record aocat:has_temporal_coverage ?t . ?record aocat:has_temporal_coverage ?t .
?t aocat:until ?until . ?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 .
?collection aocat:was_issued ?issued .
optional {
{
?collection aocat:has_publisher / rdfs:label ?publisherName .
}
union
{
?collection aocat:has_ARIADNE_subject ?archeologicalResourceType .
?archeologicalResourceType skos:prefLabel ?archeologicalResourceTypeName . ?archeologicalResourceType skos:prefLabel ?archeologicalResourceTypeName .
} }
union
{
?collection aocat:has_type / skos:prefLabel ?type .
}
}
#?archeologicalResourceType skos:prefLabel ?archeologicalResourceTypeName .
}
} }
{ {
select * select *
where { where {
?spatial aocat:has_place_name ?spatialPlaceName . ?spatial aocat:has_place_name ?spatialPlaceName .
optional {
{ {
?spatial aocat:has_place_name ?spatialPlaceName .
?spatial aocat:has_latitude ?spatialLocationLat . ?spatial aocat:has_latitude ?spatialLocationLat .
BIND(uri(concat('http://www.myprefix/location/', md5(str(?spatialLocationLat)))) as ?blocation) BIND(uri(concat('http://www.myprefix/location/', md5(str(?spatialLocationLat)))) as ?blocation)
} }
union union
{ {
?spatial aocat:has_place_name ?spatialPlaceName .
?spatial aocat:has_longitude ?spatialLocationLon . ?spatial aocat:has_longitude ?spatialLocationLon .
BIND(uri(concat('http://www.myprefix/location/', md5(str(?spatialLocationLon)))) as ?blocation) BIND(uri(concat('http://www.myprefix/location/', md5(str(?spatialLocationLon)))) as ?blocation)
} }
@ -123,12 +165,11 @@ where {
aocat:has_longitude ?spatialLocationLon . aocat:has_longitude ?spatialLocationLon .
BIND(uri(concat('http://www.myprefix/location/', md5(concat(str(?spatialLocationLat), str(?spatialLocationLon))))) as ?blocation) 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) .
} }
}