On 07/07/14 13:52, Olivier Torres [intactile DESIGN] wrote:
Hi,
i want to bind some models as follows :
Ontology Model (Business Ontology) -> Instances Model (Business instances)
->
IHM Model (IHM Ontology + IHM Rules)
Communication Model (External Ontology)
Only the last model needs a reasoner, others are only data models.
When I add or remove a statement in a data model, i expect that it will be
propagated to the right.
That won't happen automatically.
So if i add statement in the Instances Model i want to be informed using search
methods on the IHM Model but also to be notified by subscription
(IhmModel.register(ModelChangeListener)). The last model should also add or
remove its deductions according to propagated data.
I’ve tried an implementation based on ModelFactory.defaultModel() for de data
models, ModelFactory.createInfModel(polyReasoner, dataModel) for the inference
model, Union and MultiUnion graphs:
Model ontologyDataModel = ModelFactory.createDefaultModel();
Model instancesDataModel = ModelFactory.createDefaultModel();
Model instancesModel = ModelFactory.createUnion(instancesDataModel,
ontologyDataModel);
Model comDataModel = ModelFactory.createDefaultModel();
Model ihmDataModel = ModelFactory.createDefaultModel();
Model ihmUnionModel = ModelFactory.createModelForGraph(new
MultiUnion(graphs)); // graphs of ihmDataModel, instancesModel and comDataModel
Reasoner ihmReasoner = createReasonerFromStrings(new String[] {
"[rule: (subject predicate value1) -> (subject predicate
inf1)]",
"[rule: (subject predicate value2) -> (subject predicate
inf2)]" });
Model ihmModel = ModelFactory.createInfModel(ihmReasoner,
ihmUnionModel);
I add the triple (subject, predicate, value1) in the Instances Data Model and
(subject, predicate, value2) in the Communication Data Model.
I have two problems :
1. When i remove (subject, predicate, value1) from the Instances Data Model
and (subject, predicate, value2) from the Communication Data Model then the
inferences (subject, predicate, inf1) and (subject, predicate, inf2) are not
removed from the IHM Model,
An InfModel expects you to make changes by add/remove to the InfModel.
It will then store those changes in the underlying model plus update the
deductions.
If you make changes directly to the underlying model then the InfModel
doesn't see them. However, you can cause it to look again by calling
rebind().
So you either need to trigger a rebind after each change or you need to
modify your structure so that changes are made to the InfModel directly.
Note that with MultiUnions you can set which graph is receives the
updates so you route updates down your tree (rather than having changes
propagate upwards).
2. I Can’t subscribe to the IHM Model to be notified of added and removed
statements.
I don't know enough about how ModelChangeListeners work with unions to
comment on that - hopefully someone else can help with this bit.
Dave