Skip to content

Commit d95af78

Browse files
authored
Merge pull request #51 from eScienceLab/48-implement-workflow-retrieval-phase-ruleset
Implement Workflow Retrieval Phase Ruleset
2 parents 6b1859d + 02985c9 commit d95af78

File tree

8 files changed

+1100
-46
lines changed

8 files changed

+1100
-46
lines changed

qqOA

Lines changed: 164 additions & 0 deletions
Large diffs are not rendered by default.

rocrate_validator/profiles/five-safes-crate/may/11_workflow_execution_phase.ttl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun
2626
a sh:NodeShape ;
2727
sh:name "WorkflowExecution" ;
28-
sh:description "The workflow execution object MAY have a startTime if execution was initiated." ;
28+
sh:description (
29+
"The workflow execution object MAY have a startTime if actionStatus is "
30+
"either ActiveActionStatus, CompletedActionStatus or FailedActionStatus."
31+
) ;
2932

3033
sh:target [
3134
a sh:SPARQLTarget ;
@@ -53,6 +56,9 @@ five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun
5356
sh:minCount 1 ;
5457
sh:maxCount 1 ;
5558
sh:severity sh:Info ;
56-
sh:description "The workflow execution object MAY have a startTime if execution was initiated." ;
57-
sh:message "The workflow execution object MAY have a startTime if execution was initiated." ;
59+
sh:description (
60+
"The workflow execution object MAY have a startTime if actionStatus is "
61+
"either ActiveActionStatus, CompletedActionStatus or FailedActionStatus."
62+
) ;
63+
sh:message "The workflow execution object MAY have a startTime if actionStatus is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ;
5864
] .
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+
16+
@prefix ro: <./> .
17+
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
18+
@prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> .
19+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
20+
@prefix schema: <http://schema.org/> .
21+
@prefix purl: <http://purl.org/dc/terms/> .
22+
@prefix sh: <http://www.w3.org/ns/shacl#> .
23+
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
24+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
25+
26+
27+
five-safes-crate:DownloadedWorkflowSHOULDExistAndBeReferencedByDownloadActionResult
28+
a sh:NodeShape ;
29+
sh:name "DownloadAction" ;
30+
sh:description "Validates that DownloadAction result references an existing entity" ;
31+
sh:targetClass schema:DownloadAction ;
32+
33+
sh:property [
34+
a sh:PropertyShape ;
35+
sh:name "Result" ;
36+
sh:description "The result property must reference an existing entity in the RO-Crate" ;
37+
sh:path schema:result ;
38+
sh:minCount 1 ;
39+
sh:nodeKind sh:IRI ;
40+
41+
sh:sparql [
42+
a sh:SPARQLConstraint ;
43+
sh:select """
44+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
45+
PREFIX schema: <http://schema.org/>
46+
47+
SELECT $this $value
48+
WHERE {
49+
$this schema:result $value .
50+
51+
# Entity must have BOTH type AND name (proper definition)
52+
FILTER NOT EXISTS {
53+
$value rdf:type schema:Dataset .
54+
}
55+
}
56+
""" ;
57+
sh:severity sh:Info ;
58+
sh:message "The entity representing the downloaded workflow is not defined, OR is not referenced by `DownloadAction` --> `result`, OR is not of type `schema:Dataset`." ;
59+
] ;
60+
] .
61+
62+
63+
five-safes-crate:DownloadActionMayHaveStartTimeIfBegun
64+
a sh:NodeShape ;
65+
sh:name "DownloadAction" ;
66+
sh:description (
67+
"`DownloadAction` MAY have the `startTime` property if `actionStatus` "
68+
"is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus."
69+
);
70+
71+
sh:target [
72+
a sh:SPARQLTarget ;
73+
sh:select """
74+
PREFIX schema: <http://schema.org/>
75+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
76+
77+
SELECT ?this
78+
WHERE {
79+
?this rdf:type schema:DownloadAction ;
80+
schema:actionStatus ?status .
81+
FILTER(?status IN (
82+
"http://schema.org/CompletedActionStatus",
83+
"http://schema.org/FailedActionStatus",
84+
"http://schema.org/ActiveActionStatus"
85+
))
86+
}
87+
""" ;
88+
] ;
89+
90+
sh:property [
91+
a sh:PropertyShape ;
92+
sh:name "StartTime" ;
93+
sh:path schema:startTime ;
94+
sh:minCount 1 ;
95+
sh:maxCount 1 ;
96+
sh:severity sh:Info ;
97+
sh:description (
98+
"`DownloadAction` MAY have the `startTime` property if `actionStatus` "
99+
"is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus."
100+
);
101+
sh:message "`DownloadAction` MAY have the `startTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ;
102+
] .
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
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:DownloadActionObjectMUSTHavesDescriptiveName
27+
a sh:NodeShape ;
28+
sh:name "DownloadAction" ;
29+
sh:targetClass schema:DownloadAction ;
30+
sh:description "" ;
31+
32+
sh:property [
33+
a sh:PropertyShape ;
34+
sh:name "name" ;
35+
sh:description "DownloadAction MUST have a human readable name string." ;
36+
sh:path schema:name ;
37+
sh:minCount 1 ;
38+
sh:maxCount 1 ;
39+
sh:datatype xsd:string ;
40+
sh:severity sh:Violation ;
41+
sh:message "DownloadAction MUST have a human readable name string." ;
42+
] .
43+
44+
five-safes-crate:DownloadActionStartTimeMUSTFollowISOStandard
45+
a sh:NodeShape ;
46+
sh:name "DownloadAction" ;
47+
sh:description "" ;
48+
sh:targetClass schema:DownloadAction ;
49+
50+
sh:property [
51+
a sh:PropertyShape ;
52+
sh:name "StartTime" ;
53+
sh:minCount 0;
54+
sh:path schema:startTime ;
55+
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})$" ;
56+
sh:severity sh:Violation ;
57+
sh:message "`DownloadAction` --> `startTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
58+
] .
59+
60+
61+
five-safes-crate:DownloadActionEndTimeMUSTFollowISOStandard
62+
a sh:NodeShape ;
63+
sh:name "DownloadAction" ;
64+
sh:description "" ;
65+
sh:targetClass schema:DownloadAction ;
66+
67+
sh:property [
68+
a sh:PropertyShape ;
69+
sh:name "EndTime" ;
70+
sh:minCount 0;
71+
sh:path schema:endTime ;
72+
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})$" ;
73+
sh:severity sh:Violation ;
74+
sh:message "`DownloadAction` --> `endTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
75+
] .
76+
77+
78+
five-safes-crate:WorkflowSameAsAndRootDataEntityMainEntityMUSTBeTheSame
79+
a sh:NodeShape ;
80+
sh:name "Downloaded Workflow" ;
81+
sh:description "" ;
82+
sh:target [
83+
a sh:SPARQLTarget ;
84+
sh:select """
85+
PREFIX schema: <http://schema.org/>
86+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
87+
88+
SELECT ?this
89+
WHERE {
90+
?this rdf:type schema:Dataset .
91+
?s rdf:type schema:DownloadAction ;
92+
schema:result ?this .
93+
}
94+
""" ;
95+
];
96+
97+
sh:sparql [
98+
a sh:SPARQLConstraint ;
99+
sh:select """
100+
PREFIX schema: <http://schema.org/>
101+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
102+
103+
SELECT $this
104+
WHERE {
105+
FILTER NOT EXISTS {
106+
$this schema:sameAs ?o .
107+
?s schema:mainEntity ?o .
108+
# ?o rdf:type schema:Dataset .
109+
}
110+
}
111+
""" ;
112+
sh:severity sh:Violation ;
113+
sh:description "The property `sameAs` of the entity representing the downloaded workflow MUST point to the same entity as `RootDataEntity` --> `mainEntity`." ;
114+
sh:message "The property `sameAs` of the entity representing the downloaded workflow MUST point to the same entity as `RootDataEntity` --> `mainEntity`." ;
115+
] .
116+
117+
118+
five-safes-crate:DownloadedWorkflowDistributionAndDownloadActionObjectMUSTBeTheSame
119+
a sh:NodeShape ;
120+
sh:name "Downloaded Workflow" ;
121+
sh:description "" ;
122+
sh:target [
123+
a sh:SPARQLTarget ;
124+
sh:select """
125+
PREFIX schema: <http://schema.org/>
126+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
127+
128+
SELECT ?this
129+
WHERE {
130+
?this rdf:type schema:Dataset .
131+
?s rdf:type schema:DownloadAction ;
132+
schema:result ?this .
133+
}
134+
""" ;
135+
];
136+
137+
sh:sparql [
138+
a sh:SPARQLConstraint ;
139+
sh:name "" ;
140+
sh:select """
141+
PREFIX schema: <http://schema.org/>
142+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
143+
144+
SELECT $this
145+
WHERE {
146+
?action rdf:type schema:DownloadAction .
147+
FILTER NOT EXISTS {
148+
$this schema:distribution ?url .
149+
?action schema:object ?url .
150+
}
151+
}
152+
""" ;
153+
sh:severity sh:Violation ;
154+
sh:message "DownloadedWorkflow --> `distribution` MUST reference the same entity as `DownloadAction` --> `object`." ;
155+
] .
156+
157+
158+
five-safes-crate:DownloadActionActionStatusMUSTHaveAllowedValues
159+
a sh:NodeShape ;
160+
sh:name "DownloadAction" ;
161+
sh:description "" ;
162+
163+
sh:target [
164+
a sh:SPARQLTarget ;
165+
sh:select """
166+
PREFIX schema: <http://schema.org/>
167+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
168+
169+
SELECT ?this
170+
WHERE {
171+
?this rdf:type schema:DownloadAction ;
172+
schema:actionStatus ?status .
173+
}
174+
""" ;
175+
] ;
176+
177+
sh:property [
178+
a sh:PropertyShape ;
179+
sh:name "ActionStatus" ;
180+
sh:path schema:actionStatus ;
181+
sh:in (
182+
"http://schema.org/PotentialActionStatus"
183+
"http://schema.org/ActiveActionStatus"
184+
"http://schema.org/CompletedActionStatus"
185+
"http://schema.org/FailedActionStatus"
186+
) ;
187+
sh:severity sh:Violation ;
188+
sh:message "The value of actionStatus MUST be one of the allowed values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." ;
189+
] .

0 commit comments

Comments
 (0)