Skip to content

Commit c6299a5

Browse files
authored
Merge pull request #54 from eScienceLab/53-fix-timestamp-rules-in-disclosure-phase-ruleset
Fix timestamp and assessAction rules plus pytests for disclosure phase ruleset
2 parents 4d4c6ec + 0bd3bd9 commit c6299a5

4 files changed

Lines changed: 225 additions & 139 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ five-safes-crate:DisclosureObjectHasStartTimeIfBegun
5252
sh:path schema:startTime ;
5353
sh:minCount 1 ;
5454
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})$" ;
5655
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." ;
56+
sh:description "`DisclosureCheck` MAY have the `startTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ;
57+
sh:message "`DisclosureCheck` MAY have the `startTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ;
5958
] .

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

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,31 @@ five-safes-crate:DisclosureObjectHasDescriptiveNameAndIsAssessAction
4444
sh:property [
4545
a sh:PropertyShape ;
4646
sh:name "AssessAction" ;
47-
sh:description "DisclosureCheck MUST be a `schema:AssessAction`." ;
47+
sh:description "`DisclosureCheck` MUST be a `schema:AssessAction`." ;
4848
sh:path rdf:type ;
4949
sh:minCount 1 ;
5050
sh:hasValue schema:AssessAction;
5151
sh:severity sh:Violation ;
52-
sh:message "DisclosureCheck MUST be a `schema:AssessAction`." ;
52+
sh:message "`DisclosureCheck` MUST be a `schema:AssessAction`." ;
5353
] ;
5454

5555
sh:property [
5656
a sh:PropertyShape ;
5757
sh:name "name" ;
58-
sh:description "DisclosureCheck MUST have a name string of at least 20 characters." ;
58+
sh:description "`DisclosureCheck` MUST have a name string of at least 10 characters." ;
59+
sh:minCount 1 ;
5960
sh:path schema:name ;
6061
sh:datatype xsd:string ;
61-
sh:minLength 20 ;
62+
sh:minLength 10 ;
6263
sh:severity sh:Violation ;
63-
sh:message "DisclosureCheck MUST have a name string of at least 20 characters." ;
64+
sh:message "`DisclosureCheck` MUST have a name string of at least 10 characters." ;
6465
] .
6566

6667

67-
five-safes-crate:DisclosureObjectHasActionStatus
68+
five-safes-crate:DisclosureObjectHasActionStatusWithAcceptedValue
6869
a sh:NodeShape ;
6970
sh:name "DisclosureCheck" ;
70-
sh:description "DisclosureCheck" ;
71+
sh:description "`DisclosureCheck` MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
7172

7273
sh:target [
7374
a sh:SPARQLTarget ;
@@ -86,7 +87,7 @@ five-safes-crate:DisclosureObjectHasActionStatus
8687
sh:property [
8788
a sh:PropertyShape ;
8889
sh:name "actionStatus" ;
89-
sh:description "The value of actionStatus MUST be one of the allowed values." ;
90+
sh:description "`DisclosureCheck` MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
9091
sh:path schema:actionStatus ;
9192
sh:in (
9293
"http://schema.org/PotentialActionStatus"
@@ -95,5 +96,63 @@ five-safes-crate:DisclosureObjectHasActionStatus
9596
"http://schema.org/FailedActionStatus"
9697
) ;
9798
sh:severity sh:Violation ;
98-
sh:message "The value of actionStatus MUST be one of the allowed values." ;
99+
sh:message "`DisclosureCheck` MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ;
100+
] .
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))." ;
99158
] .

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ five-safes-crate:RootDataEntityShouldMentionDisclosureObject
3232
sh:sparql [
3333
a sh:SPARQLConstraint ;
3434
sh:name "mentions" ;
35-
sh:description "RootDataEntity SHOULD mention a disclosure object." ;
35+
sh:description "`RootDataEntity` SHOULD mention a disclosure object." ;
3636
sh:select """
3737
PREFIX schema: <http://schema.org/>
3838
PREFIX shp: <https://w3id.org/shp#>
@@ -46,14 +46,14 @@ five-safes-crate:RootDataEntityShouldMentionDisclosureObject
4646
}
4747
""" ;
4848
sh:severity sh:Warning ;
49-
sh:message "RootDataEntity SHOULD mention a disclosure object." ;
49+
sh:message "`RootDataEntity` SHOULD mention a disclosure object." ;
5050
] .
5151

5252

5353
five-safes-crate:DisclosureObjectHasActionStatus
5454
a sh:NodeShape ;
5555
sh:name "DisclosureCheck" ;
56-
sh:description "DisclosureCheck" ;
56+
sh:description "The `DisclosureCheck` SHOULD have `actionStatus` property." ;
5757

5858
sh:target [
5959
a sh:SPARQLTarget ;
@@ -71,11 +71,11 @@ five-safes-crate:DisclosureObjectHasActionStatus
7171
sh:property [
7272
a sh:PropertyShape ;
7373
sh:name "ActionStatus" ;
74-
sh:description "The DisclosureCheck SHOULD have actionStatus property." ;
74+
sh:description "The `DisclosureCheck` SHOULD have `actionStatus` property." ;
7575
sh:path schema:actionStatus ;
7676
sh:minCount 1 ;
7777
sh:severity sh:Warning ;
78-
sh:message "The DisclosureCheck SHOULD have actionStatus property." ;
78+
sh:message "The `DisclosureCheck` SHOULD have `actionStatus` property." ;
7979
] .
8080

8181

@@ -108,8 +108,7 @@ five-safes-crate:DisclosureObjectHasEndTimeIfcompletedOrFailed
108108
sh:path schema:endTime ;
109109
sh:minCount 1 ;
110110
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})$" ;
112111
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." ;
112+
sh:description "`DisclosureCheck` SHOULD have the `endTime` property if `actionStatus` is either CompletedActionStatus or FailedActionStatus." ;
113+
sh:message "`DisclosureCheck` SHOULD have the `endTime` property if `actionStatus` is either CompletedActionStatus or FailedActionStatus." ;
115114
] .

0 commit comments

Comments
 (0)