Hello,
thanks for your answer Scott,   but is there any way to use SPIN without the
TBD, and add the constraints with the api dynamically ?

2010/10/7 Scott Henninger <shennin...@topquadrant.com>

>  Rodolfo; There may be a couple of SPIN principles that may be helpful to
> you.  The first is that constraints, constructors and rules are defined for
> a class and applied to its members.  The second is that ?this should be used
> to state that the query is applied to individual members.  I.e. in the
> following query:
>  1) is defined as a spin:constraint property for bad:Device
>  2) the triple pattern <?dev rdf:type bad:Device> is not necessary because
> ?this is pre-bound to each member of bad:Device
>
> CONSTRUCT {
>     _:b0 a spin:ConstraintViolation .
>     _:b0 spin:violationRoot ?this .
>     _:b0 spin:violationPath bad:deviceIngressProtection .
>     _:b0 rdfs:label "the value should be between 20 and 30" .
> }
> WHERE {
>     ?this bad:deviceIngressProtection ?value .
>     FILTER ((?value < 20) || (?value > 30)) .
> }
>
> In this case, I'm using Composer's constraint violation infrastructure to
> show this, so I'm creating a ConstraintViolation instance and hanging it on
> the bad:deviceIngressProtection property.
>
> I'm attaching a model that demonstrates this.  You can try it out in TBC
> Free/SE/ME.
>
> -- Scott
>
>
> On 10/7/10 1:29 AM, dennis wrote:
>
> Hi Rodolfo,
>
> could it be that ?value refers to a plain literal? I've realized that
> arithmetic operations don't work if the literals are not explicitly
> typed e.g. as xsd:integer or xsd:double, and maybe this holds for <
> and > comparisons as well...
>
> Cheers,
> Dennis
>
> On 7 Okt., 03:37, Holger Knublauch <hol...@topquadrant.com> 
> <hol...@topquadrant.com> wrote:
>
>  Hi Rudolfo,
>
> I am not sure where the problem is in your example. I think I need more 
> information - feel free to send me your specific example (off-list). I notice 
> that you are creating the CONSTRUCT query but it is unclear whether this 
> constraint is also attached to the model somehow.
>
> Holger
>
> On Oct 7, 2010, at 5:00 AM, Rodolfo Rieckhof wrote:
>
>
>  Hello Holger,
> thanks for your quick response. I have downloaded the new API and it works 
> just fine. But i have another question.
> How can  i insert a SPIN constraint dynamically in my ontology ? I have tried 
> the following:
> I create a constraint, just like in the examples with:
>
>   ...
> String query = prefixes +
> "CONSTRUCT { _:b0 bad:deviceIngressProtection ?value;" +
> "      rdfs:label 'the value should be between 20 an 30'} " +
> "WHERE { ?dev rdf:type bad:Device ; bad:deviceIngressProtection ?value ." +
> "      FILTER ( ?value < 20 || ?value > 30) " +
> "}";
>
>   Query arqQuery = ARQFactory.get().createQuery(model, query);
> ARQ2SPIN arq2SPIN = new ARQ2SPIN(model);
> Construct spinQuery = (Construct) arq2SPIN.createQuery(arqQuery, null);
>
>   //then i load my Onotology
>
>   File root = new File("ontologies");
> String  dataURL = new File(root.getAbsolutePath() + 
> "/Thermokon_Easysens_Funkschalter_BJ_V1.owl").toURI().toString();
> Reasoner reasoner = PelletReasonerFactory.theInstance().create();
>
>    // create an empty model
>    OntModel ontModel = ModelFactory.createOntologyModel( 
> PelletReasonerFactory.THE_SPEC );
>    ontModel.read( dataURL );
>
>   //add the   model with the Constraint
> ontModel.addl(model);
> SPINModuleRegistry.get().registerAll(ontModel);
>
>   // let SPIN do its work
> List<ConstraintViolation> cvs = SPINConstraints.check(ontModel, null);
> System.out.println("Constraint violations:" + cvs.size());
> for(ConstraintViolation cv : cvs) {
> System.out.println(" - at " + SPINLabels.get().getLabel(cv.getRoot()) + ": " 
> + cv.getRoot());
> }
>
>   the Problem is that i donĀ“t get any constrains violation  (cvs = 0). 
> Although when i run the query with ARQ I get 1. Could you tell me please wich 
> is the wright way to do this ? . Is it a problem, that the is Ontology in rdf 
> ?
>
>   Regards,
> Rodolfo
>
>   2010/10/6 Holger Knublauch <hol...@topquadrant.com> 
> <hol...@topquadrant.com>:
>
>  Hi Rodolfo,
>
>    thanks a lot for this bug report. It was indeed a (simple) recursive loop. 
> Since this was a small but rather critical bug, I have just updated the SPIN 
> API that is on the web with a fix. The file has still the same version number 
> etc, but the infinite loop should be gone now. I plan to do a proper release 
> with a couple of new features in a few weeks after it went through QA.
>
>    Thanks again
> Holger
>
>    On Oct 6, 2010, at 4:28 AM, rodo2...@googlemail.com wrote:
>
>    Hello everyone,
> I just downloaded the implementation of the SPIN API 1.1.2 and  when
> i run the example KennedysInferencingAndConstraintsExample i get an
> StackOverflowError. I haven't changed anything in the source and i
> think the problem is in this piece of code:
>
>     ...
> // Run constraints on a single instance only
>               Resource person = cvs.get(0).getRoot();
>               List<ConstraintViolation> localCVS = 
> SPINConstraints.check(person,
> null);
>               System.out.println("Constraint violations for " +
> SPINLabels.get().getLabel(person) + ": " + localCVS.size());
>
>     i am using jena 2.6.3 and ARQ  2.8.5. I would be very thankful for any
> help.
>
>     Regards
> Rodolfo
>
>     Console output:
>
>     Inferred triples: 136
> Constraint violations:
> - at spin:AskTemplates:
> - at spin:UpdateTemplates:
> - at spin:SelectTemplates:
> - at spin:ConstructTemplates:
> - at kennedys:JosephKennedy: age must be within a realistic range
> - at kennedys:StephenSmith: Same-sex marriage not permitted (in this
> model)
> - at kennedys:JeanKennedy: Same-sex marriage not permitted (in this
> model)
> Exception in thread "main" java.lang.StackOverflowError
>       at
> org.topbraid.spin.constraints.SPINConstraints.check(SPINConstraints.java:
> 259)
>       at
> org.topbraid.spin.constraints.SPINConstraints.check(SPINConstraints.java:
> 259)
> ....
>
>     --
> 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 totopbraid-us...@googlegroups.com
> To unsubscribe from this group, send email 
> totopbraid-users+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/topbraid-users?hl=en
>
>    --
> 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 totopbraid-us...@googlegroups.com
> To unsubscribe from this group, send email 
> totopbraid-users+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/topbraid-users?hl=en
>
>   --
> 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 totopbraid-us...@googlegroups.com
> To unsubscribe from this group, send email 
> totopbraid-users+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/topbraid-users?hl=en
>
>    --
> 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
> topbraid-users@googlegroups.com
> To unsubscribe from this group, send email to
> topbraid-users+unsubscr...@googlegroups.com<topbraid-users%2bunsubscr...@googlegroups.com>
> 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
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
topbraid-users@googlegroups.com
To unsubscribe from this group, send email to
topbraid-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en

Reply via email to