Skip to content

Commit 6299e47

Browse files
authored
Merge pull request #57 from eScienceLab/unify-timestamp-checks
Unify timestamp checks
2 parents 3b10e2f + a53c832 commit 6299e47

15 files changed

+92
-277
lines changed

rocrate_validator/profiles/five-safes-crate/may/4_sign_off.ttl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ five-safes-crate:SignOffPhaseStartTime
5353
sh:maxCount 1 ;
5454
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})$" ;
5555
sh:severity sh:Info ;
56-
sh:description "Sign Off object MAY have a startTime property if action is active, completed or failed. This must follow ISO-8601 syntax" ;
57-
sh:message "Sign Off object MAY have a startTime property if action is active, completed or failed. This must follow ISO-8601 syntax" ;
56+
sh:description "Sign Off object MAY have a startTime property if action is active, completed or failed." ;
57+
sh:message "Sign Off object MAY have a startTime property if action is active, completed or failed." ;
5858
] .

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,6 @@ five-safes-crate:WorkflowMustHaveDescriptiveName
4141
] .
4242

4343

44-
five-safes-crate:WorkflowexecutionObjectHasCompliantStartTimeFormat
45-
a sh:NodeShape ;
46-
sh:name "WorkflowExecution" ;
47-
sh:description "The startTime of the workflow execution object MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
48-
sh:targetClass schema:CreateAction ;
49-
50-
sh:property [
51-
a sh:PropertyShape ;
52-
sh:name "StartTime" ;
53-
sh:path schema:startTime ;
54-
sh:minCount 0 ;
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 "The startTime of the workflow execution object MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
58-
] .
59-
60-
61-
five-safes-crate:WorkflowexecutionObjectHasCompliantEndTimeFormat
62-
a sh:NodeShape ;
63-
sh:name "WorkflowExecution" ;
64-
sh:description "The endTime of the workflow execution object MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
65-
sh:targetClass schema:CreateAction ;
66-
67-
sh:property [
68-
a sh:PropertyShape ;
69-
sh:name "EndTime" ;
70-
sh:path schema:endTime ;
71-
sh:minCount 0 ;
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 "The endTime of the workflow execution object MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
75-
] .
7644

7745

7846
five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues

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

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -59,62 +59,6 @@ five-safes-crate:CheckValueObjectHasDescriptiveNameAndIsAssessAction
5959
sh:message "CheckValue MUST have a human readable name string." ;
6060
] .
6161

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-
11862
five-safes-crate:CheckValueActionStatusMustHaveAllowedValues
11963
a sh:NodeShape ;
12064
sh:name "CheckValue" ;

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

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -124,59 +124,3 @@ five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue
124124
sh:severity sh:Violation ;
125125
sh:message "actionStatus MUST be either PotentialActionStatus, ActiveActionStatus, CompletedActionStatus, or FailedActionStatus." ;
126126
] .
127-
128-
129-
five-safes-crate:ValidationCheckStartTimeMUSTFollowISOStandard
130-
a sh:NodeShape ;
131-
sh:name "ValidationCheck" ;
132-
sh:description "" ;
133-
sh:target [
134-
a sh:SPARQLTarget ;
135-
sh:select """
136-
PREFIX schema: <http://schema.org/>
137-
PREFIX shp: <https://w3id.org/shp#>
138-
139-
SELECT ?this
140-
WHERE {
141-
?this schema:additionalType shp:ValidationCheck .
142-
}
143-
""" ;
144-
] ;
145-
146-
sh:property [
147-
a sh:PropertyShape ;
148-
sh:name "StartTime" ;
149-
sh:minCount 0;
150-
sh:path schema:startTime ;
151-
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})$" ;
152-
sh:severity sh:Violation ;
153-
sh:message "ValidationCheck --> `startTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
154-
] .
155-
156-
157-
five-safes-crate:ValidationCheckEndTimeMUSTFollowISOStandard
158-
a sh:NodeShape ;
159-
sh:name "ValidationCheck" ;
160-
sh:description "" ;
161-
sh:target [
162-
a sh:SPARQLTarget ;
163-
sh:select """
164-
PREFIX schema: <http://schema.org/>
165-
PREFIX shp: <https://w3id.org/shp#>
166-
167-
SELECT ?this
168-
WHERE {
169-
?this schema:additionalType shp:ValidationCheck .
170-
}
171-
""" ;
172-
] ;
173-
174-
sh:property [
175-
a sh:PropertyShape ;
176-
sh:name "EndTime" ;
177-
sh:minCount 0;
178-
sh:path schema:endTime ;
179-
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})$" ;
180-
sh:severity sh:Violation ;
181-
sh:message "ValidationCheck --> `endTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
182-
] .

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,6 @@ five-safes-crate:DownloadActionObjectMUSTHavesDescriptiveName
4141
sh:message "DownloadAction MUST have a human readable name string." ;
4242
] .
4343

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-
] .
7644

7745

7846
five-safes-crate:WorkflowSameAsAndRootDataEntityMainEntityMUSTBeTheSame
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
# to ensure the entity id will be included in any error message,
27+
# target all entities which have startTime and/or endTime properties using sh:targetSubjectsOf,
28+
# then we use sh:property to validate the values of those properties.
29+
# the properties are listed individually so that the property id appears in any error message too
30+
five-safes-crate:TimeStampFormat
31+
a sh:NodeShape ;
32+
sh:name "Timestamp Format" ;
33+
sh:description "Timestamps MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
34+
sh:targetSubjectsOf schema:startTime, schema:endTime;
35+
sh:property [
36+
a sh:PropertyShape ;
37+
sh:name "End TimeStamp" ;
38+
sh:path schema:endTime ;
39+
sh:minCount 0 ;
40+
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})$" ;
41+
sh:severity sh:Violation ;
42+
sh:message "All `startTime` and `endTime` values MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
43+
sh:description "End timestamps MUST follow the RFC 3339 standard." ;
44+
] ;
45+
sh:property [
46+
a sh:PropertyShape ;
47+
sh:name "Start TimeStamp" ;
48+
sh:path schema:startTime ;
49+
sh:minCount 0 ;
50+
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})$" ;
51+
sh:severity sh:Violation ;
52+
sh:message "All `startTime` and `endTime` values MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
53+
sh:description "Start timestamps MUST follow the RFC 3339 standard." ;
54+
] .

rocrate_validator/profiles/five-safes-crate/must/8_disclosure_phase.ttl

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -98,61 +98,3 @@ five-safes-crate:DisclosureObjectHasActionStatusWithAcceptedValue
9898
sh:severity sh:Violation ;
9999
sh:message "`DisclosureCheck` MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
100100
] .
101-
102-
103-
five-safes-crate:DisclosureObjectHasCompliantStartTimeFormat
104-
a sh:NodeShape ;
105-
sh:name "DisclosureCheck" ;
106-
sh:description "`DisclosureCheck` --> `startTime` MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
107-
sh:target [
108-
a sh:SPARQLTarget ;
109-
sh:select """
110-
PREFIX schema: <http://schema.org/>
111-
PREFIX shp: <https://w3id.org/shp#>
112-
113-
SELECT ?this
114-
WHERE {
115-
?this schema:additionalType shp:DisclosureCheck ;
116-
schema:startTime ?o
117-
}
118-
""" ;
119-
] ;
120-
121-
sh:property [
122-
a sh:PropertyShape ;
123-
sh:name "StartTime" ;
124-
sh:path schema:startTime ;
125-
sh:minCount 0 ;
126-
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})$" ;
127-
sh:severity sh:Violation ;
128-
sh:message "`DisclosureCheck` --> `startTime` MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
129-
] .
130-
131-
132-
five-safes-crate:DisclosureObjectHasCompliantEndTimeFormat
133-
a sh:NodeShape ;
134-
sh:name "DisclosureCheck" ;
135-
sh:description "`DisclosureCheck` --> `endTime` MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
136-
sh:target [
137-
a sh:SPARQLTarget ;
138-
sh:select """
139-
PREFIX schema: <http://schema.org/>
140-
PREFIX shp: <https://w3id.org/shp#>
141-
142-
SELECT ?this
143-
WHERE {
144-
?this schema:additionalType shp:DisclosureCheck ;
145-
schema:endTime ?o
146-
}
147-
""" ;
148-
] ;
149-
150-
sh:property [
151-
a sh:PropertyShape ;
152-
sh:name "EndTime" ;
153-
sh:path schema:endTime ;
154-
sh:minCount 0 ;
155-
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})$" ;
156-
sh:severity sh:Violation ;
157-
sh:message "`DisclosureCheck` --> `endTime` MUST follow the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
158-
] .

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,3 @@ five-safes-crate:CheckValueShouldHaveActionStatus
188188
sh:severity sh:Warning ;
189189
sh:message "CheckValue SHOULD have actionStatus property." ;
190190
] .
191-

rocrate_validator/profiles/five-safes-crate/should/4_sign_off.ttl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ five-safes-crate:SignOffPhaseEndTime
171171
sh:path schema:endTime ;
172172
sh:minCount 1 ;
173173
sh:maxCount 1 ;
174-
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})$" ;
175174
sh:severity sh:Warning ;
176-
sh:description "Sign Off object SHOULD have endTime property if action completed or failed. This must follow ISO-8601 syntax" ;
177-
sh:message "Sign Off object SHOULD have endTime property if action completed or failed. This must follow ISO-8601 syntax" ;
175+
sh:description "Sign Off object SHOULD have endTime property if action completed or failed." ;
176+
sh:message "Sign Off object SHOULD have endTime property if action completed or failed." ;
178177
] .

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ def test_5src_workflow_object_has_no_properly_formatted_start_time():
136136
rocrate_path=ValidROC().five_safes_crate_result,
137137
requirement_severity=Severity.REQUIRED,
138138
expected_validation_result=False,
139-
expected_triggered_requirements=["WorkflowExecution"],
139+
expected_triggered_requirements=["Timestamp Format"],
140140
expected_triggered_issues=[
141141
(
142-
"The startTime of the workflow execution object MUST follow the RFC 3339 standard "
142+
"All `startTime` and `endTime` values MUST follow the RFC 3339 standard "
143143
"(YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))."
144144
)
145145
],
@@ -169,10 +169,10 @@ def test_5src_workflow_object_has_no_properly_formatted_end_time():
169169
rocrate_path=ValidROC().five_safes_crate_result,
170170
requirement_severity=Severity.REQUIRED,
171171
expected_validation_result=False,
172-
expected_triggered_requirements=["WorkflowExecution"],
172+
expected_triggered_requirements=["Timestamp Format"],
173173
expected_triggered_issues=[
174174
(
175-
"The endTime of the workflow execution object MUST follow the RFC 3339 standard "
175+
"All `startTime` and `endTime` values MUST follow the RFC 3339 standard "
176176
"(YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))."
177177
)
178178
],

0 commit comments

Comments
 (0)