Skip to content

Commit

Permalink
Merge branch 'Feature-Issue-379' into unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnelson-nist committed Aug 19, 2022
2 parents 205412f + 8b84c5d commit fa3da83
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 1 deletion.
28 changes: 27 additions & 1 deletion ontology/uco/core/core.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,38 @@ core:externalReference
.

core:hasFacet
a owl:ObjectProperty ;
a
owl:ObjectProperty ,
owl:InverseFunctionalProperty
;
rdfs:label "hasFacet"@en ;
rdfs:comment "Further sets of properties characterizing a concept based on the particular context of the class and of the particular instance of the concept being characterized."@en ;
rdfs:range core:Facet ;
.

core:hasFacet-shape
a sh:PropertyShape ;
sh:path core:hasFacet ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:message "hasFacet must not be used to link two objects to one Facet."@en ;
sh:select """
PREFIX core: <https://ontology.unifiedcyberontology.org/uco/core/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT $this ?value
WHERE {
?value core:hasFacet $this .
?nOtherValue core:hasFacet $this .
FILTER ( ?value != ?nOtherValue )
FILTER NOT EXISTS {
?value owl:sameAs|^owl:sameAs ?nOtherValue .
}
}
""" ;
] ;
sh:targetObjectsOf core:hasFacet ;
.

core:isDirectional
a owl:DatatypeProperty ;
rdfs:label "isDirectional"@en ;
Expand Down
4 changes: 4 additions & 0 deletions tests/examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ all: \
co_XFAIL_validation.ttl \
configuration_setting_PASS_validation.ttl \
configuration_setting_XFAIL_validation.ttl \
has_facet_inverse_functional_PASS_validation.ttl \
has_facet_inverse_functional_XFAIL_validation.ttl \
hash_PASS_validation.ttl \
hash_XFAIL_validation.ttl \
location_PASS_validation.ttl \
Expand Down Expand Up @@ -91,6 +93,8 @@ check: \
co_XFAIL_validation.ttl \
configuration_setting_PASS_validation.ttl \
configuration_setting_XFAIL_validation.ttl \
has_facet_inverse_functional_PASS_validation.ttl \
has_facet_inverse_functional_XFAIL_validation.ttl \
hash_PASS_validation.ttl \
hash_XFAIL_validation.ttl \
location_PASS_validation.ttl \
Expand Down
30 changes: 30 additions & 0 deletions tests/examples/has_facet_inverse_functional_PASS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"@context": {
"kb": "http://example.org/kb/",
"core": "https://ontology.unifiedcyberontology.org/uco/core/",
"owl": "http://www.w3.org/2002/07/owl#"
},
"@graph": [
{
"@id": "kb:facet-1",
"@type": "core:Facet"
},
{
"@id": "kb:object-1",
"@type": "core:UcoObject",
"core:hasFacet": {
"@id": "kb:facet-1"
},
"owl:sameAs": {
"@id": "kb:object-2"
}
},
{
"@id": "kb:object-2",
"@type": "core:UcoObject",
"core:hasFacet": {
"@id": "kb:facet-1"
}
}
]
}
11 changes: 11 additions & 0 deletions tests/examples/has_facet_inverse_functional_PASS_validation.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@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 ;
.

26 changes: 26 additions & 0 deletions tests/examples/has_facet_inverse_functional_XFAIL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"@context": {
"kb": "http://example.org/kb/",
"core": "https://ontology.unifiedcyberontology.org/uco/core/"
},
"@graph": [
{
"@id": "kb:facet-1",
"@type": "core:Facet"
},
{
"@id": "kb:object-1",
"@type": "core:UcoObject",
"core:hasFacet": {
"@id": "kb:facet-1"
}
},
{
"@id": "kb:object-2",
"@type": "core:UcoObject",
"core:hasFacet": {
"@id": "kb:facet-1"
}
}
]
}
68 changes: 68 additions & 0 deletions tests/examples/has_facet_inverse_functional_XFAIL_validation.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@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 "false"^^xsd:boolean ;
sh:result
[
a sh:ValidationResult ;
sh:focusNode <http://example.org/kb/facet-1> ;
sh:resultMessage "hasFacet must not be used to link two objects to one Facet." ;
sh:resultPath core:hasFacet ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraint [
a sh:SPARQLConstraint ;
sh:message "hasFacet must not be used to link two objects to one Facet."@en ;
sh:select """
PREFIX core: <https://ontology.unifiedcyberontology.org/uco/core/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT $this ?value
WHERE {
?value core:hasFacet $this .
?nOtherValue core:hasFacet $this .
FILTER ( ?value != ?nOtherValue )
FILTER NOT EXISTS {
?value owl:sameAs|^owl:sameAs ?nOtherValue .
}
}
""" ;
] ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:sourceShape core:hasFacet-shape ;
sh:value <http://example.org/kb/object-1> ;
] ,
[
a sh:ValidationResult ;
sh:focusNode <http://example.org/kb/facet-1> ;
sh:resultMessage "hasFacet must not be used to link two objects to one Facet." ;
sh:resultPath core:hasFacet ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraint [
a sh:SPARQLConstraint ;
sh:message "hasFacet must not be used to link two objects to one Facet."@en ;
sh:select """
PREFIX core: <https://ontology.unifiedcyberontology.org/uco/core/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT $this ?value
WHERE {
?value core:hasFacet $this .
?nOtherValue core:hasFacet $this .
FILTER ( ?value != ?nOtherValue )
FILTER NOT EXISTS {
?value owl:sameAs|^owl:sameAs ?nOtherValue .
}
}
""" ;
] ;
sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
sh:sourceShape core:hasFacet-shape ;
sh:value <http://example.org/kb/object-2> ;
]
;
.

16 changes: 16 additions & 0 deletions tests/examples/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@ def test_configuration_setting_XFAIL_validation() -> None:
g = load_validation_graph("configuration_setting_XFAIL_validation.ttl", False)
assert isinstance(g, rdflib.Graph)

def test_has_facet_inverse_functional_PASS() -> None:
confirm_validation_results(
"has_facet_inverse_functional_PASS_validation.ttl",
True
)

def test_has_facet_inverse_functional_XFAIL() -> None:
confirm_validation_results(
"has_facet_inverse_functional_XFAIL_validation.ttl",
False,
expected_focus_node_severities={
("http://example.org/kb/facet-1", str(NS_SH.Violation))
}
)


def test_hash_PASS() -> None:
g = load_validation_graph("hash_PASS_validation.ttl", True)
assert isinstance(g, rdflib.Graph)
Expand Down

0 comments on commit fa3da83

Please sign in to comment.