Skip to content

Commit 3b10e2f

Browse files
authored
Merge pull request #46 from eScienceLab/45-implement-check-phase-ruleset
Implement Check Phase Ruleset
2 parents d95af78 + eb5384a commit 3b10e2f

File tree

5 files changed

+781
-0
lines changed

5 files changed

+781
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright (c) 2025 eScience Lab, The University of Manchester
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
@prefix ro: <./> .
16+
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
17+
@prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> .
18+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
19+
@prefix schema: <http://schema.org/> .
20+
@prefix purl: <http://purl.org/dc/terms/> .
21+
@prefix sh: <http://www.w3.org/ns/shacl#> .
22+
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
23+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
24+
25+
26+
five-safes-crate:CheckValueMayHaveStartTime
27+
a sh:NodeShape ;
28+
sh:name "CheckValue" ;
29+
sh:description "" ;
30+
sh:target [
31+
a sh:SPARQLTarget ;
32+
sh:select """
33+
PREFIX schema: <http://schema.org/>
34+
PREFIX shp: <https://w3id.org/shp#>
35+
SELECT ?this
36+
WHERE {
37+
?this schema:additionalType shp:CheckValue ;
38+
schema:actionStatus ?status .
39+
FILTER(?status IN (
40+
"http://schema.org/CompletedActionStatus",
41+
"http://schema.org/FailedActionStatus",
42+
"http://schema.org/ActiveActionStatus"
43+
))
44+
}
45+
""" ;
46+
] ;
47+
48+
sh:property [
49+
a sh:PropertyShape ;
50+
sh:name "StartTime" ;
51+
sh:path schema:startTime ;
52+
sh:minCount 1 ;
53+
sh:maxCount 1 ;
54+
sh:severity sh:Info ;
55+
sh:message "`CheckValue` MAY have the `startTime` property." ;
56+
] .
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Copyright (c) 2025 eScience Lab, The University of Manchester
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
@prefix ro: <./> .
16+
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
17+
@prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> .
18+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
19+
@prefix schema: <http://schema.org/> .
20+
@prefix purl: <http://purl.org/dc/terms/> .
21+
@prefix sh: <http://www.w3.org/ns/shacl#> .
22+
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
23+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
24+
25+
26+
five-safes-crate:CheckValueObjectHasDescriptiveNameAndIsAssessAction
27+
a sh:NodeShape ;
28+
sh:name "CheckValue" ;
29+
sh:description "" ;
30+
31+
sh:target [
32+
a sh:SPARQLTarget ;
33+
sh:select """
34+
PREFIX schema: <http://schema.org/>
35+
PREFIX shp: <https://w3id.org/shp#>
36+
37+
SELECT ?this
38+
WHERE {
39+
?this schema:additionalType shp:CheckValue .
40+
}
41+
""" ;
42+
] ;
43+
44+
sh:property [
45+
sh:path rdf:type ;
46+
sh:minCount 1 ;
47+
sh:hasValue schema:AssessAction;
48+
sh:severity sh:Violation ;
49+
sh:message "CheckValue MUST be a `schema:AssessAction`." ;
50+
] ;
51+
52+
sh:property [
53+
sh:a sh:PropertyShape ;
54+
sh:name "name" ;
55+
sh:description "CheckValue MUST have a human readable name string." ;
56+
sh:path schema:name ;
57+
sh:datatype xsd:string ;
58+
sh:severity sh:Violation ;
59+
sh:message "CheckValue MUST have a human readable name string." ;
60+
] .
61+
62+
five-safes-crate:CheckValueStartTimeMustFollowISOStandard
63+
a sh:NodeShape ;
64+
sh:name "CheckValue" ;
65+
sh:description "" ;
66+
sh:target [
67+
a sh:SPARQLTarget ;
68+
sh:select """
69+
PREFIX schema: <http://schema.org/>
70+
PREFIX shp: <https://w3id.org/shp#>
71+
SELECT ?this
72+
WHERE {
73+
?this schema:additionalType shp:CheckValue ;
74+
schema:startTime ?o
75+
76+
}
77+
""" ;
78+
] ;
79+
80+
sh:property [
81+
a sh:PropertyShape ;
82+
sh:name "StartTime" ;
83+
sh:path schema:startTime ;
84+
sh:pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt][0-9]{2}:[0-9]{2}:[0-9]{2}([.|,][0-9]+)?(Z|z|[+-][0-9]{2}:[0-9]{2})$" ;
85+
sh:severity sh:Violation ;
86+
sh:message "`CheckValue` --> `startTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
87+
] .
88+
89+
90+
five-safes-crate:CheckValueEndTimeMustFollowISOStandard
91+
a sh:NodeShape ;
92+
sh:name "CheckValue" ;
93+
sh:description "" ;
94+
sh:target [
95+
a sh:SPARQLTarget ;
96+
sh:select """
97+
PREFIX schema: <http://schema.org/>
98+
PREFIX shp: <https://w3id.org/shp#>
99+
SELECT ?this
100+
WHERE {
101+
?this schema:additionalType shp:CheckValue ;
102+
schema:endTime ?o
103+
104+
}
105+
""" ;
106+
] ;
107+
108+
sh:property [
109+
a sh:PropertyShape ;
110+
sh:name "EndTime" ;
111+
sh:path schema:endTime ;
112+
sh:pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt][0-9]{2}:[0-9]{2}:[0-9]{2}([.|,][0-9]+)?(Z|z|[+-][0-9]{2}:[0-9]{2})$" ;
113+
sh:severity sh:Violation ;
114+
sh:message "`CheckValue` --> `endTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
115+
] .
116+
117+
118+
five-safes-crate:CheckValueActionStatusMustHaveAllowedValues
119+
a sh:NodeShape ;
120+
sh:name "CheckValue" ;
121+
sh:description "" ;
122+
123+
sh:target [
124+
a sh:SPARQLTarget ;
125+
sh:select """
126+
PREFIX schema: <http://schema.org/>
127+
PREFIX shp: <https://w3id.org/shp#>
128+
129+
SELECT ?this
130+
WHERE {
131+
?this schema:additionalType shp:CheckValue ;
132+
schema:actionStatus ?status .
133+
}
134+
""" ;
135+
] ;
136+
137+
sh:property [
138+
a sh:PropertyShape ;
139+
sh:name "ActionStatus" ;
140+
sh:path schema:actionStatus ;
141+
sh:in (
142+
"http://schema.org/PotentialActionStatus"
143+
"http://schema.org/ActiveActionStatus"
144+
"http://schema.org/CompletedActionStatus"
145+
"http://schema.org/FailedActionStatus"
146+
) ;
147+
sh:severity sh:Violation ;
148+
sh:message "`CheckValue` --> `actionStatus` MUST have one of the allowed values." ;
149+
] .
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# Copyright (c) 2025 eScience Lab, The University of Manchester
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
@prefix ro: <./> .
16+
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
17+
@prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> .
18+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
19+
@prefix schema: <http://schema.org/> .
20+
@prefix purl: <http://purl.org/dc/terms/> .
21+
@prefix sh: <http://www.w3.org/ns/shacl#> .
22+
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
23+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
24+
25+
26+
five-safes-crate:RootDataEntityShouldMentionCheckValueObject
27+
a sh:NodeShape ;
28+
sh:name "RootDataEntity" ;
29+
sh:targetClass ro-crate:RootDataEntity ;
30+
sh:description "" ;
31+
32+
sh:sparql [
33+
a sh:SPARQLConstraint ;
34+
sh:name "mentions" ;
35+
sh:description "RootDataEntity SHOULD mention a check value object." ;
36+
sh:select """
37+
PREFIX schema: <http://schema.org/>
38+
PREFIX shp: <https://w3id.org/shp#>
39+
SELECT $this
40+
WHERE {
41+
FILTER NOT EXISTS{
42+
$this schema:mentions ?action .
43+
?action schema:additionalType shp:CheckValue .
44+
}
45+
}
46+
""" ;
47+
sh:severity sh:Warning ;
48+
sh:message "RootDataEntity SHOULD mention a check value object." ;
49+
] .
50+
51+
52+
five-safes-crate:CheckValueObjectShouldPointToRootDataEntity
53+
a sh:NodeShape ;
54+
sh:name "CheckValue" ;
55+
sh:description "" ;
56+
sh:target [
57+
a sh:SPARQLTarget ;
58+
sh:select """
59+
PREFIX schema: <http://schema.org/>
60+
PREFIX shp: <https://w3id.org/shp#>
61+
SELECT ?this
62+
WHERE {
63+
?this schema:additionalType shp:CheckValue .
64+
}
65+
""" ;
66+
] ;
67+
68+
sh:property [
69+
a sh:PropertyShape ;
70+
sh:name "object" ;
71+
sh:path schema:object ;
72+
sh:minCount 1 ;
73+
sh:hasValue ro-crate:RootDataEntity ;
74+
sh:severity sh:Warning ;
75+
sh:message "`CheckValue` --> `object` SHOULD point to the root of the RO-Crate" ;
76+
] .
77+
78+
79+
five-safes-crate:CheckValueInstrumentShouldPointToEntityTypedDefinedTerm
80+
a sh:NodeShape ;
81+
sh:name "CheckValue" ;
82+
sh:description "" ;
83+
sh:target [
84+
a sh:SPARQLTarget ;
85+
sh:select """
86+
PREFIX schema: <http://schema.org/>
87+
PREFIX shp: <https://w3id.org/shp#>
88+
SELECT ?this
89+
WHERE {
90+
?this schema:additionalType shp:CheckValue .
91+
}
92+
""" ;
93+
] ;
94+
95+
sh:property [
96+
a sh:PropertyShape ;
97+
sh:name "instrument" ;
98+
sh:path schema:instrument ;
99+
sh:minCount 1 ;
100+
sh:class schema:DefinedTerm ;
101+
sh:severity sh:Warning ;
102+
sh:message "`CheckValue` --> `instrument` SHOULD point to an entity typed `schema:DefinedTerm`" ;
103+
] .
104+
105+
106+
five-safes-crate:CheckValueAgentShouldIdentifyTheAgentWhoPerformnedTheCheck
107+
a sh:NodeShape ;
108+
sh:name "CheckValue" ;
109+
sh:description "" ;
110+
sh:target [
111+
a sh:SPARQLTarget ;
112+
sh:select """
113+
PREFIX schema: <http://schema.org/>
114+
PREFIX shp: <https://w3id.org/shp#>
115+
SELECT ?this
116+
WHERE {
117+
?this schema:additionalType shp:CheckValue .
118+
}
119+
""" ;
120+
] ;
121+
122+
sh:property [
123+
a sh:PropertyShape ;
124+
sh:name "agent" ;
125+
sh:path schema:agent ;
126+
sh:minCount 1 ;
127+
sh:nodeKind sh:IRI ;
128+
sh:severity sh:Warning ;
129+
sh:message "`CheckValue` --> `agent` SHOULD reference the agent who initiated the check" ;
130+
] .
131+
132+
133+
five-safes-crate:CheckValueShouldHaveEndTime
134+
a sh:NodeShape ;
135+
sh:name "CheckValue" ;
136+
sh:description "" ;
137+
sh:target [
138+
a sh:SPARQLTarget ;
139+
sh:select """
140+
PREFIX schema: <http://schema.org/>
141+
PREFIX shp: <https://w3id.org/shp#>
142+
SELECT ?this
143+
WHERE {
144+
?this schema:additionalType shp:CheckValue ;
145+
schema:actionStatus ?status .
146+
FILTER(?status IN (
147+
"http://schema.org/CompletedActionStatus",
148+
"http://schema.org/FailedActionStatus"
149+
))
150+
}
151+
""" ;
152+
] ;
153+
154+
sh:property [
155+
a sh:PropertyShape ;
156+
sh:name "EndTime" ;
157+
sh:path schema:endTime ;
158+
sh:minCount 1 ;
159+
sh:maxCount 1 ;
160+
sh:severity sh:Warning ;
161+
sh:message "`CheckValue` SHOULD have the `endTime` property." ;
162+
] .
163+
164+
165+
five-safes-crate:CheckValueShouldHaveActionStatus
166+
a sh:NodeShape ;
167+
sh:name "CheckValue" ;
168+
sh:description "" ;
169+
170+
sh:target [
171+
a sh:SPARQLTarget ;
172+
sh:select """
173+
PREFIX schema: <http://schema.org/>
174+
PREFIX shp: <https://w3id.org/shp#>
175+
176+
SELECT ?this
177+
WHERE {
178+
?this schema:additionalType shp:CheckValue .
179+
}
180+
""" ;
181+
] ;
182+
183+
sh:property [
184+
a sh:PropertyShape ;
185+
sh:name "ActionStatus" ;
186+
sh:path schema:actionStatus ;
187+
sh:minCount 1 ;
188+
sh:severity sh:Warning ;
189+
sh:message "CheckValue SHOULD have actionStatus property." ;
190+
] .
191+

0 commit comments

Comments
 (0)