The triple to be deleted was previously inferred and is thus contained
in Model newTriples. newTriples is a subModel of OntModel queryModel,
as required by SPINInferences.run().
I found it a bit challenging to override the ARQFactory.getDataset()
method as ARQFactory is a singleton class. The following seems to
work:
MyARQFactory myARQ = new MyARQFactory();
ARQFactory.set(myARQ);
where
public class MyARQFactory extends ARQFactory {
public Dataset getDataset(Model defaultModel) {
OntModel model = (OntModel) defaultModel;
ExtendedIterator<OntModel> i = model.listSubModels();
while(i.hasNext()) {
System.out.println(i.next().toString());
}
...
Dataset d = DatasetFactory.create(model.getBaseModel());
return d;
}
}
My next problem is that getDataset() passes a Model, while an OntModel
is needed to get the subModels. Casting Model to OntModel is probably
not a good idea. Even if it is possible to get an OntModel, how do I
know which subModel is newTriples?
Basically what I'm trying to do is to remove triples that were
previously inferred (based on a CONSTRUCT SPIN rule), when the triple
which caused the inferment does not exist anymore. This should be
quite a common use case, no?
Thanks a lot for your help!
Gerrit
On Aug 26, 1:44 am, Holger Knublauch <[email protected]> wrote:
> Hi Gerrit,
>
> On Aug 25, 2011, at 6:54 PM, Gerrit wrote:
>
> > I have a spin:UpdateTemplate with a DELETE WHERE clause:
>
> > DELETE {
> > ?this sc:hasMediaPath ?mp .
> > }
> > WHERE {
> > ?this sc:hasMediaPath ?mp .
> > ?mp bonding:mediaSourceSO ?mediaSource .
> > ?mp bonding:mediaOriginator ?device2 .
> > FILTER NOT EXISTS {
> > ?this sc:connectedTo ?device2 .
> > } .
> > }
>
> This does not look like a DELETE WHERE. That would be something like
>
> DELETE WHERE {
> ?this sc:hasMediaPath ?mp
>
> }
>
> Anyway, just as an aside because I don't think this is the problem.
>
> > I created the template by subclassing spin:UpdateTemplates and filling
> > in spin:body with the above, and spin:labelTemplate with a human-
> > readable string.
>
> > This seems to work fine in TBC FE. When using it with SPIN 1.2.0, I
> > get the following error:
>
> > Exception in thread "main" java.lang.NullPointerException
> > at org.topbraid.spin.util.UpdateUtil.addUpdatedGraphs(UpdateUtil.java:
> > 58)
>
> That line is
>
> if(quad.isDefaultGraph()) {
> results.add(graphStore.getDefaultModel().getGraph());
>
> }
>
> which indicates to me that your query is trying to update the default graph,
> but your Dataset does not define a default graph. So please either check your
> code where you construct the Dataset to make sure you give it a default
> graph, or change your query so that it explicitly mentions a named graph using
>
> DELETE {
> GRAPH [g] {
> ...
> }}
>
> WHERE {
> ...
>
> }
>
> If the triple you are trying to delete is inferred then it may be in a graph
> that doesn't even have a name in the default Dataset, so you would need to
> overload ARQFactory.getDataset() so that it returns a Dataset that has the
> inferred graph as default graph, or the [g] above.
>
> Cheers,
> Holger
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en