Skip to content

Commit 2c3d518

Browse files
committed
Merged 13_validation_phase.ttl files (replaces SPARQL constraints with equivalent SHACL code where necessary).
1 parent 8daba32 commit 2c3d518

5 files changed

Lines changed: 154 additions & 200 deletions

File tree

rocrate_validator/profiles/five-safes-crate/12_check_phase.ttl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ five-safes-crate:CheckValueActionStatusMustHaveAllowedValues
9898

9999
#=== SHOULD shapes ===#
100100

101-
#--- THIS NEEDS FURTHER CHECKS ---#
102-
103101
five-safes-crate:RootDataEntityShouldMentionCheckValueObject
104102
a sh:NodeShape ;
105103
sh:name "RootDataEntity" ;

rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl renamed to rocrate_validator/profiles/five-safes-crate/13_validation_phase.ttl

Lines changed: 154 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,136 @@
1919
@prefix schema: <http://schema.org/> .
2020
@prefix purl: <http://purl.org/dc/terms/> .
2121
@prefix sh: <http://www.w3.org/ns/shacl#> .
22+
@prefix shp: <https://w3id.org/shp#> .
2223
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
2324
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2425

2526

26-
five-safes-crate:RootDataEntityShouldMentionValidationCheckObject
27+
#=== MUST shapes ===#
28+
29+
five-safes-crate:ValidationCheckObjectHasDescriptiveNameAndIsAssessAction
2730
a sh:NodeShape ;
28-
sh:name "RootDataEntity" ;
29-
sh:targetClass ro-crate:RootDataEntity ;
31+
sh:name "ValidationCheck" ;
3032
sh:description "" ;
3133

32-
sh:sparql [
33-
a sh:SPARQLConstraint ;
34-
sh:name "mentions" ;
35-
sh:description "RootDataEntity SHOULD mention a ValidationCheck object." ;
34+
sh:target [
35+
a sh:SPARQLTarget ;
36+
sh:select """
37+
PREFIX schema: <http://schema.org/>
38+
PREFIX shp: <https://w3id.org/shp#>
39+
40+
SELECT ?this
41+
WHERE {
42+
?this schema:additionalType shp:ValidationCheck .
43+
}
44+
""" ;
45+
] ;
46+
47+
sh:property [
48+
sh:path rdf:type ;
49+
sh:minCount 1 ;
50+
sh:hasValue schema:AssessAction;
51+
sh:severity sh:Violation ;
52+
sh:message "ValidationCheck MUST be a `AssessAction`." ;
53+
] ;
54+
55+
sh:property [
56+
sh:a sh:PropertyShape ;
57+
sh:name "name" ;
58+
sh:description "ValidationCheck MUST have a human readable name string." ;
59+
sh:path schema:name ;
60+
sh:datatype xsd:string ;
61+
sh:severity sh:Violation ;
62+
sh:message "ValidationCheck MUST have a human readable name string." ;
63+
] .
64+
65+
66+
five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue
67+
a sh:NodeShape ;
68+
sh:name "ValidationCheck" ;
69+
sh:target [
70+
a sh:SPARQLTarget ;
71+
sh:select """
72+
PREFIX schema: <http://schema.org/>
73+
PREFIX shp: <https://w3id.org/shp#>
74+
75+
SELECT ?this
76+
WHERE {
77+
?this schema:additionalType shp:ValidationCheck ;
78+
schema:actionStatus ?status .
79+
}
80+
""" ;
81+
] ;
82+
83+
sh:property [
84+
a sh:PropertyShape ;
85+
sh:name "actionStatus" ;
86+
sh:description "The `actionStatus` of ValidationCheck MUST have an allowed value (see https://schema.org/ActionStatusType)." ;
87+
sh:path schema:actionStatus ;
88+
sh:in (
89+
"http://schema.org/PotentialActionStatus"
90+
"http://schema.org/ActiveActionStatus"
91+
"http://schema.org/CompletedActionStatus"
92+
"http://schema.org/FailedActionStatus"
93+
) ;
94+
sh:severity sh:Violation ;
95+
sh:message "The `actionStatus` of ValidationCheck MUST have an allowed value (see https://schema.org/ActionStatusType)." ;
96+
] .
97+
98+
99+
five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue
100+
a sh:NodeShape ;
101+
sh:name "ValidationCheck" ;
102+
sh:target [
103+
a sh:SPARQLTarget ;
36104
sh:select """
37105
PREFIX schema: <http://schema.org/>
38-
PREFIX shp: <https://w3id.org/shp#>
39-
SELECT $this
106+
PREFIX shp: <https://w3id.org/shp#>
107+
108+
SELECT ?this
40109
WHERE {
41-
FILTER NOT EXISTS{
42-
$this schema:mentions ?action .
43-
?action schema:additionalType shp:ValidationCheck .
44-
}
110+
?this schema:additionalType shp:ValidationCheck .
45111
}
46112
""" ;
113+
] ;
114+
115+
sh:property [
116+
a sh:PropertyShape ;
117+
sh:minCount 1 ;
118+
sh:name "actionStatus" ;
119+
sh:description "actionStatus MUST be either PotentialActionStatus, ActiveActionStatus, CompletedActionStatus, or FailedActionStatus." ;
120+
sh:path schema:actionStatus ;
121+
sh:in (
122+
"http://schema.org/PotentialActionStatus"
123+
"http://schema.org/ActiveActionStatus"
124+
"http://schema.org/CompletedActionStatus"
125+
"http://schema.org/FailedActionStatus"
126+
) ;
127+
sh:severity sh:Violation ;
128+
sh:message "actionStatus MUST be either PotentialActionStatus, ActiveActionStatus, CompletedActionStatus, or FailedActionStatus." ;
129+
] .
130+
131+
132+
#=== SHOULD shapes ===#
133+
134+
five-safes-crate:RootDataEntityShouldMentionValidationCheckObject
135+
a sh:NodeShape ;
136+
sh:name "RootDataEntity" ;
137+
sh:targetClass ro-crate:RootDataEntity ;
138+
sh:description "" ;
139+
140+
sh:property [
141+
sh:path schema:mentions ;
142+
143+
# Require at least one mentioned node that is a ValidationCheck (via additionalType)
144+
sh:qualifiedValueShape [
145+
sh:property [
146+
sh:path schema:additionalType ;
147+
sh:hasValue shp:ValidationCheck ;
148+
] ;
149+
] ;
150+
sh:qualifiedMinCount 1 ;
151+
47152
sh:severity sh:Warning ;
48153
sh:message "RootDataEntity SHOULD mention a ValidationCheck object." ;
49154
] .
@@ -163,3 +268,39 @@ five-safes-crate:DownloadActionShouldHaveEndTimeIfBegun
163268
sh:description "ValidationCheck SHOULD have the `endTime` property if `actionStatus` is either CompletedActionStatus or FailedActionStatus." ;
164269
sh:message "ValidationCheck SHOULD have the `endTime` property if `actionStatus` is either CompletedActionStatus or FailedActionStatus." ;
165270
] .
271+
272+
273+
#=== MAY shapes ===#
274+
275+
five-safes-crate:DownloadActionMayHaveStartTimeIfBegun
276+
a sh:NodeShape ;
277+
sh:name "ValidationCheck" ;
278+
sh:description "" ;
279+
sh:target [
280+
a sh:SPARQLTarget ;
281+
sh:select """
282+
PREFIX schema: <http://schema.org/>
283+
PREFIX shp: <https://w3id.org/shp#>
284+
SELECT ?this
285+
WHERE {
286+
?this schema:additionalType shp:ValidationCheck ;
287+
schema:actionStatus ?status .
288+
FILTER(?status IN (
289+
"http://schema.org/CompletedActionStatus",
290+
"http://schema.org/FailedActionStatus",
291+
"http://schema.org/ActiveActionStatus"
292+
))
293+
}
294+
""" ;
295+
] ;
296+
297+
sh:property [
298+
a sh:PropertyShape ;
299+
sh:name "StartTime" ;
300+
sh:path schema:startTime ;
301+
sh:minCount 1 ;
302+
sh:maxCount 1 ;
303+
sh:severity sh:Info ;
304+
sh:description "ValidationCheck MAY have the `startTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ;
305+
sh:message "ValidationCheck MAY have the `startTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ;
306+
] .

rocrate_validator/profiles/five-safes-crate/may/13_validation_phase.ttl

Lines changed: 0 additions & 57 deletions
This file was deleted.

rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl

Lines changed: 0 additions & 126 deletions
This file was deleted.

tests/integration/profiles/five-safes-crate/test_5src_12_check_phase.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ def test_5src_check_value_has_action_status_with_not_allowed_value():
188188

189189
# ----- SHOULD fails tests
190190

191-
# --- THIS NEEDS FURTHER CHECKS ---#
192-
193191

194192
def test_5src_root_data_entity_does_not_mention_check_value_entity():
195193
sparql = """

0 commit comments

Comments
 (0)