From a4802b532f8017a84b02c9bb26ef24004f473984 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Tue, 23 Jan 2024 15:27:43 -0500 Subject: [PATCH] Confirm an InvestigativeAction results in at least one ProvenanceRecord This new shape stemmed from discussion on CASE Issue 136. As a matter of preserving backwards compatibility, this patch introduces the shape requiring `ProvenanceRecord`s with a `sh:Warning`-level severity. In CASE 2.0.0, this requirement will be strengthened into a `sh:Violation`. A separate proposal will be filed with UCO to test the minimum qualified cardinality OWL structure. A draft of that syntax review system was used to test this patch. This patch adds a version floor for pySHACL to ensure an update in qualified value shape handling is included, which is necessary for the new property shape to function when using pySHACL. Disclaimer: References: * https://github.com/RDFLib/pySHACL/issues/213 * https://github.com/casework/CASE/issues/136 * https://github.com/casework/CASE/issues/146 Signed-off-by: Alex Nelson --- Makefile | 6 ++++- ontology/investigation/investigation.ttl | 32 +++++++++++++++++++----- requirements.txt | 1 + 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 requirements.txt diff --git a/Makefile b/Makefile index 15fa466..e50c231 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,8 @@ all: \ .git_submodule_init.done.log \ dependencies/UCO/dependencies/CASE-Utility-SHACL-Inheritance-Reviewer/case_shacl_inheritance_reviewer/__init__.py \ dependencies/UCO/dependencies/CASE-Utility-SHACL-Inheritance-Reviewer/setup.cfg \ - dependencies/UCO/requirements.txt + dependencies/UCO/requirements.txt \ + requirements.txt rm -rf venv $(PYTHON3) -m venv \ venv @@ -62,6 +63,9 @@ all: \ source venv/bin/activate \ && pip install \ --requirement dependencies/UCO/requirements.txt + source venv/bin/activate \ + && pip install \ + --requirement requirements.txt touch $@ check: \ diff --git a/ontology/investigation/investigation.ttl b/ontology/investigation/investigation.ttl index 4437d10..89287e8 100644 --- a/ontology/investigation/investigation.ttl +++ b/ontology/investigation/investigation.ttl @@ -178,14 +178,34 @@ investigation:InvestigativeAction owl:Class , sh:NodeShape ; - rdfs:subClassOf uco-action:Action ; + rdfs:subClassOf + uco-action:Action , + [ + a owl:Restriction ; + owl:onProperty uco-action:result ; + owl:onClass investigation:ProvenanceRecord ; + owl:minQualifiedCardinality "1"^^xsd:nonNegativeInteger ; + ] + ; rdfs:label "InvestigativeAction"@en ; rdfs:comment "An investigative action is something that may be done or performed within the context of an investigation, typically to examine or analyze evidence or other data."@en ; - sh:property [ - sh:class investigation:InvestigativeAction ; - sh:nodeKind sh:BlankNodeOrIRI ; - sh:path investigation:wasInformedBy ; - ] ; + sh:property + [ + sh:class investigation:InvestigativeAction ; + sh:nodeKind sh:BlankNodeOrIRI ; + sh:path investigation:wasInformedBy ; + ] , + [ + sh:message "An InvestigativeAction should have a ProvenanceRecord among its results. This will be a requirement in CASE 2.0.0."@en ; + sh:path uco-action:result ; + sh:qualifiedMinCount "1"^^xsd:integer ; + sh:qualifiedValueShape [ + a sh:NodeShape ; + sh:class investigation:ProvenanceRecord ; + ] ; + sh:severity sh:Warning ; + ] + ; sh:targetClass investigation:InvestigativeAction ; . diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d33bca9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyshacl >= 0.24.0