Hi Justin,

There's an example that might help:

https://github.com/apache/jena/blob/main/jena-examples/src/main/java/shacl/examples/Shacl02_validateTransaction.java

of org.apache.jena.shacl.GraphValidation.

In general, code inside the transaction action can see the in-progress data. Some SHACL rules nee more than the statement being addedd or removed.


ModelChangedListener are called on the same thread as the change.

ModelChangedListener could signal to the code inside the transaction. Either with a flag if you want to accumulate reports or an exception. And if using datasets.executeWrite, an uncaught exception will abort the transaction.

It does depend on the storage supporting proper abort.  A dataset of

DatasetFactory.createTxnMem();

does in-memory and TDB(1|2) do.

It is the general "holds any graph" datasets that don't necessarily support abort in the way as shown by Dataset.supportsTransactionAbort().

    HTH
    Andy

On 29/12/2022 17:00, Justin wrote:
Hi all,

Is it possible to register a ModelChangedListener on a Model such that
updates to the Model could be aborted by the ModelChangedListener?
>
Basically I'm looking for a way to listen for or intercept Model commits so
that I can run some validation code or SPARQL *before* the commit is
allowed to happen (and potentially abort the commit).

Thanks,
Justin

Reply via email to