Skip to content
Permalink
Browse files
feat(ontology): Allow adding new property to a resource class in use (D…
…SP-1629) (#1859)

* feat(ontology): check if class is in use only if given minCardinality greater than 0 or cardinality=1

* docs(ontology): improve docs

* refactor(ontology): clean up

* fix (ontology): correct the test ontology

* test (ontology): test for adding cardinality for a new property of a class in use

* docs(ontology) clean up

* fix (ontology): test data
  • Loading branch information
SepidehAlassi committed May 18, 2021
1 parent ce9ba3a commit 061875ed21a2d574d1ab4df678bd6dbdaa305247
Showing with 14,963 additions and 11,989 deletions.
  1. +4 −4 docs/03-apis/api-v2/ontology-information.md
  2. +1 −1 test_data/ontologies/anything-onto.ttl
  3. +67 −53 test_data/ontologyR2RV2/allOntologyMetadata.ttl
  4. +19 −18 test_data/ontologyR2RV2/anythingHasDate.ttl
  5. +20 −19 test_data/ontologyR2RV2/anythingHasListItem.ttl
  6. +17 −14 test_data/ontologyR2RV2/anythingOntologyMetadata.ttl
  7. +201 −201 test_data/ontologyR2RV2/anythingOntologyWithValueObjects.jsonld
  8. +2,738 −1,811 test_data/ontologyR2RV2/anythingOntologyWithValueObjects.rdf
  9. +1,527 −1,271 test_data/ontologyR2RV2/anythingOntologyWithValueObjects.ttl
  10. +213 −173 test_data/ontologyR2RV2/anythingThingWithAllLanguages.ttl
  11. +11 −9 test_data/ontologyR2RV2/beolOntologyMetadata.ttl
  12. +117 −98 test_data/ontologyR2RV2/boxOntologyWithValueObjects.ttl
  13. +191 −155 test_data/ontologyR2RV2/imagesBild.ttl
  14. +18 −17 test_data/ontologyR2RV2/imagesTitel.ttl
  15. +162 −132 test_data/ontologyR2RV2/incunabulaBook.ttl
  16. +7 −6 test_data/ontologyR2RV2/incunabulaOntologyMetadata.ttl
  17. +383 −321 test_data/ontologyR2RV2/incunabulaOntologySimple.ttl
  18. +128 −128 test_data/ontologyR2RV2/incunabulaOntologyWithValueObjects.jsonld
  19. +876 −758 test_data/ontologyR2RV2/incunabulaOntologyWithValueObjects.ttl
  20. +172 −140 test_data/ontologyR2RV2/incunabulaPage.ttl
  21. +324 −263 test_data/ontologyR2RV2/incunabulaPageAndBookWithValueObjects.ttl
  22. +5 −5 test_data/ontologyR2RV2/incunabulaPartOf.jsonld
  23. +21 −19 test_data/ontologyR2RV2/incunabulaPartOf.ttl
  24. +14 −13 test_data/ontologyR2RV2/incunabulaSimplePubDate.ttl
  25. +5 −5 test_data/ontologyR2RV2/incunabulaWithValueObjectsPubDate.jsonld
  26. +19 −18 test_data/ontologyR2RV2/incunabulaWithValueObjectsPubDate.ttl
  27. +13 −13 test_data/ontologyR2RV2/knoraApiDate.ttl
  28. +124 −100 test_data/ontologyR2RV2/knoraApiDateValue.ttl
  29. +615 −523 test_data/ontologyR2RV2/knoraApiOntologySimple.ttl
  30. +398 −398 test_data/ontologyR2RV2/knoraApiOntologyWithValueObjects.jsonld
  31. +4,652 −3,807 test_data/ontologyR2RV2/knoraApiOntologyWithValueObjects.ttl
  32. +13 −12 test_data/ontologyR2RV2/knoraApiSimpleHasColor.ttl
  33. +5 −5 test_data/ontologyR2RV2/knoraApiWithValueObjectsHasColor.jsonld
  34. +20 −19 test_data/ontologyR2RV2/knoraApiWithValueObjectsHasColor.ttl
  35. +20 −18 test_data/ontologyR2RV2/minimalOntologyWithValueObjects.ttl
  36. +28 −28 test_data/ontologyR2RV2/salsahGuiOntology.jsonld
  37. +62 −46 test_data/ontologyR2RV2/salsahGuiOntology.ttl
  38. +10 −10 test_data/ontologyR2RV2/standoffOntologyWithValueObjects.jsonld
  39. +1,684 −1,347 test_data/ontologyR2RV2/standoffOntologyWithValueObjects.ttl
  40. +17 −7 webapi/src/main/scala/org/knora/webapi/responders/v2/OntologyResponderV2.scala
  41. +42 −4 webapi/src/test/scala/org/knora/webapi/responders/v2/OntologyResponderV2Spec.scala
@@ -1449,8 +1449,8 @@ the property definition, submit the request without those predicates.

### Adding Cardinalities to a Class

This operation is not permitted if the class is used in data, or if it
has a subclass.
If the class is used in data or if it
has a subclass, it is not allowed to add cardinalities `owl:minCardinality` greater than 0 or `owl:cardinality 1` to the class.

```
HTTP POST to http://host/v2/ontologies/cardinalities
@@ -1464,7 +1464,7 @@ HTTP POST to http://host/v2/ontologies/cardinalities
"@type" : "xsd:dateTimeStamp",
"@value" : "ONTOLOGY_LAST_MODIFICATION_DATE"
},
"@graph" : [ {
"@graph" : [
{
"@id" : "CLASS_IRI",
"@type" : "owl:Class",
@@ -1476,7 +1476,7 @@ HTTP POST to http://host/v2/ontologies/cardinalities
}
}
}
} ],
],
"@context" : {
"knora-api" : "http://api.knora.org/ontology/knora-api/v2#",
"owl" : "http://www.w3.org/2002/07/owl#",
@@ -634,7 +634,7 @@
rdf:type owl:Restriction ;
owl:onProperty :hasBlueThingValue ;
owl:minCardinality "0"^^xsd:nonNegativeInteger ;
salsah-gui:guiOrder "16"^^xsd:nonNegativeInteger
salsah-gui:guiOrder "63"^^xsd:nonNegativeInteger
] ;

rdfs:comment """Diese Resource-Klasse beschreibt ein blaues Ding"""@de ;
@@ -1,68 +1,82 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix knora-api: <http://api.knora.org/ontology/knora-api/v2#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://0.0.0.0:3333/ontology/0001/anything/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0001>;
knora-api:lastModificationDate "2017-12-19T15:23:42.166Z"^^xsd:dateTimeStamp;
rdfs:label "The anything ontology" .
<http://0.0.0.0:3333/ontology/0001/something/v2>
a owl:Ontology ;
rdfs:label "The something ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0001> .

<http://0.0.0.0:3333/ontology/0001/minimal/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0001>;
knora-api:lastModificationDate "2019-09-10T08:57:46.633162Z"^^xsd:dateTimeStamp;
rdfs:label "A minimal ontology" .
<http://0.0.0.0:3333/ontology/0001/minimal/v2>
a owl:Ontology ;
rdfs:label "A minimal ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0001> ;
knora-api:lastModificationDate "2019-09-10T08:57:46.633162Z"^^xsd:dateTimeStamp .

<http://0.0.0.0:3333/ontology/0001/something/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0001>;
rdfs:label "The something ontology" .
<http://api.knora.org/ontology/salsah-gui/v2>
a owl:Ontology ;
rdfs:label "The salsah-gui ontology" ;
knora-api:attachedToProject <http://www.knora.org/ontology/knora-admin#SystemProject> ;
knora-api:isBuiltIn true .

<http://0.0.0.0:3333/ontology/00FF/images/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/00FF>;
rdfs:label "The images demo ontology" .
<http://0.0.0.0:3333/ontology/0806/webern/v2>
a owl:Ontology ;
rdfs:label "The Anton Webern project ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0806> .

<http://0.0.0.0:3333/ontology/0801/beol/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF>;
rdfs:label "The BEOL ontology" .
<http://api.knora.org/ontology/knora-admin/v2>
a owl:Ontology ;
rdfs:label "The Knora admin ontology" ;
knora-api:attachedToProject <http://www.knora.org/ontology/knora-admin#SystemProject> ;
knora-api:isBuiltIn true .

<http://0.0.0.0:3333/ontology/0801/biblio/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF>;
rdfs:label "The Biblio ontology" .
<http://0.0.0.0:3333/ontology/0804/dokubib/v2>
a owl:Ontology ;
rdfs:label "The dokubib ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0804> .

<http://0.0.0.0:3333/ontology/0803/incunabula/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0803>;
rdfs:label "The incunabula ontology" .
<http://api.knora.org/ontology/shared/example-box/v2>
a owl:Ontology ;
rdfs:label "An example of a shared ontology" ;
knora-api:attachedToProject <http://www.knora.org/ontology/knora-admin#DefaultSharedOntologiesProject> ;
knora-api:isShared true ;
knora-api:lastModificationDate "2018-09-10T14:53:00Z"^^xsd:dateTimeStamp .

<http://0.0.0.0:3333/ontology/0804/dokubib/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0804>;
rdfs:label "The dokubib ontology" .
<http://0.0.0.0:3333/ontology/00FF/images/v2>
a owl:Ontology ;
rdfs:label "The images demo ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/00FF> .

<http://0.0.0.0:3333/ontology/0806/webern/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0806>;
rdfs:label "The Anton Webern project ontology" .
<http://0.0.0.0:3333/ontology/0801/biblio/v2>
a owl:Ontology ;
rdfs:label "The Biblio ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF> .

<http://api.knora.org/ontology/knora-admin/v2> a owl:Ontology;
knora-api:attachedToProject <http://www.knora.org/ontology/knora-admin#SystemProject>;
knora-api:isBuiltIn true;
rdfs:label "The Knora admin ontology" .
<http://0.0.0.0:3333/ontology/0803/incunabula/v2>
a owl:Ontology ;
rdfs:label "The incunabula ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0803> .

<http://api.knora.org/ontology/knora-api/v2> a owl:Ontology;
knora-api:attachedToProject <http://www.knora.org/ontology/knora-admin#SystemProject>;
knora-api:isBuiltIn true;
rdfs:label "The knora-api ontology in the complex schema" .
<http://api.knora.org/ontology/knora-api/v2>
a owl:Ontology ;
rdfs:label "The knora-api ontology in the complex schema" ;
knora-api:attachedToProject <http://www.knora.org/ontology/knora-admin#SystemProject> ;
knora-api:isBuiltIn true .

<http://api.knora.org/ontology/salsah-gui/v2> a owl:Ontology;
knora-api:attachedToProject <http://www.knora.org/ontology/knora-admin#SystemProject>;
knora-api:isBuiltIn true;
rdfs:label "The salsah-gui ontology" .
<http://0.0.0.0:3333/ontology/0801/beol/v2>
a owl:Ontology ;
rdfs:label "The BEOL ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF> .

<http://api.knora.org/ontology/shared/example-box/v2> a owl:Ontology;
knora-api:attachedToProject <http://www.knora.org/ontology/knora-admin#DefaultSharedOntologiesProject>;
knora-api:isShared true;
knora-api:lastModificationDate "2018-09-10T14:53:00Z"^^xsd:dateTimeStamp;
rdfs:label "An example of a shared ontology" .
<http://0.0.0.0:3333/ontology/0001/anything/v2>
a owl:Ontology ;
rdfs:label "The anything ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0001> ;
knora-api:lastModificationDate "2017-12-19T15:23:42.166Z"^^xsd:dateTimeStamp .

<http://api.knora.org/ontology/standoff/v2> a owl:Ontology;
knora-api:attachedToProject <http://www.knora.org/ontology/knora-admin#SystemProject>;
knora-api:isBuiltIn true;
rdfs:label "The standoff ontology" .
<http://api.knora.org/ontology/standoff/v2>
a owl:Ontology ;
rdfs:label "The standoff ontology" ;
knora-api:attachedToProject <http://www.knora.org/ontology/knora-admin#SystemProject> ;
knora-api:isBuiltIn true .
@@ -1,21 +1,22 @@
@prefix anything: <http://0.0.0.0:3333/ontology/0001/anything/v2#> .
@prefix knora-api: <http://api.knora.org/ontology/knora-api/v2#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix salsah-gui: <http://api.knora.org/ontology/salsah-gui/v2#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix knora-api: <http://api.knora.org/ontology/knora-api/v2#> .
@prefix anything: <http://0.0.0.0:3333/ontology/0001/anything/v2#> .

<http://0.0.0.0:3333/ontology/0001/anything/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0001>;
knora-api:lastModificationDate "2017-12-19T15:23:42.166Z"^^xsd:dateTimeStamp;
rdfs:label "The anything ontology" .
<http://0.0.0.0:3333/ontology/0001/anything/v2>
a owl:Ontology ;
rdfs:label "The anything ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0001> ;
knora-api:lastModificationDate "2017-12-19T15:23:42.166Z"^^xsd:dateTimeStamp .

anything:hasDate a owl:ObjectProperty;
knora-api:isEditable true;
knora-api:isResourceProperty true;
knora-api:objectType knora-api:DateValue;
knora-api:subjectType anything:Thing;
salsah-gui:guiElement salsah-gui:Date;
rdfs:label "Date";
rdfs:subPropertyOf knora-api:hasValue .
anything:hasDate a owl:ObjectProperty ;
rdfs:label "Date" ;
rdfs:subPropertyOf knora-api:hasValue ;
knora-api:isEditable true ;
knora-api:isResourceProperty true ;
knora-api:objectType knora-api:DateValue ;
knora-api:subjectType anything:Thing ;
salsah-gui:guiElement salsah-gui:Date .
@@ -1,22 +1,23 @@
@prefix anything: <http://0.0.0.0:3333/ontology/0001/anything/v2#> .
@prefix knora-api: <http://api.knora.org/ontology/knora-api/v2#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix salsah-gui: <http://api.knora.org/ontology/salsah-gui/v2#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix knora-api: <http://api.knora.org/ontology/knora-api/v2#> .
@prefix anything: <http://0.0.0.0:3333/ontology/0001/anything/v2#> .

<http://0.0.0.0:3333/ontology/0001/anything/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0001>;
knora-api:lastModificationDate "2017-12-19T15:23:42.166Z"^^xsd:dateTimeStamp;
rdfs:label "The anything ontology" .
<http://0.0.0.0:3333/ontology/0001/anything/v2>
a owl:Ontology ;
rdfs:label "The anything ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0001> ;
knora-api:lastModificationDate "2017-12-19T15:23:42.166Z"^^xsd:dateTimeStamp .

anything:hasListItem a owl:ObjectProperty;
knora-api:isEditable true;
knora-api:isResourceProperty true;
knora-api:objectType knora-api:ListValue;
knora-api:subjectType anything:Thing;
salsah-gui:guiAttribute "hlist=<http://rdfh.ch/lists/0001/treeList>";
salsah-gui:guiElement salsah-gui:List;
rdfs:label "List element";
rdfs:subPropertyOf knora-api:hasValue .
anything:hasListItem a owl:ObjectProperty ;
rdfs:label "List element" ;
rdfs:subPropertyOf knora-api:hasValue ;
knora-api:isEditable true ;
knora-api:isResourceProperty true ;
knora-api:objectType knora-api:ListValue ;
knora-api:subjectType anything:Thing ;
salsah-gui:guiAttribute "hlist=<http://rdfh.ch/lists/0001/treeList>" ;
salsah-gui:guiElement salsah-gui:List .
@@ -1,18 +1,21 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix knora-api: <http://api.knora.org/ontology/knora-api/v2#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://0.0.0.0:3333/ontology/0001/anything/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0001>;
knora-api:lastModificationDate "2017-12-19T15:23:42.166Z"^^xsd:dateTimeStamp;
rdfs:label "The anything ontology" .
<http://0.0.0.0:3333/ontology/0001/anything/v2>
a owl:Ontology ;
rdfs:label "The anything ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0001> ;
knora-api:lastModificationDate "2017-12-19T15:23:42.166Z"^^xsd:dateTimeStamp .

<http://0.0.0.0:3333/ontology/0001/minimal/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0001>;
knora-api:lastModificationDate "2019-09-10T08:57:46.633162Z"^^xsd:dateTimeStamp;
rdfs:label "A minimal ontology" .
<http://0.0.0.0:3333/ontology/0001/minimal/v2>
a owl:Ontology ;
rdfs:label "A minimal ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0001> ;
knora-api:lastModificationDate "2019-09-10T08:57:46.633162Z"^^xsd:dateTimeStamp .

<http://0.0.0.0:3333/ontology/0001/something/v2> a owl:Ontology;
knora-api:attachedToProject <http://rdfh.ch/projects/0001>;
rdfs:label "The something ontology" .
<http://0.0.0.0:3333/ontology/0001/something/v2>
a owl:Ontology ;
rdfs:label "The something ontology" ;
knora-api:attachedToProject <http://rdfh.ch/projects/0001> .

0 comments on commit 061875e

Please sign in to comment.