samedi 29 janvier 2022

How to customize Jena ARQ query engine to add additional triple pattern

Given the following triples describe Forklift1 location at the different times:

:forklift1 
   :location :station1, :dockdoor1;
   :9305fc5f-d43d :station1;
   :a4e9-2bcd5b97 :dockdoor1;
  .
:9305fc5f-d43d a :location;
   :createdDate "2022-01-02T10:00:00.000-05:00"^^xsd:dateTime; 
   :expiryDate "2022-01-03T14:00:00.000-05:00"^^xsd:dateTime; 
  .
:a4e9-2bcd5b97 a :location;
   :createdDate "2022-01-03T14:00:00.000-05:00"^^xsd:dateTime; 
  .

To retrieve Forklift1's current location, a SPARQL query is:

select ?o where { 
    :forklift1 :location ?o 
    optional{:forklift1 ?px ?o. ?px a :location. optional{?px :createdDate ?createdDate} optional {?px :expiryDate ?expiryDate}}
    filter (!bound(?expiryDate)) 
  }

result :dockdoor1

My goal is to make Query Engine return the same result but with a much simpler query:

select ?s where { 
    :forklift1 :location ?o.
}

result :dockdoor1

I am using Jena TBD + ARQ; I read some documents, it can be done by customizing ARQ Query Engine; for each Triple pattern :forklift1 :location ?o, to programmatically add the new property instance pattern optional{:forklift1 ?px ?o. ?px a :location. optional{?px :createdDate ?createdDate} optional {?px :expiryDate ?expiryDate}} filter (!bound(?expiryDate)).

Does anyone know how to do this? Your help will move my work forward!

Aucun commentaire:

Enregistrer un commentaire