Hi Andy,

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

Great. That's what I need as well.

Thanks! You've given me some ideas.

Justin

On Fri, Dec 30, 2022 at 5:15 AM Andy Seaborne <[email protected]> wrote:

> 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