2

I found some SPARQL query manipulation only for SELECT, ASK, CONSTRUCT https://jena.apache.org/documentation/query/manipulating_sparql_using_arq.html and https://jena.apache.org/documentation/query/algebra.html but could not find anything regarding UPDATE operations

Any examples I can look at?

Thanks.

  • Starting from an [`UpdateRequest`](https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/update/UpdateRequest.html) which is nothing more than an Iterable of [`Update`](https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/update/Update.html) you can access the components depending on the type of the `Update`, see its subclasses via Javadoc, then process their components. – UninformedUser Jan 23 '21 at 11:53
  • Thanks! treated differently than regular queries but still helps. – Guillermo Coscarelli Jan 25 '21 at 14:07

1 Answers1

0

It seems you can use org.apache.jena.sparql.syntax.syntaxtransform.UpdateTransformOps

I have the same requirement and as the documentation is super limited here, I'm still using debug mode to see how I can achieve my goal. You can inspire from this, if you have a better solution I would be very interested.

Something like that:

public class OpPermissionTransformer extends ElementTransformCopyBase {
    @Override
    public Element transform(ElementNamedGraph el, Node gn, Element elt1) {
       return elt1;
    }

}
 UpdateRequest modified = UpdateTransformOps.transform(update, new OpPermissionTransformer(), new NodeTransformExpr(n -> { 
    // modify the node as you wish
    return n;
});