|
| 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 | +#=== MUST shapes ===# |
| 27 | + |
| 28 | +five-safes-crate:WorkflowMustHaveDescriptiveName |
| 29 | + a sh:NodeShape ; |
| 30 | + sh:name "WorkflowExecution" ; |
| 31 | + sh:targetClass ro-crate:WorkflowRunAction ; |
| 32 | + |
| 33 | + sh:property [ |
| 34 | + a sh:PropertyShape ; |
| 35 | + sh:name "name" ; |
| 36 | + sh:minCount 1 ; |
| 37 | + sh:description "The `CreateAction` corresponding to the workflow run MUST have a name string of at least 10 characters." ; |
| 38 | + sh:path schema:name ; |
| 39 | + sh:datatype xsd:string ; |
| 40 | + sh:minLength 10 ; |
| 41 | + sh:severity sh:Violation ; |
| 42 | + sh:message "The `CreateAction` corresponding to the workflow run MUST have a name string of at least 10 characters." ; |
| 43 | + ] . |
| 44 | + |
| 45 | + |
| 46 | +five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues |
| 47 | + a sh:NodeShape ; |
| 48 | + sh:name "WorkflowExecution" ; |
| 49 | + sh:targetClass ro-crate:WorkflowRunAction ; |
| 50 | + sh:property [ |
| 51 | + a sh:PropertyShape ; |
| 52 | + sh:minCount 1 ; |
| 53 | + sh:name "actionStatus" ; |
| 54 | + sh:description "`CreateAction` MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ; |
| 55 | + sh:path schema:actionStatus ; |
| 56 | + sh:in ( |
| 57 | + "http://schema.org/PotentialActionStatus" |
| 58 | + "http://schema.org/ActiveActionStatus" |
| 59 | + "http://schema.org/CompletedActionStatus" |
| 60 | + "http://schema.org/FailedActionStatus" |
| 61 | + ) ; |
| 62 | + sh:severity sh:Violation ; |
| 63 | + sh:message "`CreateAction` MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ; |
| 64 | + ] . |
| 65 | + |
| 66 | + |
| 67 | +#=== SHOULD shapes ===# |
| 68 | + |
| 69 | +five-safes-crate:RootDataEntityShouldMentionWorkflow |
| 70 | + a sh:NodeShape ; |
| 71 | + sh:name "RootDataEntity" ; |
| 72 | + sh:description "RootDataEntity SHOULD mention workflow execution object (typed WorkflowRunAction)." ; |
| 73 | + sh:targetClass ro-crate:RootDataEntity ; |
| 74 | + sh:severity sh:Warning ; |
| 75 | + |
| 76 | + sh:sparql [ |
| 77 | + a sh:SPARQLConstraint ; |
| 78 | + sh:name "mentions" ; |
| 79 | + sh:select """ |
| 80 | + PREFIX schema: <http://schema.org/> |
| 81 | + PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> |
| 82 | + SELECT $this |
| 83 | + WHERE { |
| 84 | + FILTER NOT EXISTS { |
| 85 | + $this schema:mentions ?workflowExecution . |
| 86 | + ?workflowExecution a rocrate:WorkflowRunAction . |
| 87 | + } |
| 88 | + } |
| 89 | + """ ; |
| 90 | + sh:message "RootDataEntity SHOULD mention workflow execution object (typed WorkflowRunAction)." ; |
| 91 | + ] . |
| 92 | + |
| 93 | + |
| 94 | +five-safes-crate:WorkflowexecutionObjectHasEndTimeIfEnded |
| 95 | + a sh:NodeShape ; |
| 96 | + sh:name "WorkflowExecution" ; |
| 97 | + sh:description "The workflow run object SHOULD have an endTime property if it has ended." ; |
| 98 | + |
| 99 | + sh:target [ |
| 100 | + a sh:SPARQLTarget ; |
| 101 | + sh:select """ |
| 102 | + PREFIX schema: <http://schema.org/> |
| 103 | + PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> |
| 104 | +
|
| 105 | + SELECT ?this |
| 106 | + WHERE { |
| 107 | + ?this a rocrate:WorkflowRunAction ; |
| 108 | + schema:actionStatus ?status . |
| 109 | + FILTER(?status IN ( |
| 110 | + "http://schema.org/CompletedActionStatus", |
| 111 | + "http://schema.org/FailedActionStatus" |
| 112 | + )) |
| 113 | + } |
| 114 | + """ ; |
| 115 | + ] ; |
| 116 | + |
| 117 | + sh:property [ |
| 118 | + a sh:PropertyShape ; |
| 119 | + sh:name "EndTime" ; |
| 120 | + sh:path schema:endTime ; |
| 121 | + sh:minCount 1 ; |
| 122 | + sh:maxCount 1 ; |
| 123 | + sh:severity sh:Warning ; |
| 124 | + sh:description "The workflow execution object SHOULD have an endTime property if it has ended." ; |
| 125 | + sh:message "The workflow execution object SHOULD have an endTime property if it has ended." ; |
| 126 | + ] . |
| 127 | + |
| 128 | + |
| 129 | +#=== MAY shapes ===# |
| 130 | + |
| 131 | +five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun |
| 132 | + a sh:NodeShape ; |
| 133 | + sh:name "WorkflowExecution" ; |
| 134 | + sh:description ( |
| 135 | + "The workflow execution object MAY have a startTime if actionStatus is " |
| 136 | + "either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." |
| 137 | + ) ; |
| 138 | + |
| 139 | + sh:target [ |
| 140 | + a sh:SPARQLTarget ; |
| 141 | + sh:select """ |
| 142 | + PREFIX schema: <http://schema.org/> |
| 143 | + PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> |
| 144 | +
|
| 145 | + SELECT ?this |
| 146 | + WHERE { |
| 147 | + ?this a rocrate:WorkflowRunAction ; |
| 148 | + schema:actionStatus ?status . |
| 149 | + FILTER(?status IN ( |
| 150 | + "http://schema.org/CompletedActionStatus", |
| 151 | + "http://schema.org/FailedActionStatus", |
| 152 | + "http://schema.org/ActiveActionStatus" |
| 153 | + )) |
| 154 | + } |
| 155 | + """ ; |
| 156 | + ] ; |
| 157 | + |
| 158 | + sh:property [ |
| 159 | + a sh:PropertyShape ; |
| 160 | + sh:name "StartTime" ; |
| 161 | + sh:path schema:startTime ; |
| 162 | + sh:minCount 1 ; |
| 163 | + sh:maxCount 1 ; |
| 164 | + sh:severity sh:Info ; |
| 165 | + sh:description ( |
| 166 | + "The workflow execution object MAY have a startTime if actionStatus is " |
| 167 | + "either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." |
| 168 | + ) ; |
| 169 | + sh:message "The workflow execution object MAY have a startTime if actionStatus is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ; |
| 170 | + ] . |
0 commit comments