Skip to content

Commit

Permalink
Merge pull request #587 from ucoProject/Feature-Issue-586
Browse files Browse the repository at this point in the history
Issue 586: Warn of prior disjointedness declarations in `core:` and `types:`
  • Loading branch information
plbt5 authored Jun 5, 2024
2 parents 27ca6b0 + 9460e74 commit f2b11ce
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ontology/uco/core/core.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,17 @@ core:UcoInherentCharacterizationThing
sh:targetClass core:UcoInherentCharacterizationThing ;
.

core:UcoInherentCharacterizationThing-disjointWith-UcoObject-shape
a sh:NodeShape ;
sh:message "observable:UcoInherentCharacterizationThing and observable:UcoObject are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ;
sh:not [
a sh:NodeShape ;
sh:class core:UcoObject ;
] ;
sh:severity sh:Warning ;
sh:targetClass core:UcoInherentCharacterizationThing ;
.

core:UcoObject
a
owl:Class ,
Expand Down
22 changes: 22 additions & 0 deletions ontology/uco/types/types.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ types:Thread
] ;
.

types:Thread-disjointWith-co-List-shape
a sh:NodeShape ;
sh:message "types:Thread and co:List are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ;
sh:not [
a sh:NodeShape ;
sh:class co:List ;
] ;
sh:severity sh:Warning ;
sh:targetClass types:Thread ;
.

types:ThreadItem
a
owl:Class ,
Expand All @@ -213,6 +224,17 @@ types:ThreadItem
] ;
.

types:ThreadItem-disjointWith-co-ListItem-shape
a sh:NodeShape ;
sh:message "types:ThreadItem and co:ListItem are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ;
sh:not [
a sh:NodeShape ;
sh:class co:ListItem ;
] ;
sh:severity sh:Warning ;
sh:targetClass types:ThreadItem ;
.

types:entry
a owl:ObjectProperty ;
rdfs:label "entry"@en ;
Expand Down
2 changes: 2 additions & 0 deletions tests/examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ all: \
configuration_setting_XFAIL_validation.ttl \
database_records_PASS_validation.ttl \
database_records_XFAIL_validation.ttl \
disjointedness_PASS_validation.ttl \
event_XFAIL_validation.ttl \
file_url_PASS_validation.ttl \
has_facet_inverse_functional_PASS_validation.ttl \
Expand Down Expand Up @@ -98,6 +99,7 @@ check: \
configuration_setting_XFAIL_validation.ttl \
database_records_PASS_validation.ttl \
database_records_XFAIL_validation.ttl \
disjointedness_PASS_validation.ttl \
event_XFAIL_validation.ttl \
file_url_PASS_validation.ttl \
has_facet_inverse_functional_PASS_validation.ttl \
Expand Down
18 changes: 18 additions & 0 deletions tests/examples/disjointedness_PASS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"@context": {
"kb": "http://example.org/kb/",
"core": "https://ontology.unifiedcyberontology.org/uco/core/",
"observable": "https://ontology.unifiedcyberontology.org/uco/observable/",
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"@graph": [
{
"@id": "kb:File-33a25932-3a1a-4828-a90f-d31818b495ce",
"@type": [
"observable:File",
"observable:FileFacet"
],
"rdfs:comment": "This node will trigger a violation in UCO 2.0.0 for designating itself a File and FileFacet, which are disjoint due to File being a (eventual) subclass of UcoObject, and FileFacet being a (eventual) subclass of UcoInherentCharacterizationThing."
}
]
}
21 changes: 21 additions & 0 deletions tests/examples/disjointedness_PASS_validation.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@prefix core: <https://ontology.unifiedcyberontology.org/uco/core/> .
@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 sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

[]
a sh:ValidationReport ;
sh:conforms "true"^^xsd:boolean ;
sh:result [
a sh:ValidationResult ;
sh:focusNode <http://example.org/kb/File-33a25932-3a1a-4828-a90f-d31818b495ce> ;
sh:resultMessage "observable:UcoInherentCharacterizationThing and observable:UcoObject are disjoint classes. Assigning both types to a single node will be an error in UCO 2.0.0."@en ;
sh:resultSeverity sh:Warning ;
sh:sourceConstraintComponent sh:NotConstraintComponent ;
sh:sourceShape core:UcoInherentCharacterizationThing-disjointWith-UcoObject-shape ;
sh:value <http://example.org/kb/File-33a25932-3a1a-4828-a90f-d31818b495ce> ;
] ;
.

9 changes: 9 additions & 0 deletions tests/examples/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ def test_database_records_XFAIL() -> None:
}
)

def test_disjointedness_PASS() -> None:
confirm_validation_results(
"disjointedness_PASS_validation.ttl",
True,
expected_focus_node_severities={
("http://example.org/kb/File-33a25932-3a1a-4828-a90f-d31818b495ce", str(NS_SH.Warning)),
}
)

def test_event_XFAIL() -> None:
confirm_validation_results(
"event_XFAIL_validation.ttl",
Expand Down

0 comments on commit f2b11ce

Please sign in to comment.