Thanks to ModelChangedListener, I can monitor changes in a Model
as explained in Jena documentation (Event handling in Jena).
Model m = ModelFactory.createDefaultModel();
ModelChangedListener L = new MyListener();
m.register(L);
However, in my project, I want to monitor a Dataset
for changes to run a code after something occurred in the default graph or one of the named graphes of the Dataset
.
What I want to do is simply triggering events after executing such a query against a Dataset
:
PREFIX d: <http://learningsparql.com/ns/data#>
PREFIX dm: <http://learningsparql.com/ns/demo#>
INSERT DATA
{
d:x dm:tag "one" .
d:x dm:tag "two" .
GRAPH d:g1
{
d:x dm:tag "three" .
d:x dm:tag "four" .
}
}
to detect that "one" "two" were added to the default graph, and "three" "four" where added to g1.
With this code, I can't even detect changes happening in the default graph of the Dataset
, let alone detecting changes in named graphs.
Dataset ds = RDFDataMgr.loadDataset(ONTOLOGY_PATH);
Model defaultModel = ds.getDefaultModel();
ModelChangedListener modelChangedListener = new MyListener();
defaultModel.register(modelChangedListener);