How to associate a constraint with a property?

28 views
Skip to first unread message

Jack Hodges

unread,
Jun 8, 2016, 5:28:34 PM6/8/16
to TopBraid Suite Users
I am building some constraints using ASK templates. In the myPurchases example when the checkInvoiceAge ASK template (an invoice with no paidDate is > 90 days old) is applied to the purchases:MaterialsPurchase class errors show up next to the invoiceDate and paidDate properties. I am guessing that this is because they are the only properties directly referenced in the checkInvoiceAge ASK template. Is this true?

And what if I want to associated a constraint test with a provided property name? How would I show the violation against that property? Right now it ends up showing against the instance, which isn't nearly as helpful.

Jack

Irene Polikoff

unread,
Jun 8, 2016, 5:56:00 PM6/8/16
to topbrai...@googlegroups.com
Violations from ASK templates always show against a resource that failed the check. 

You can use CONSTRUCT templates. With these, you can create whatever violation messages you want and define where it applies using spin:violationPath property. This means that the violation can be shown for some other resource, but I am not sure this is what you are asking for.


Irene Polikoff

--
You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include the TopBraid Suite family of products and its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbrai...@googlegroups.com
---
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 topbraid-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jack Hodges

unread,
Jun 10, 2016, 4:46:04 PM6/10/16
to TopBraid Suite Users

Irene,

Thank you for this clarification but in the cases I am referring to I have sent the property type into the ASK template as a SPIN constraint, and when the violation fails it is showing the violation on the instance and not on the property but the failure is most assuredly on the property value. I am attaching the ASK statement below:

# a class property cardinality is inconsistent with an instance property cardinality
ASK WHERE {
    ?this ?testPredicate ?predValues .
    ?this a ?iclassType .
    BIND (smf:minCardinality(?iclassType, ?testPredicate) AS ?cmin) .
    BIND (smf:minCardinality(?iclassType, ?testPredicate) AS ?cmax) .
    FILTER ((spl:objectCount(?inst, ?testPredicate) < ?cmin) || (spl:objectCount(?inst, ?testPredicate) > ?cmax)) .
}

This one is clearly a cardinality constraint check, where the SPIN constraint is ?testPredicate and, in the test instance I have provided, is the property 'eddl:constantUnit'. The ASK template is attached to the parent class using this property, where the cardinality constraint is 'max 1' and I have created 3 in the test instance. I have attached a screen grab of this.

Based on your explanation and my understanding (or at least wish), I'd have expected the violation to be attached to the eddl:constantUnit property. That is in fact the way it worked in the myPurchases example, except that in that example the property wasn't an argument but declared in the SPARQL directly. Such a template would not be very generally applicable and that is why I made the property an argument in the first place.

Jack

Irene Polikoff

unread,
Jun 10, 2016, 6:01:57 PM6/10/16
to topbrai...@googlegroups.com
Jack,

I don’t believe it makes sense to actually attach the violation to a property. Property is potentially used with many instances – it is not in itself violating anything. If you attach a violation to a property, you wouldn’t know what resource has a problem – that what resource has more than allowed number of values for this property. 

You can’t attach the violation to the values either. First, in this case, they are literals. Secondly, even if they were resources, which of the three is in violation and in what context – any of them could be also a value for some other resource where there are only two values.

So, in this particular example, I don’t see how a violation could be usefully attached to anything but edispin:Variable1.

Having said this, if you wanted to attach it to eddl:constantUnit, you could by using a CONSTRUCT template.

You may be confusing the resource that has a violation raised against it with the UI, where a warning sign may appear in a resource's form next to some property widget. 

This is not because the violation is “attached” to the property, it is is just a UI presentation of the violation that is found for edispin:Variable1. In case of CONSTRUCT templates, the property next to which we display a warning signal on a form is set using spin:violationPath. In case of ASK templates, I believe that the code tries to figure it out itself. It may be that it is not smart enough to know which property is being used when this is going through a template. I am not sure. I also don’t know how exactly you are declaring the template. 

However, I do know that if you use a CONSTRUCT template, you can provide the spin:violationPath property, and then the display should work just fine. You should use any of the spl templates as an example. For example, take a look at spl:RangePropertyConstraint.


Irene Polikoff

Jack Hodges

unread,
Jun 13, 2016, 1:16:01 PM6/13/16
to TopBraid Suite Users
Irene,

I am not generally interested in the property, per se, but the rdfs:range associated with the property, but I'd like to see the constraint violation associated with the property in the UI just as it was in the example case you (TQ) provided. My constraint isn't on the literal values that I had in my example but on the cardinality restriction on the property. I never tested for the values. In other cases I do.

Jack

Irene Polikoff

unread,
Jun 13, 2016, 1:19:31 PM6/13/16
to topbrai...@googlegroups.com
Did you try using CONSTRUCT Templates and specifying property as the violation path?

Irene Polikoff


Reply all
Reply to author
Forward
0 new messages