Skip to content

Commit 1984245

Browse files
authored
Merge pull request #39 from eScienceLab/38-implement-disclosure-phase-ruleset
Implement Disclosure Phase Ruleset
2 parents 6d8c458 + f0f8067 commit 1984245

5 files changed

Lines changed: 619 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 sh: <http://www.w3.org/ns/shacl#> .
21+
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
22+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
23+
24+
25+
five-safes-crate:DisclosureObjectHasStartTimeIfBegun
26+
a sh:NodeShape ;
27+
sh:name "DisclosureCheck" ;
28+
sh:description "DisclosureCheck" ;
29+
30+
sh:target [
31+
a sh:SPARQLTarget ;
32+
sh:select """
33+
PREFIX schema: <http://schema.org/>
34+
PREFIX shp: <https://w3id.org/shp#>
35+
36+
SELECT ?this
37+
WHERE {
38+
?this schema:additionalType shp:DisclosureCheck ;
39+
schema:actionStatus ?status .
40+
FILTER(?status IN (
41+
"http://schema.org/CompletedActionStatus",
42+
"http://schema.org/FailedActionStatus",
43+
"http://schema.org/ActiveActionStatus"
44+
))
45+
}
46+
""" ;
47+
] ;
48+
49+
sh:property [
50+
a sh:PropertyShape ;
51+
sh:name "StartTime" ;
52+
sh:path schema:startTime ;
53+
sh:minCount 1 ;
54+
sh:maxCount 1 ;
55+
sh:pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(Z|[+-][0-9]{2}:[0-9]{2})$" ;
56+
sh:severity sh:Info ;
57+
sh:description "Disclosure object MAY have startTime property with RFC 3339 full datetime string if action began." ;
58+
sh:message "Disclosure object MAY have startTime property with RFC 3339 full datetime string if action began." ;
59+
] .
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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:DisclosureObjectHasDescriptiveNameAndIsAssessAction
27+
a sh:NodeShape ;
28+
sh:name "DisclosureCheck" ;
29+
sh:description "DisclosureCheck" ;
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:DisclosureCheck .
40+
}
41+
""" ;
42+
] ;
43+
44+
sh:property [
45+
sh:a sh:PropertyShape ;
46+
sh:name "AssessAction" ;
47+
sh:description "DisclosureCheck MUST be a `schema:AssessAction`." ;
48+
sh:path rdf:type ;
49+
sh:minCount 1 ;
50+
sh:hasValue schema:AssessAction;
51+
sh:severity sh:Violation ;
52+
sh:message "DisclosureCheck MUST be a `schema:AssessAction`." ;
53+
] ;
54+
55+
sh:property [
56+
sh:a sh:PropertyShape ;
57+
sh:name "name" ;
58+
sh:description "DisclosureCheck MUST have a name string of at least 20 characters." ;
59+
sh:path schema:name ;
60+
sh:datatype xsd:string ;
61+
sh:minLength 20 ;
62+
sh:severity sh:Violation ;
63+
sh:message "DisclosureCheck MUST have a name string of at least 20 characters." ;
64+
] .
65+
66+
67+
five-safes-crate:DisclosureObjectHasActionStatus
68+
a sh:NodeShape ;
69+
sh:name "DisclosureCheck" ;
70+
sh:description "DisclosureCheck" ;
71+
72+
sh:target [
73+
a sh:SPARQLTarget ;
74+
sh:select """
75+
PREFIX schema: <http://schema.org/>
76+
PREFIX shp: <https://w3id.org/shp#>
77+
78+
SELECT ?this
79+
WHERE {
80+
?this schema:additionalType shp:DisclosureCheck ;
81+
schema:actionStatus ?status .
82+
}
83+
""" ;
84+
] ;
85+
86+
sh:property [
87+
a sh:PropertyShape ;
88+
sh:name "actionStatus" ;
89+
sh:description "The value of actionStatus MUST be one of the allowed values." ;
90+
sh:path schema:actionStatus ;
91+
sh:in (
92+
"http://schema.org/PotentialActionStatus"
93+
"http://schema.org/ActiveActionStatus"
94+
"http://schema.org/CompletedActionStatus"
95+
"http://schema.org/FailedActionStatus"
96+
) ;
97+
sh:severity sh:Violation ;
98+
sh:message "The value of actionStatus MUST be one of the allowed values." ;
99+
] .
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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:RootDataEntityShouldMentionDisclosureObject
27+
a sh:NodeShape ;
28+
sh:name "RootDataEntity" ;
29+
sh:targetClass ro-crate:RootDataEntity ;
30+
sh:description "RootDataEntity SHOULD mention a disclosure object." ;
31+
32+
sh:sparql [
33+
a sh:SPARQLConstraint ;
34+
sh:name "mentions" ;
35+
sh:description "RootDataEntity SHOULD mention a disclosure 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 a schema:AssessAction ;
44+
schema:additionalType shp:DisclosureCheck .
45+
}
46+
}
47+
""" ;
48+
sh:severity sh:Warning ;
49+
sh:message "RootDataEntity SHOULD mention a disclosure object." ;
50+
] .
51+
52+
53+
five-safes-crate:DisclosureObjectHasActionStatus
54+
a sh:NodeShape ;
55+
sh:name "DisclosureCheck" ;
56+
sh:description "DisclosureCheck" ;
57+
58+
sh:target [
59+
a sh:SPARQLTarget ;
60+
sh:select """
61+
PREFIX schema: <http://schema.org/>
62+
PREFIX shp: <https://w3id.org/shp#>
63+
64+
SELECT ?this
65+
WHERE {
66+
?this schema:additionalType shp:DisclosureCheck .
67+
}
68+
""" ;
69+
] ;
70+
71+
sh:property [
72+
a sh:PropertyShape ;
73+
sh:name "ActionStatus" ;
74+
sh:description "The DisclosureCheck SHOULD have actionStatus property." ;
75+
sh:path schema:actionStatus ;
76+
sh:minCount 1 ;
77+
sh:severity sh:Warning ;
78+
sh:message "The DisclosureCheck SHOULD have actionStatus property." ;
79+
] .
80+
81+
82+
five-safes-crate:DisclosureObjectHasEndTimeIfcompletedOrFailed
83+
a sh:NodeShape ;
84+
sh:name "DisclosureCheck" ;
85+
sh:description "DisclosureCheck" ;
86+
87+
sh:target [
88+
a sh:SPARQLTarget ;
89+
sh:select """
90+
PREFIX schema: <http://schema.org/>
91+
PREFIX shp: <https://w3id.org/shp#>
92+
93+
SELECT ?this
94+
WHERE {
95+
?this schema:additionalType shp:DisclosureCheck ;
96+
schema:actionStatus ?status .
97+
FILTER(?status IN (
98+
"http://schema.org/CompletedActionStatus",
99+
"http://schema.org/FailedActionStatus"
100+
))
101+
}
102+
""" ;
103+
] ;
104+
105+
sh:property [
106+
a sh:PropertyShape ;
107+
sh:name "EndTime" ;
108+
sh:path schema:endTime ;
109+
sh:minCount 1 ;
110+
sh:maxCount 1 ;
111+
sh:pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(Z|[+-][0-9]{2}:[0-9]{2})$" ;
112+
sh:severity sh:Warning ;
113+
sh:description "Disclosure object SHOULD have endTime property with a valid datetetime if action completed of failed." ;
114+
sh:message "Disclosure object SHOULD have endTime property with a valid datetime if action completed of failed." ;
115+
] .

tests/data/crates/valid/five-safes-crate-result/ro-crate-metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@
303303
"@id": "https://w3id.org/shp#DisclosureCheck"
304304
},
305305
"name": "Disclosure check of workflow results: approved",
306+
"startTime": "2023-04-24T00:00:00+01:00",
306307
"endTime": "2023-04-25T16:00:00+01:00",
307308
"object": {
308309
"@id": "./"

0 commit comments

Comments
 (0)