Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property inheritance: Knora-base:objectClassConstraint & Knora-base:subjectClassConstraint? #302

Closed
mrivoal opened this issue Nov 2, 2016 · 3 comments · Fixed by #303
Closed
Assignees
Labels
bug something isn't working

Comments

@mrivoal
Copy link

mrivoal commented Nov 2, 2016

I don't know if I am doing something wrong or if it is a bug I should report for.

Here is the situation:

In my ontology, a property drawings-gods:internalComment is shared by several resource classes (drawings-gods:Drawing, drawings-gods:Instruction, drawings-gods:CollectionSite).

I defined a property drawings-gods:internalComment with a knora-base:objectClassConstraint on knora-base:TextValue. Then, I defined several subproperties of the previous one: drawings-gods:drawingComment, drawings-gods:instructionComment, drawings-gods:siteComment.

The knora-base:subjectClassConstraint is only defined in the property drawings-gods:internalComment. But different knora-base:objectClassConstraint are defined for each subproperty.

###  http://www.knora.org/ontology/drawings-gods#Drawing
:Drawing rdf:type owl:Class ;
         rdfs:subClassOf knora-base:StillImageRepresentation ,
                         [ rdf:type owl:Restriction ;
                           owl:onProperty :drawingComment ;
                           owl:minCardinality "0"^^xsd:nonNegativeInteger
                         ] ;
	rdfs:label "Dessin"@fr ,
			"Drawing"@en ;
        knora-base:hasDefaultViewPermission knora-base:UnknownUser ,
                                           knora-base:KnownUser ;
        knora-base:hasDefaultModifyPermission knora-base:ProjectMember ;
        knora-base:hasDefaultDeletePermission knora-base:Owner . 

###  http://www.knora.org/ontology/drawings-gods#Instruction
:Instruction rdf:type owl:Class ;
             rdfs:subClassOf knora-base:Resource ,
                             [ rdf:type owl:Restriction ;
                               owl:onProperty :instructionComment ;
                               owl:minCardinality "0"^^xsd:nonNegativeInteger
                             ] ;
    	    rdfs:label "Instructions"@fr ,
            	         "Instructions"@en ;
            rdfs:comment "Instructions expliquées à l'enfant."@fr ,
        		"Task explained to the child."@en ;
	    knora-base:hasDefaultViewPermission knora-base:UnknownUser ,
                                           knora-base:KnownUser ;
            knora-base:hasDefaultModifyPermission knora-base:ProjectMember ;
            knora-base:hasDefaultDeletePermission knora-base:Owner . 

###  http://www.knora.org/ontology/drawings-gods#CollectionSite
:CollectionSite rdf:type owl:Class ;
                rdfs:subClassOf knora-base:Resource ,
                                [ rdf:type owl:Restriction ;
                                  owl:onProperty :siteComment ;
                                  owl:minCardinality "0"^^xsd:nonNegativeInteger
                                ] ;
				rdfs:label "Site de collecte"@fr ,
            		"Collection site"@en ;
            	rdfs:comment "Institution, lieu de récolte."@fr ,
        			"Institution, place of collection."@en ;
        		knora-base:hasDefaultViewPermission knora-base:UnknownUser ,
                                           knora-base:KnownUser ;
        		knora-base:hasDefaultModifyPermission knora-base:ProjectMember ;
        		knora-base:hasDefaultDeletePermission knora-base:Owner . 

###  http://www.knora.org/ontology/drawings-gods#internalComment
:internalComment rdf:type owl:ObjectProperty ;
                 rdfs:subPropertyOf knora-base:hasValue ;
                 knora-base:objectClassConstraint knora-base:TextValue ;
                 rdfs:label "Commentaire interne"@fr ,
                     	"Internal comment"@en ;
		 rdfs:comment "Commentaire interne"@fr ,
			"Internal comment"@en ;
		 salsah-gui:guiElement salsah-gui:SimpleText ;
		 salsah-gui:guiOrder "1"^^xsd:integer ;
       		 knora-base:hasDefaultViewPermission knora-base:ProjectMember ;
	         knora-base:hasDefaultDeletePermission knora-base:Owner .

###  http://www.knora.org/ontology/drawings-gods#drawingComment
:drawingComment rdf:type owl:ObjectProperty ;
                rdfs:subPropertyOf :internalComment ;
                knora-base:subjectClassConstraint :Drawing ;
                rdfs:label "Commentaire interne (dessin)"@fr ,
                     	"Internal comment (drawing)"@en ;
		rdfs:comment "Commentaire interne (dessin)."@fr ,
			"Internal comment (drawing)."@en .

###  http://www.knora.org/ontology/drawings-gods#siteComment
:siteComment rdf:type owl:ObjectProperty ;
             rdfs:subPropertyOf :internalComment ;
             knora-base:subjectClassConstraint :CollectionSite ;
             rdfs:label "Commentaire interne (site de collecte)"@fr ,
             	"Internal comment (collection site)"@en ;
	     rdfs:comment "Commentaire interne (site de collecte)"@fr ,
		"Internal comment (collection site)"@en .

###  http://www.knora.org/ontology/drawings-gods#instructionComment
:instructionComment rdf:type owl:ObjectProperty ;
                    rdfs:subPropertyOf :internalComment ;
                    knora-base:subjectClassConstraint :Instruction ;
                    rdfs:label "Commentaire interne (instruction)"@fr ,
                     	"Internal comment (instruction)"@en ;
		    rdfs:comment "Commentaire interne (instruction)"@fr ,
			"Internal comment (instruction)"@en .

What I intended to do by modelling data this way is to allow user to search for values in drawings-gods:internalComment property, and thus to retrieve results from any of its subproperties (drawings-gods:drawingComment, etc.).

Consistency check passed. Salsah GUI displays correctly the field in the Add resource window.
capture d ecran 2016-11-02 a 10 51 46 copie

However, I am unable to create a resource. I get this response:
{"status":27,"error":"org.knora.webapi.UpdateNotPerformedException: Resource http://data.knora.org/j_ByCu-bQLef_c8kzSv7ng was not created. Please report this as a possible bug."}

The error comes from the SPARQL insertion query, which does not insert anything, even if the query looks right (the example is the following file is for a different resource class drawings-gods:Passage but you will get the idea: ddd-save-request.txt).

The only way I was able to create the resource is when both knora-base:objectClassConstraint and knora-base:subjectClassConstraint were defined within the sub-property itself. So, is it a restriction from the GUI? From the API? From Knora? Is it the intended behaviour or is it a bug?

@mrivoal mrivoal added bug something isn't working question further information is requested labels Nov 2, 2016
@benjamingeer
Copy link

Thanks for this bug report. You're right, this should work the way you expect, but I'm not sure it's feasible.

The problem is that property inheritance is easy to implement in the consistency checker and in the Knora API server, but difficult to implement in the SPARQL that does the update to create the resource. That SPARQL update checks that the type of value you submitted matches the property's objectClassConstraint. In your case, the property has no objectClassConstraint, so the check fails, and this makes the update fail.

It would be easy to make the SPARQL work for this particular case. The hard case, however, would be something like this:

:Foo rdf:type owl:Class ;
    rdfs:subClassOf knora-base:Resource .

:Bar rdf:type owl:Class ;
    rdfs:subClassOf :Foo .

:hasFoo rdfs:subPropertyOf knora-base:hasLinkTo ;
    knora-base:objectClassConstraint :Foo .

:hasBar rdfs:subPropertyOf :hasFoo ;
    knora-base:objectClassConstraint :Bar .

Here the objectClassConstraint of hasBar should override the objectClassConstraint of hasFoo, to ensure that the object is really a :Bar and not just a :Foo. This is complicated to do in SPARQL. I'll try to get it work. If I don't succeed, then you'll just have to specify objectClassConstraint on the subproperty.

@benjamingeer
Copy link

I managed to implement this in the update SPARQL, but it was too slow on Fuseki. So I think the best thing is to remove these checks from the update SPARQL as per pull request #305.

@benjamingeer
Copy link

It turns out that our GraphDB consistency checking doesn't actually support the inheritance of property predicates, because there is no such inheritance in RDFS. My confusion arose because rdfs:subClassOf causes OWL cardinalities to be inherited in resource classes, so it seemed to make sense that there should be a corresponding mechanism for property definitions, but in reality there isn't.

So I think the sensible thing to do is to completely remove support for inheritance of property predicates from Knora. This means that you'll have to write knora-base:objectClassConstraint explicitly on each property definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants