Hi Cati,
the Java code looks OK, but I am not sure how your ontology looks. Did
you assign the template to a class via spin:constraint? If you want, you
can share your example file with me or the group. Does the constraint
violation checking work from TopBraid Composer? Free Edition should be
enough to test this.
Holger
On 4/4/2014 0:14, Cati MartÃnez wrote:
Hi all,
I am relative new to the SPIN API and I am facing some basic problems:
I want to apply a spin:constraint based on a existing template to a
class. In the following lines you see how I get the template and bind
the arguments.
Template template =
SPINModuleRegistry.get().getTemplate("http://spinrdf.org/spl#ObjectCountPropertyConstraint",
ontModel);
com.hp.hpl.jena.query.Query arq =
ARQFactory.get().createQuery((Construct)template.getBody());
QueryExecution qexec = ARQFactory.get().createQueryExecution(arq,
ontModel);
QuerySolutionMap arqBindings = new QuerySolutionMap();
arqBindings.add(SPIN.THIS_VAR_NAME, informationItem);
arqBindings.add("property",describesSituation);
arqBindings.add("maxCount",ResourceFactory.createTypedLiteral("2",XSDDatatype.XSDinteger));
arqBindings.add("minCount",ResourceFactory.createTypedLiteral("2",XSDDatatype.XSDinteger));
qexec.setInitialBinding(arqBindings);
Now, I execute the query:
Model cm = qexec.execConstruct();
qexec.close();
cm.write(System.out);
And I see in my console the following constraint violation triple:
<rdf:Description rdf:nodeID="A0">
<j.0:violationPath
rdf:resource="http://purl.org/biotop/btl2.owl#represents"/>
<j.0:violationRoot
rdf:resource="http://www.semanticweb.org/martinezc/ontologies/2013/6/shn2.owl#shn:InformationItem"/>
<rdf:type rdf:resource="http://spinrdf.org/spin#ConstraintViolation"/>
</rdf:Description>
My problem is what to do next. I would like to show the error message,
so I tried the following:
// Run all constraints
List<ConstraintViolation> cvs =
SPINConstraints.check(ontModel, null);
System.out.println("Constraint violations:");
for(ConstraintViolation cv : cvs) {
System.out.println(" - at " +
SPINLabels.get().getLabel(cv.getRoot()) + ": " + cv.getMessage());
}
I do no get any result. I tried to add the constraint violation triple
to the ontModel, but I do not get any result printed anyway. Is there
an intermediate step required to add the spin:constraint to the class,
that I am missing?
Thanks a lot!
--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise
Vocabulary Network (EVN), TopBraid Composer, TopBraid Live, TopBraid
Insight, SPARQLMotion, SPARQL Web Pages 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
---
You received this message because you are subscribed to the Google
Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary
Network (EVN), TopBraid Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL
Web Pages 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
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.