On 8/1/2014 2:00, [email protected] wrote:
I'm working with spin constraints (spin 1.4.0 via Maven). I have them firing but I'm confused about how to label them so I can see which constraint has failed. The full code (and data) is at https://github.com/jameshowison/softcite (

This is very cool. I am glad to see more projects using SPIN, some of them with Turtle files edited by hand. If you do edit these files by hand, I would still recommend to make them easier to open with TopBraid (Free Edition) and similar RDF tools. All you would need to do is add some owl:Ontology into every file and define explicit owl:imports so that when you load the example file, it will pull all other necessary files into TopBraid. This may help you get more feedback because more people could understand what's going on (without stepping through Java code). Just an idea.

may be some local paths in there, sorry!) and I run the constraints via mvn -Dtest=AppTest#testSPINConstraints test

I'm using the output code from the Kennedy's example, edited to use getCustomizedLabel rather than getLabel (although using just getLabel doesn't work as I'd expect either):

for(ConstraintViolation cv : cvs) {
System.out.println(" - at " + SPINLabels.get().getCustomizedLabel(cv.getRoot()) + ": " + cv.getMessage());

I've tried to follow the code through cv.getMessage() but I got lost in abstract interfaces somewhere :)

This is the constraint:

bioj:SoftwareMention a rdfs:Class ;
  spin:constraint
              [ a       spl:Attribute ;
rdfs:comment "Must have one and exactly one classification "^^xsd:string ;
                spl:predicate citec:mention_category ;
                spl:minCount 1 ;
                spl:maxCount 1 ;
                # spl:valueType citec:MentionClassification ;
               # spl:defaultValue ex:Red
              ] ;
.

Originally I was working with 1.3.1 and I was getting the Resource ID but no message:

- at citec:a2007-36-BMC_PLANT_BIOL-B03-mention:

Now I've upgraded to 1.4.0 and I'm getting a generic message (progress!):

- at citec:a2007-36-BMC_PLANT_BIOL-B03-mention: Attribute citec:mention_category : [1,1]

Yes I had fixed this bug in 1.3.3 because several users complained that the message was empty. It now behaves more consistently with TopBraid. If the template has a spin:labelTemplate then it will use that.


But how would I output the rdfs:comment from the constraint?

As a secondary, but likely related question, I have this constraint:

bioj:ArticleSoftwareLink a rdfs:Class ;
spin:constraint
           [ a       sp:Ask ;
             sp:text """
        # Can only find versions if they exist
                 ASK WHERE {
                     ?this a bioj:ArticleSoftwareLink ;
citec:has_version_indicator false ;
citec:version_is_findable true .
                 }"""
           ] ;
.

That outputs the generic:

- at bioj:a2003-44-BBA-GEN_SUBJECTS-SWISS-MODEL: SPIN constraint at bioj:ArticleSoftwareLink

But I'd like it to output the comment in the query ( # Can only find versions if they exist ), I understand that the sp:text gets parsed and that should end up as an rdfs:comment property on the constraint, not sure if that's actually right.

In the SPIN RDF syntax (without sp:text), the RDF syntax tree would have an rdfs:comment triple at the sp:Ask. So you could try to move the # into an rdfs:comment triple and see if it works better. It is difficult to rely on the # comment in the sp:text syntax because this information is thrown away by the SPARQL parser. The sp:Ask object is there to allow to attach exactly that kind of explicit metadata.

I would also suggest you switch to CONSTRUCT, which gives you more options, especially to also specify a spin:violationPath. When you CONSTRUCT the spin:ConstraintViolation, you can freely chose an rdfs:label, and that label could be the result of your own CONCAT string operations in the WHERE clause.


In any case (and perhaps more confusingly) I'd tried having the comment as rdfs:comment or rdfs:label for the constraint, but having either of those there produces a NullPointerException:

java.lang.NullPointerException
at org.topbraid.spin.util.JenaUtil.getStringProperty(JenaUtil.java:617)
at org.topbraid.spin.system.SPINLabels.getCustomizedLabel(SPINLabels.java:57) at edu.utexas.ischool.jhowison.TTLRepository.runSPINconstraints(TTLRepository.java:523)

The NullPointer is because the ConstraintViolation has no root resource, so this problem is IMHO unrelated to the constraint violation's message.

I will try look into your example more next week, as it is quite possible that you are pointing at things to improve. Meanwhile: would it be possible for you to make the files a bit more TopBraid-friendly so that they are easier to open and study?

Thanks,
Holger

--
-- 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.

Reply via email to