Skip to content

Commit b836a4b

Browse files
committed
(i) Added extra SHACL shapes. (ii) Changed violation severity of existing SHACL shapes based on redefined rules in excel file. (iii) Added tests to validate SHACL shapes.
1 parent 586ab3d commit b836a4b

File tree

6 files changed

+518
-32
lines changed

6 files changed

+518
-32
lines changed

qqOA

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

rocrate_validator/profiles/five-safes-crate/may/14_workflow_retrieval_phase.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ five-safes-crate:DownloadActionMayHaveStartTimeIfBegun
5252
sh:minCount 1 ;
5353
sh:maxCount 1 ;
5454
sh:severity sh:Info ;
55-
sh:message "`DownloadAction` SHOULD have the `endTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ;
55+
sh:message "`DownloadAction` MAY have the `startTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ;
5656
] .

rocrate_validator/profiles/five-safes-crate/must/14_workflow_retrieval_phase.ttl

Lines changed: 86 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2424

2525

26-
five-safes-crate:DownloadActionObjectHasDescriptiveName
26+
five-safes-crate:DownloadActionObjectMUSTHavesDescriptiveName
2727
a sh:NodeShape ;
2828
sh:name "DownloadAction" ;
2929
sh:targetClass schema:DownloadAction ;
@@ -42,35 +42,24 @@ five-safes-crate:DownloadActionObjectHasDescriptiveName
4242
sh:message "DownloadAction MUST have a human readable name string of at least 10 characters." ;
4343
] .
4444

45-
five-safes-crate:DownloadActionStartTimeMustFollowISOStandard
45+
five-safes-crate:DownloadActionStartTimeMUSTFollowISOStandard
4646
a sh:NodeShape ;
4747
sh:name "DownloadAction" ;
4848
sh:description "" ;
49-
sh:target [
50-
a sh:SPARQLTarget ;
51-
sh:select """
52-
PREFIX schema: <http://schema.org/>
53-
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
54-
55-
SELECT ?this
56-
WHERE {
57-
?this rdf:type schema:DownloadAction ;
58-
schema:startTime ?o .
59-
}
60-
""" ;
61-
] ;
49+
sh:targetClass schema:DownloadAction ;
6250

6351
sh:property [
6452
a sh:PropertyShape ;
6553
sh:name "StartTime" ;
54+
sh:minCount 0;
6655
sh:path schema:startTime ;
6756
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})$" ;
6857
sh:severity sh:Violation ;
6958
sh:message "`DownloadAction` --> `startTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
7059
] .
7160

7261

73-
five-safes-crate:DownloadActionEndTimeMustFollowISOStandard
62+
five-safes-crate:DownloadActionEndTimeMUSTFollowISOStandard
7463
a sh:NodeShape ;
7564
sh:name "DownloadAction" ;
7665
sh:description "" ;
@@ -87,7 +76,87 @@ five-safes-crate:DownloadActionEndTimeMustFollowISOStandard
8776
] .
8877

8978

90-
five-safes-crate:CheckValueActionStatusMustHaveAllowedValues
79+
five-safes-crate:WorkflowSameAsAndRootDataEntityMainEntityMUSTBeTheSame
80+
a sh:NodeShape ;
81+
sh:name "Downloaded Workflow" ;
82+
sh:description "" ;
83+
sh:target [
84+
a sh:SPARQLTarget ;
85+
sh:select """
86+
PREFIX schema: <http://schema.org/>
87+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
88+
89+
SELECT ?this
90+
WHERE {
91+
?this rdf:type schema:Dataset .
92+
?s rdf:type schema:DownloadAction ;
93+
schema:result ?this .
94+
}
95+
""" ;
96+
];
97+
98+
sh:sparql [
99+
a sh:SPARQLConstraint ;
100+
sh:select """
101+
PREFIX schema: <http://schema.org/>
102+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
103+
104+
SELECT $this
105+
WHERE {
106+
FILTER NOT EXISTS {
107+
$this schema:sameAs ?o .
108+
?s schema:mainEntity ?o .
109+
# ?o rdf:type schema:Dataset .
110+
}
111+
}
112+
""" ;
113+
sh:severity sh:Violation ;
114+
sh:description "The property `sameAs` of the entity representing the downloaded workflow MUST point to the same entity as `RootDataEntity` --> `mainEntity`." ;
115+
sh:message "The property `sameAs` of the entity representing the downloaded workflow MUST point to the same entity as `RootDataEntity` --> `mainEntity`." ;
116+
] .
117+
118+
119+
five-safes-crate:DownloadedWorkflowDistributionAndDownloadActionObjectMUSTBeTheSame
120+
a sh:NodeShape ;
121+
sh:name "Downloaded Workflow" ;
122+
sh:description "" ;
123+
sh:target [
124+
a sh:SPARQLTarget ;
125+
sh:select """
126+
PREFIX schema: <http://schema.org/>
127+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
128+
129+
SELECT ?this
130+
WHERE {
131+
?this rdf:type schema:Dataset .
132+
?s rdf:type schema:DownloadAction ;
133+
schema:result ?this .
134+
}
135+
""" ;
136+
];
137+
138+
sh:sparql [
139+
a sh:SPARQLConstraint ;
140+
sh:name "" ;
141+
sh:select """
142+
PREFIX schema: <http://schema.org/>
143+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
144+
145+
SELECT $this
146+
WHERE {
147+
?action rdf:type schema:DownloadAction .
148+
FILTER NOT EXISTS {
149+
$this schema:distribution ?url .
150+
?action schema:object ?url .
151+
}
152+
}
153+
""" ;
154+
sh:severity sh:Violation ;
155+
sh:message "DownloadedWorkflow --> `distribution` MUST reference the same entity as `DownloadAction` --> `object`." ;
156+
] .
157+
158+
159+
five-safes-crate:DownloadActionActionStatusMUSTHaveAllowedValues
91160
a sh:NodeShape ;
92161
sh:name "DownloadAction" ;
93162
sh:description "" ;

rocrate_validator/profiles/five-safes-crate/should/14_workflow_retrieval_phase.ttl

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,55 @@
2323
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2424

2525

26-
five-safes-crate:RootDataEntityShouldMentionDownloadActionObjectIfItExists
26+
five-safes-crate:DownloadActionEntitySHOULDExist
2727
a sh:NodeShape ;
2828
sh:name "RootDataEntity" ;
29+
sh:description "" ;
2930
sh:targetClass ro-crate:RootDataEntity ;
31+
32+
sh:sparql [
33+
a sh:SPARQLConstraint ;
34+
sh:name "" ;
35+
sh:select """
36+
PREFIX schema: <http://schema.org/>
37+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
38+
39+
SELECT $this
40+
WHERE {
41+
FILTER NOT EXISTS {
42+
?s rdf:type schema:DownloadAction .
43+
}
44+
}
45+
""" ;
46+
sh:severity sh:Warning ;
47+
sh:message "An entity typed DownloadAction SHOULD exist." ;
48+
] .
49+
50+
51+
52+
five-safes-crate:RootDataEntitySHOULDMentionDownloadActionIfPresent
53+
a sh:NodeShape ;
54+
sh:name "RootDataEntity" ;
3055
sh:description "" ;
56+
sh:targetClass ro-crate:RootDataEntity ;
3157

3258
sh:sparql [
3359
a sh:SPARQLConstraint ;
34-
sh:name "mentions" ;
35-
sh:description "RootDataEntity SHOULD mention the DownloadAction object." ;
60+
sh:name "" ;
3661
sh:select """
3762
PREFIX schema: <http://schema.org/>
3863
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
39-
SELECT $this ?download
64+
65+
SELECT $this ?da
4066
WHERE {
41-
?download rdf:type schema:DownloadAction .
42-
FILTER NOT EXISTS{
43-
$this schema:mentions ?download .
67+
?da rdf:type schema:DownloadAction .
68+
FILTER NOT EXISTS {
69+
$this schema:mentions ?da .
4470
}
4571
}
46-
""" ;
72+
""" ;
4773
sh:severity sh:Warning ;
48-
sh:message "RootDataEntity SHOULD mention the DownloadAction object." ;
74+
sh:message "RootDataEntity SHOULD mention DownloadAction if this exists." ;
4975
] .
5076

5177

@@ -82,6 +108,42 @@ five-safes-crate:DownloadActionShouldHaveEndTimeIfEnded
82108
] .
83109

84110

111+
five-safes-crate:DownloadedWorkflowSHOULDExistAndBeReferencedByDownloadActionResult
112+
a sh:NodeShape ;
113+
sh:name "DownloadAction" ;
114+
sh:description "Validates that DownloadAction result references an existing entity" ;
115+
sh:targetClass schema:DownloadAction ;
116+
117+
sh:property [
118+
a sh:PropertyShape ;
119+
sh:name "Result" ;
120+
sh:description "The result property must reference an existing entity in the RO-Crate" ;
121+
sh:path schema:result ;
122+
sh:minCount 1 ;
123+
sh:nodeKind sh:IRI ;
124+
125+
sh:sparql [
126+
a sh:SPARQLConstraint ;
127+
sh:select """
128+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
129+
PREFIX schema: <http://schema.org/>
130+
131+
SELECT $this $value
132+
WHERE {
133+
$this schema:result $value .
134+
135+
# Entity must have BOTH type AND name (proper definition)
136+
FILTER NOT EXISTS {
137+
$value rdf:type schema:Dataset .
138+
}
139+
}
140+
""" ;
141+
sh:severity sh:Warning ;
142+
sh:message "The entity represented the downloaded workflow is not properly defined in the RO-Crate and/or it is not referenced by `DownloadAction` --> `result`." ;
143+
] ;
144+
] .
145+
146+
85147
five-safes-crate:DownloadActionShouldHaveActionStatus
86148
a sh:NodeShape ;
87149
sh:name "DownloadAction" ;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
{
107107
"@id": "#query-37252371-c937-43bd-a0a7-3680b48c0538",
108108
"@type": "CreateAction",
109-
"actionStatus": "http://schema.org/CompleteActionStatus",
109+
"actionStatus": "http://schema.org/CompletedActionStatus",
110110
"agent": {
111111
"@id": "https://orcid.org/0000-0001-9842-9718"
112112
},
@@ -303,7 +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",
306+
"startTime": "2023-04-25T15:00:00+01:00",
307307
"endTime": "2023-04-25T16:00:00+01:00",
308308
"object": {
309309
"@id": "./"

0 commit comments

Comments
 (0)