0

I am managing a named graph (multiple resources per named graph pattern) and needs to update the named graph for any changes for versioning graphs.

To start with, I have a current version of the named graph.

problem statement: whenever I receive a delta turtle file (ttl will have only the changed triples), a new version named graph with delta change incorporated (current version + delta) has to be created. named graph versions diagram

**V1 named graph**
prefix ex: http://example.org/def/
prefix id: http://example.org/id/
prefix graph: <http://example.org/graph/>

id:a ex:hasLabel "a" graph:v1 .
id:b ex:hasLabel "b" graph:v1.
id:b ex:hasChild id:d graph:v1.
id:c ex:hasLabel "c" graph:v1
id:c ex:hasChild id:d graph:v1 .
id:d ex:hasLabel "d" graph:v1.

**DELTA file**
id:b ex:hasLabel "B".
id:c ex:hasChild id:e .
id:e ex:hasLabel "e" .

**Expected V2 Named graph with the delta change incorporated**
id:a ex:hasLabel "a" graph:v2.
id:b ex:hasLabel "B" graph:v2.
id:b ex:hasChild id:d graph:v2.
id:c ex:hasLabel "c" graph:v2.
id:c ex:hasChild id:d graph:v2.
id:d ex:hasLabel "d" graph:v2.
id:c ex:hasChild id:e graph:v2.
id:e ex:hasLabel "e" graph:v2.

I POSTed named graph v1 to a new named graph V2. Tried HTTP PUT and PATCH to update, but it is just replacing it with the delta file (I need to keep unchanged nodes in new named graph).

Is it possible to do it using HTTP PATCH as I read in SPARQL 1.1 Graph Store HTTP Protocol :

With PATCH, however, the enclosed entity contains a set of instructions describing how the RDF graph content residing on the origin server should be modified to produce a new version.

Appreciate if anyone can give me some pointers or ideas to reach the solution. Thanks.

Pam
  • 1
  • 1
  • Which triple store are you using? PUT means "replace with new contents" - i.e old contents re lost. POST is "append" which for an unordered set of triples (a graph) means "add triples". – AndyS Jul 26 '21 at 13:05
  • There are change formats for RDF; there is no standard one. See for example https://afs.github.io/rdf-delta/rdf-patch.html which can record changes for any graph (insert disclaimer). There is a version of Apache jena with PATCH support in the "RDF delta" project. – AndyS Jul 26 '21 at 13:10
  • Thanks @AndyS. I am using Ontotext GraphDB trial version for the POC. – Pam Jul 27 '21 at 13:08
  • You might also consider SPARQL Update, specifically `INSERT DATA` and `DELETE DATA`. – AndyS Jul 27 '21 at 17:47
  • I thought about it. But in my delta file - in come cases, triples are new (new relations) - which has to be inserted, some cases triples need to be updated(delete existing and insert). I don't have the additions(A) and deletions(D) specified as in the RDF-PATCH example. Is it even possible to write a general set of SPARQL or GSP operations which works for any delta file? – Pam Jul 27 '21 at 22:46
  • Except for blank nodes, yes. A SPARQL Update request to the server can be a number of "INSERT DATA {...}; DELETE DATA {...};INSERT DATA { ....}" all in one go separated by ";" – AndyS Jul 28 '21 at 10:04
  • I think the issue is with my delta file. Either it should have a Concise Bounded Description of the resource's present state than just the updated triple or operation (A, D) has to be specified along with the triple. – Pam Jul 30 '21 at 04:07
  • What does this have to do with Semantic Versioning? – jwdonahue Jul 31 '21 at 18:55
  • @jwdonahue, sorry. Removed the tag. – Pam Aug 01 '21 at 23:17

0 Answers0