From d2e27205457a9d94e07c29cfa67f0ec23ad3d75b Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 14 Jun 2024 11:59:55 -0400 Subject: [PATCH 1/6] Add Non/InformationResource and UUID rule exception A follow-on patch will regenerate Make-managed files. References: * https://github.com/ucoProject/UCO/issues/606 Signed-off-by: Alex Nelson --- ontology/uco/core/core.ttl | 34 +++++++++++++ ontology/uco/identity/identity.ttl | 5 +- ontology/uco/observable/observable.ttl | 21 +++++++- tests/examples/Makefile | 2 + tests/examples/information_resource_PASS.json | 50 +++++++++++++++++++ tests/examples/test_validation.py | 10 ++++ 6 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 tests/examples/information_resource_PASS.json diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index e4bf1777..df437303 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -284,6 +284,27 @@ core:IdentityAbstraction sh:targetClass core:IdentityAbstraction ; . +core:InformationResource + a + owl:Class , + sh:NodeShape + ; + rdfs:subClassOf core:UcoThing ; + owl:disjointWith core:NonInformationResource ; + sh:targetClass core:InformationResource ; + . + +core:InformationResource-disjointWith-NonInformationResource-shape + a sh:NodeShape ; + sh:message "core:InformationResource and core:NonInformationResource are disjoint classes. Assigning both types to a single node will be an error as of UCO 2.0.0."@en ; + sh:not [ + a sh:NodeShape ; + sh:class core:NonInformationResource ; + ] ; + sh:severity sh:Warning ; + sh:targetClass core:InformationResource ; + . + core:Item a owl:Class , @@ -317,6 +338,15 @@ core:ModusOperandi sh:targetClass core:ModusOperandi ; . +core:NonInformationResource + a + owl:Class , + sh:NodeShape + ; + rdfs:subClassOf core:UcoThing ; + sh:targetClass core:NonInformationResource ; + . + core:Relationship a owl:Class , @@ -485,6 +515,7 @@ core:UcoThing-identifier-regex-shape a sh:NodeShape ; rdfs:comment "This shape is given an independent IRI for applications that have sufficient controls in place to deactivate this advisory of node identification practice."@en ; rdfs:seeAlso sh:deactivated ; + sh:description "This shape advises that nodes identify themselves with IRIs that are sufficiently unique that collisions between independent node assigners are unlikely. This shape excepts nodes that are explicitly typed as Information Resources."@en ; sh:severity sh:Info ; sh:sparql [ a sh:SPARQLConstraint ; @@ -496,6 +527,9 @@ core:UcoThing-identifier-regex-shape SELECT $this WHERE { $this a/rdfs:subClassOf* core:UcoThing . + FILTER NOT EXISTS { + $this a/rdfs:subClassOf* core:InformationResource . + } FILTER ( ! REGEX ( STR($this), diff --git a/ontology/uco/identity/identity.ttl b/ontology/uco/identity/identity.ttl index 93c20b6f..edaccf9f 100644 --- a/ontology/uco/identity/identity.ttl +++ b/ontology/uco/identity/identity.ttl @@ -105,7 +105,10 @@ identity:Identity owl:Class , sh:NodeShape ; - rdfs:subClassOf core:IdentityAbstraction ; + rdfs:subClassOf + core:IdentityAbstraction , + core:NonInformationResource + ; rdfs:label "Identity"@en ; rdfs:comment "An identity is a grouping of identifying characteristics unique to an individual or organization."@en ; sh:targetClass identity:Identity ; diff --git a/ontology/uco/observable/observable.ttl b/ontology/uco/observable/observable.ttl index 37dc84be..e9a93ff7 100644 --- a/ontology/uco/observable/observable.ttl +++ b/ontology/uco/observable/observable.ttl @@ -2221,7 +2221,10 @@ observable:Device owl:Class , sh:NodeShape ; - rdfs:subClassOf observable:ObservableObject ; + rdfs:subClassOf + core:NonInformationResource , + observable:ObservableObject + ; rdfs:label "Device"@en ; rdfs:comment "A device is a piece of equipment or a mechanism designed to serve a special purpose or perform a special function. [based on https://www.merriam-webster.com/dictionary/device]"@en ; sh:targetClass observable:Device ; @@ -7359,12 +7362,26 @@ observable:WebPage owl:Class , sh:NodeShape ; - rdfs:subClassOf observable:ObservableObject ; + rdfs:subClassOf + core:InformationResource , + observable:WebResource + ; rdfs:label "WebPage"@en ; rdfs:comment "A web page is a specific collection of information provided by a website and displayed to a user in a web browser. A website typically consists of many web pages linked together in a coherent fashion. [based on https://en.wikipedia.org/wiki/Web_page]"@en ; sh:targetClass observable:WebPage ; . +observable:WebResource + a + owl:Class , + sh:NodeShape + ; + rdfs:subClassOf observable:ObservableObject ; + rdfs:label "WebResource"@en ; + rdfs:seeAlso ; + sh:targetClass observable:WebResource ; + . + observable:WhoIs a owl:Class , diff --git a/tests/examples/Makefile b/tests/examples/Makefile index 7921bb00..48be8ca5 100644 --- a/tests/examples/Makefile +++ b/tests/examples/Makefile @@ -35,6 +35,7 @@ all: \ has_facet_inverse_functional_XFAIL_validation.ttl \ hash_PASS_validation.ttl \ hash_XFAIL_validation.ttl \ + information_resource_PASS_validation.ttl \ location_PASS_validation.ttl \ location_XFAIL_validation.ttl \ message_thread_PASS_validation.ttl \ @@ -108,6 +109,7 @@ check: \ has_facet_inverse_functional_XFAIL_validation.ttl \ hash_PASS_validation.ttl \ hash_XFAIL_validation.ttl \ + information_resource_PASS_validation.ttl \ location_PASS_validation.ttl \ location_XFAIL_validation.ttl \ message_thread_PASS_validation.ttl \ diff --git a/tests/examples/information_resource_PASS.json b/tests/examples/information_resource_PASS.json new file mode 100644 index 00000000..bd977352 --- /dev/null +++ b/tests/examples/information_resource_PASS.json @@ -0,0 +1,50 @@ +{ + "@context": { + "core": "https://ontology.unifiedcyberontology.org/uco/core/", + "kb": "http://example.org/kb/", + "identity": "https://ontology.unifiedcyberontology.org/uco/identity/", + "observable": "https://ontology.unifiedcyberontology.org/uco/observable/", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#" + }, + "@graph": [ + { + "@id": "http://example.org/~bob", + "@type": [ + "identity:Person", + "observable:WebPage" + ], + "core:name": "Bob", + "core:description": "Bob's company home page.", + "rdfs:comment": "This node will trigger a warning from conflating a node as both a person and the person's home page.", + "rdfs:seeAlso": [ + { + "@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549" + }, + { + "@id": "kb:WebPage-1c05c378-124e-4d3c-898a-fb5a8d178cf8" + } + ] + }, + { + "@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549", + "@type": "identity:Person", + "core:name": "Bob", + "rdfs:seeAlso": { + "@id": "http://example.org/~bob" + } + }, + { + "@id": "kb:WebPage-1c05c378-124e-4d3c-898a-fb5a8d178cf8", + "@type": "observable:WebPage", + "core:description": "Bob's company home page.", + "rdfs:seeAlso": { + "@id": "http://example.org/~bob" + } + }, + { + "@id": "http://example.org/~chris", + "@type": "observable:WebResource", + "rdfs:comment": "This node will trigger an info-level result from not designating itself a InformationResource, and not ending with a UUID." + } + ] +} diff --git a/tests/examples/test_validation.py b/tests/examples/test_validation.py index d4f39e6a..71ad8a00 100644 --- a/tests/examples/test_validation.py +++ b/tests/examples/test_validation.py @@ -275,6 +275,16 @@ def test_hash_XFAIL() -> None: } ) +def test_information_resource_PASS_validation() -> None: + confirm_validation_results( + "information_resource_PASS_validation.ttl", + True, + expected_focus_node_severities={ + ("http://example.org/~bob", str(NS_SH.Warning)), + ("http://example.org/~chris", str(NS_SH.Info)), + } + ) + def test_co_PASS_validation() -> None: confirm_validation_results("co_PASS_validation.ttl", True) From da6c9442fdade4e59c4594a0950171bdd3577615 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 14 Jun 2024 12:00:51 -0400 Subject: [PATCH 2/6] Regenerate Make-managed files References: * https://github.com/ucoProject/UCO/issues/606 Signed-off-by: Alex Nelson --- .../information_resource_PASS_validation.ttl | 55 +++++++++++++++++++ tests/examples/uco_thing_XFAIL_validation.ttl | 9 +++ 2 files changed, 64 insertions(+) create mode 100644 tests/examples/information_resource_PASS_validation.ttl diff --git a/tests/examples/information_resource_PASS_validation.ttl b/tests/examples/information_resource_PASS_validation.ttl new file mode 100644 index 00000000..b1575af9 --- /dev/null +++ b/tests/examples/information_resource_PASS_validation.ttl @@ -0,0 +1,55 @@ +@prefix core: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix sh: . +@prefix xsd: . + +[] + a sh:ValidationReport ; + sh:conforms "true"^^xsd:boolean ; + sh:result + [ + a sh:ValidationResult ; + sh:focusNode ; + sh:resultMessage "core:InformationResource and core:NonInformationResource are disjoint classes. Assigning both types to a single node will be an error as of UCO 2.0.0."@en ; + sh:resultSeverity sh:Warning ; + sh:sourceConstraintComponent sh:NotConstraintComponent ; + sh:sourceShape core:InformationResource-disjointWith-NonInformationResource-shape ; + sh:value ; + ] , + [ + a sh:ValidationResult ; + sh:focusNode ; + sh:resultMessage "UcoThings are suggested to end with a UUID." ; + sh:resultSeverity sh:Info ; + sh:sourceConstraint [ + a sh:SPARQLConstraint ; + rdfs:seeAlso ; + sh:message "UcoThings are suggested to end with a UUID."@en ; + sh:select ''' + PREFIX rdfs: + PREFIX core: + SELECT $this + WHERE { + $this a/rdfs:subClassOf* core:UcoThing . + FILTER NOT EXISTS { + $this a/rdfs:subClassOf* core:InformationResource . + } + FILTER ( + ! REGEX ( + STR($this), + "[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$", + "i" + ) + ) + } + ''' ; + ] ; + sh:sourceConstraintComponent sh:SPARQLConstraintComponent ; + sh:sourceShape core:UcoThing-identifier-regex-shape ; + sh:value ; + ] + ; + . + diff --git a/tests/examples/uco_thing_XFAIL_validation.ttl b/tests/examples/uco_thing_XFAIL_validation.ttl index ab5f6013..67e35a37 100644 --- a/tests/examples/uco_thing_XFAIL_validation.ttl +++ b/tests/examples/uco_thing_XFAIL_validation.ttl @@ -24,6 +24,9 @@ SELECT $this WHERE { $this a/rdfs:subClassOf* core:UcoThing . + FILTER NOT EXISTS { + $this a/rdfs:subClassOf* core:InformationResource . + } FILTER ( ! REGEX ( STR($this), @@ -53,6 +56,9 @@ SELECT $this WHERE { $this a/rdfs:subClassOf* core:UcoThing . + FILTER NOT EXISTS { + $this a/rdfs:subClassOf* core:InformationResource . + } FILTER ( ! REGEX ( STR($this), @@ -113,6 +119,9 @@ SELECT $this WHERE { $this a/rdfs:subClassOf* core:UcoThing . + FILTER NOT EXISTS { + $this a/rdfs:subClassOf* core:InformationResource . + } FILTER ( ! REGEX ( STR($this), From 91a686aa43ef9a4004d36da4023f614b832b7ce7 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Mon, 24 Jun 2024 09:44:35 -0400 Subject: [PATCH 3/6] Update implementation with NeverInformationResource and market-analysts example A follow-on patch will regenerate Make-managed files. References: * https://github.com/ucoProject/UCO/issues/606 Signed-off-by: Alex Nelson --- ontology/uco/core/core.ttl | 17 +++++++++---- ontology/uco/identity/identity.ttl | 15 +++++++----- ontology/uco/observable/observable.ttl | 2 +- ontology/uco/types/types.ttl | 11 +++++++-- tests/examples/information_resource_PASS.json | 24 +++++++++++++++++++ 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index df437303..e114b566 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -290,16 +290,16 @@ core:InformationResource sh:NodeShape ; rdfs:subClassOf core:UcoThing ; - owl:disjointWith core:NonInformationResource ; + owl:disjointWith core:NeverInformationResource ; sh:targetClass core:InformationResource ; . -core:InformationResource-disjointWith-NonInformationResource-shape +core:InformationResource-disjointWith-NeverInformationResource-shape a sh:NodeShape ; - sh:message "core:InformationResource and core:NonInformationResource are disjoint classes. Assigning both types to a single node will be an error as of UCO 2.0.0."@en ; + sh:message "core:InformationResource and core:NeverInformationResource are disjoint classes. Assigning both types to a single node will be an error as of UCO 2.0.0."@en ; sh:not [ a sh:NodeShape ; - sh:class core:NonInformationResource ; + sh:class core:NeverInformationResource ; ] ; sh:severity sh:Warning ; sh:targetClass core:InformationResource ; @@ -338,6 +338,15 @@ core:ModusOperandi sh:targetClass core:ModusOperandi ; . +core:NeverInformationResource + a + owl:Class , + sh:NodeShape + ; + rdfs:subClassOf core:NonInformationResource ; + sh:targetClass core:NeverInformationResource ; + . + core:NonInformationResource a owl:Class , diff --git a/ontology/uco/identity/identity.ttl b/ontology/uco/identity/identity.ttl index edaccf9f..06df8e18 100644 --- a/ontology/uco/identity/identity.ttl +++ b/ontology/uco/identity/identity.ttl @@ -105,10 +105,7 @@ identity:Identity owl:Class , sh:NodeShape ; - rdfs:subClassOf - core:IdentityAbstraction , - core:NonInformationResource - ; + rdfs:subClassOf core:IdentityAbstraction ; rdfs:label "Identity"@en ; rdfs:comment "An identity is a grouping of identifying characteristics unique to an individual or organization."@en ; sh:targetClass identity:Identity ; @@ -163,7 +160,10 @@ identity:Organization owl:Class , sh:NodeShape ; - rdfs:subClassOf identity:Identity ; + rdfs:subClassOf + core:NeverInformationResource , + identity:Identity + ; rdfs:label "Organization"@en ; rdfs:comment "An organization is a grouping of identifying characteristics unique to a group of people who work together in an organized way for a shared purpose. [based on https://dictionary.cambridge.org/us/dictionary/english/organization]"@en ; sh:targetClass identity:Organization ; @@ -185,7 +185,10 @@ identity:Person owl:Class , sh:NodeShape ; - rdfs:subClassOf identity:Identity ; + rdfs:subClassOf + core:NeverInformationResource , + identity:Identity + ; rdfs:label "Person"@en ; rdfs:comment "A person is a grouping of identifying characteristics unique to a human being regarded as an individual. [based on https://www.lexico.com/en/definition/person]"@en ; sh:targetClass identity:Person ; diff --git a/ontology/uco/observable/observable.ttl b/ontology/uco/observable/observable.ttl index e9a93ff7..62a44d69 100644 --- a/ontology/uco/observable/observable.ttl +++ b/ontology/uco/observable/observable.ttl @@ -2222,7 +2222,7 @@ observable:Device sh:NodeShape ; rdfs:subClassOf - core:NonInformationResource , + core:NeverInformationResource , observable:ObservableObject ; rdfs:label "Device"@en ; diff --git a/ontology/uco/types/types.ttl b/ontology/uco/types/types.ttl index 0b8ac9c7..7db968a5 100644 --- a/ontology/uco/types/types.ttl +++ b/ontology/uco/types/types.ttl @@ -57,7 +57,10 @@ types:Dictionary owl:Class , sh:NodeShape ; - rdfs:subClassOf core:UcoInherentCharacterizationThing ; + rdfs:subClassOf + core:NeverInformationResource , + core:UcoInherentCharacterizationThing + ; rdfs:label "Dictionary"@en ; rdfs:comment "A dictionary is list of (term/key, value) pairs with each term/key existing no more than once."@en ; sh:property [ @@ -101,7 +104,10 @@ types:Hash owl:Class , sh:NodeShape ; - rdfs:subClassOf core:UcoInherentCharacterizationThing ; + rdfs:subClassOf + core:NeverInformationResource , + core:UcoInherentCharacterizationThing + ; rdfs:label "Hash"@en ; rdfs:comment "A hash is a grouping of characteristics unique to the result of applying a mathematical algorithm that maps data of arbitrary size to a bit string (the 'hash') and is a one-way function, that is, a function which is practically infeasible to invert. This is commonly used for integrity checking of data. [based on https://en.wikipedia.org/wiki/Cryptographic_hash_function]"@en ; sh:property @@ -184,6 +190,7 @@ types:Thread ; rdfs:subClassOf co:Bag , + core:NeverInformationResource , core:UcoThing ; rdfs:label "Thread"@en ; diff --git a/tests/examples/information_resource_PASS.json b/tests/examples/information_resource_PASS.json index bd977352..12af7bbf 100644 --- a/tests/examples/information_resource_PASS.json +++ b/tests/examples/information_resource_PASS.json @@ -45,6 +45,30 @@ "@id": "http://example.org/~chris", "@type": "observable:WebResource", "rdfs:comment": "This node will trigger an info-level result from not designating itself a InformationResource, and not ending with a UUID." + }, + { + "@id": "https://mc.example.co.jp/", + "@type": "observable:WebPage", + "rdfs:comment": [ + "This node should trigger no errors, even when incorporating the annotations on the same identifier from another JSON dict.", + "This JSON dict was provided by a market analyst in Japan." + ] + }, + { + "@id": "https://mc.example.co.jp/", + "@type": ["core:NonInformationResource", "observable:WebResource"], + "rdfs:comment": [ + "This node should trigger no errors, even when incorporating the annotations on the same identifier from another JSON dict.", + "This JSON dict was provided by a market analyst in France." + ] + }, + { + "@id": "https://mc.example.co.jp/lang-fr/", + "@type": "observable:WebPage", + "rdfs:comment": [ + "This node should trigger no errors.", + "This JSON dict was provided by a market analyst in France." + ] } ] } From f2939e80a9a88270f733262d224cea6d343b03e2 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Mon, 24 Jun 2024 09:44:51 -0400 Subject: [PATCH 4/6] Regenerate Make-managed files References: * https://github.com/ucoProject/UCO/issues/606 Signed-off-by: Alex Nelson --- tests/examples/information_resource_PASS_validation.ttl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/examples/information_resource_PASS_validation.ttl b/tests/examples/information_resource_PASS_validation.ttl index b1575af9..2656c460 100644 --- a/tests/examples/information_resource_PASS_validation.ttl +++ b/tests/examples/information_resource_PASS_validation.ttl @@ -12,10 +12,10 @@ [ a sh:ValidationResult ; sh:focusNode ; - sh:resultMessage "core:InformationResource and core:NonInformationResource are disjoint classes. Assigning both types to a single node will be an error as of UCO 2.0.0."@en ; + sh:resultMessage "core:InformationResource and core:NeverInformationResource are disjoint classes. Assigning both types to a single node will be an error as of UCO 2.0.0."@en ; sh:resultSeverity sh:Warning ; sh:sourceConstraintComponent sh:NotConstraintComponent ; - sh:sourceShape core:InformationResource-disjointWith-NonInformationResource-shape ; + sh:sourceShape core:InformationResource-disjointWith-NeverInformationResource-shape ; sh:value ; ] , [ From 4138e7a918dac37488a8c6080262cf9fd8f47367 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 28 Jun 2024 12:20:36 -0400 Subject: [PATCH 5/6] Enforce InformationResource and NeverInformationResource disjointedness A follow-on patch will regenerate Make-managed files. References: * https://github.com/ucoProject/UCO/issues/606 Signed-off-by: Alex Nelson --- ontology/uco/core/core.ttl | 3 +- tests/examples/Makefile | 2 ++ tests/examples/information_resource_PASS.json | 7 ++--- .../examples/information_resource_XFAIL.json | 29 +++++++++++++++++++ tests/examples/test_validation.py | 11 ++++++- 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 tests/examples/information_resource_XFAIL.json diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index 600c35f9..ca3e3601 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -296,12 +296,11 @@ core:InformationResource core:InformationResource-disjointWith-NeverInformationResource-shape a sh:NodeShape ; - sh:message "core:InformationResource and core:NeverInformationResource are disjoint classes. Assigning both types to a single node will be an error as of UCO 2.0.0."@en ; + sh:message "core:InformationResource and core:NeverInformationResource are disjoint classes."@en ; sh:not [ a sh:NodeShape ; sh:class core:NeverInformationResource ; ] ; - sh:severity sh:Warning ; sh:targetClass core:InformationResource ; . diff --git a/tests/examples/Makefile b/tests/examples/Makefile index 80991edc..1e27456d 100644 --- a/tests/examples/Makefile +++ b/tests/examples/Makefile @@ -36,6 +36,7 @@ all: \ hash_PASS_validation.ttl \ hash_XFAIL_validation.ttl \ information_resource_PASS_validation.ttl \ + information_resource_XFAIL_validation.ttl \ location_PASS_validation.ttl \ location_XFAIL_validation.ttl \ message_thread_PASS_validation.ttl \ @@ -110,6 +111,7 @@ check: \ hash_PASS_validation.ttl \ hash_XFAIL_validation.ttl \ information_resource_PASS_validation.ttl \ + information_resource_XFAIL_validation.ttl \ location_PASS_validation.ttl \ location_XFAIL_validation.ttl \ message_thread_PASS_validation.ttl \ diff --git a/tests/examples/information_resource_PASS.json b/tests/examples/information_resource_PASS.json index 12af7bbf..ecdd397e 100644 --- a/tests/examples/information_resource_PASS.json +++ b/tests/examples/information_resource_PASS.json @@ -9,13 +9,9 @@ "@graph": [ { "@id": "http://example.org/~bob", - "@type": [ - "identity:Person", - "observable:WebPage" - ], + "@type": "observable:WebResource", "core:name": "Bob", "core:description": "Bob's company home page.", - "rdfs:comment": "This node will trigger a warning from conflating a node as both a person and the person's home page.", "rdfs:seeAlso": [ { "@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549" @@ -25,6 +21,7 @@ } ] }, + { "@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549", "@type": "identity:Person", diff --git a/tests/examples/information_resource_XFAIL.json b/tests/examples/information_resource_XFAIL.json new file mode 100644 index 00000000..b1f7f080 --- /dev/null +++ b/tests/examples/information_resource_XFAIL.json @@ -0,0 +1,29 @@ +{ + "@context": { + "core": "https://ontology.unifiedcyberontology.org/uco/core/", + "kb": "http://example.org/kb/", + "identity": "https://ontology.unifiedcyberontology.org/uco/identity/", + "observable": "https://ontology.unifiedcyberontology.org/uco/observable/", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#" + }, + "@graph": [ + { + "@id": "http://example.org/~bob", + "@type": [ + "identity:Person", + "observable:WebPage" + ], + "core:name": "Bob", + "core:description": "Bob's company home page.", + "rdfs:comment": "This node will trigger an error from conflating a node as both a person and the person's home page.", + "rdfs:seeAlso": [ + { + "@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549" + }, + { + "@id": "kb:WebPage-1c05c378-124e-4d3c-898a-fb5a8d178cf8" + } + ] + } + ] +} diff --git a/tests/examples/test_validation.py b/tests/examples/test_validation.py index c5893713..ff125931 100644 --- a/tests/examples/test_validation.py +++ b/tests/examples/test_validation.py @@ -274,11 +274,20 @@ def test_information_resource_PASS_validation() -> None: "information_resource_PASS_validation.ttl", True, expected_focus_node_severities={ - ("http://example.org/~bob", str(NS_SH.Warning)), + ("http://example.org/~bob", str(NS_SH.Info)), ("http://example.org/~chris", str(NS_SH.Info)), } ) +def test_information_resource_XFAIL_validation() -> None: + confirm_validation_results( + "information_resource_XFAIL_validation.ttl", + False, + expected_focus_node_severities={ + ("http://example.org/~bob", str(NS_SH.Violation)), + } + ) + def test_co_PASS_validation() -> None: confirm_validation_results("co_PASS_validation.ttl", True) From 6a4ccdce57000d4283bcdc4d50b30ced697d8433 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 28 Jun 2024 12:36:47 -0400 Subject: [PATCH 6/6] Regenerate Make-managed files References: * https://github.com/ucoProject/UCO/issues/606 Signed-off-by: Alex Nelson --- .../information_resource_PASS_validation.ttl | 31 ++++++++++++++++--- .../information_resource_XFAIL_validation.ttl | 21 +++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 tests/examples/information_resource_XFAIL_validation.ttl diff --git a/tests/examples/information_resource_PASS_validation.ttl b/tests/examples/information_resource_PASS_validation.ttl index 2656c460..3c878b4c 100644 --- a/tests/examples/information_resource_PASS_validation.ttl +++ b/tests/examples/information_resource_PASS_validation.ttl @@ -12,10 +12,33 @@ [ a sh:ValidationResult ; sh:focusNode ; - sh:resultMessage "core:InformationResource and core:NeverInformationResource are disjoint classes. Assigning both types to a single node will be an error as of UCO 2.0.0."@en ; - sh:resultSeverity sh:Warning ; - sh:sourceConstraintComponent sh:NotConstraintComponent ; - sh:sourceShape core:InformationResource-disjointWith-NeverInformationResource-shape ; + sh:resultMessage "UcoThings are suggested to end with a UUID." ; + sh:resultSeverity sh:Info ; + sh:sourceConstraint [ + a sh:SPARQLConstraint ; + rdfs:seeAlso ; + sh:message "UcoThings are suggested to end with a UUID."@en ; + sh:select ''' + PREFIX rdfs: + PREFIX core: + SELECT $this + WHERE { + $this a/rdfs:subClassOf* core:UcoThing . + FILTER NOT EXISTS { + $this a/rdfs:subClassOf* core:InformationResource . + } + FILTER ( + ! REGEX ( + STR($this), + "[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$", + "i" + ) + ) + } + ''' ; + ] ; + sh:sourceConstraintComponent sh:SPARQLConstraintComponent ; + sh:sourceShape core:UcoThing-identifier-regex-shape ; sh:value ; ] , [ diff --git a/tests/examples/information_resource_XFAIL_validation.ttl b/tests/examples/information_resource_XFAIL_validation.ttl new file mode 100644 index 00000000..3d7bc871 --- /dev/null +++ b/tests/examples/information_resource_XFAIL_validation.ttl @@ -0,0 +1,21 @@ +@prefix core: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix sh: . +@prefix xsd: . + +[] + a sh:ValidationReport ; + sh:conforms "false"^^xsd:boolean ; + sh:result [ + a sh:ValidationResult ; + sh:focusNode ; + sh:resultMessage "core:InformationResource and core:NeverInformationResource are disjoint classes."@en ; + sh:resultSeverity sh:Violation ; + sh:sourceConstraintComponent sh:NotConstraintComponent ; + sh:sourceShape core:InformationResource-disjointWith-NeverInformationResource-shape ; + sh:value ; + ] ; + . +