I was wondering if it was possible to create a SPARQL UpdateRequest in Jena by using ARQ Op objects. I would be interested to create programmatically updates like this:
DELETE {?s :predicate <http://example.org#old> }
INSERT {?s :predicate <http://example.org#toAdd>}
WHERE {?s :predicate <http://example.org#old> }
by creating the patterns in the DELETE, INSERT, and WHERE clauses from the ARQ API. So far the only ways I have found to create SPARQL Update requests require to parse a SPARQL string or to create a com.hp.hpl.jena.update.Update object (which uses QuadAcc objects for which I couldn't find examples of use.
My fear is that the management of SPARQL UPDATE requests and the one of SPARQL SELECT queries are separated and that ARQ cannot be used to 'assemble' queries on the fly.
Thanks in advance
I haven't tried this myself, but it looks like creating Update
objects and assembling them into an UpdateRequest
is indeed the way to go.
After a short look, QuadAcc
doesn't seem particularly difficult, just use addTriple()
with triples that contain variables.
The UpdateModify
subclass of Update
looks particularly interesting, it corresponds to the DELETE … INSERT … WHERE
pattern in your example. Unfortunately the WHERE
clause is initialised with an Element
(syntactic representation of a query part) rather than an Op
(algebraic representation).