Skip to content

Commit e95fb99

Browse files
authored
Merge pull request #27 from eScienceLab/97-responsible-project-mk2
Checks for rules about Responsible Project
2 parents a1dd141 + 1e5d8c6 commit e95fb99

File tree

11 files changed

+804
-0
lines changed

11 files changed

+804
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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:ResponsibleProject
26+
a sh:NodeShape ;
27+
sh:name "Responsible Project" ;
28+
sh:target [
29+
a sh:SPARQLTarget ;
30+
sh:prefixes ro-crate:sparqlPrefixes ;
31+
sh:select """
32+
SELECT DISTINCT ?this WHERE {
33+
?action a schema:CreateAction ;
34+
schema:agent ?agent .
35+
?agent schema:memberOf ?this .
36+
}
37+
"""
38+
] ;
39+
40+
sh:property [
41+
a sh:PropertyShape ;
42+
sh:name "funding" ;
43+
sh:path schema:funding;
44+
sh:minCount 1 ;
45+
sh:severity sh:Info ;
46+
sh:message """The Responsible Project does not have the property `funding`.""" ;
47+
] ;
48+
49+
sh:property [
50+
a sh:PropertyShape ;
51+
sh:name "member" ;
52+
sh:path schema:member;
53+
sh:minCount 1 ;
54+
sh:severity sh:Info ;
55+
sh:message """The Responsible Project does not have the property `member`.""" ;
56+
] .
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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:AgentIsMemberOf
26+
a sh:NodeShape ;
27+
sh:name "Requesting Agent" ;
28+
sh:target [
29+
a sh:SPARQLTarget ;
30+
sh:prefixes ro-crate:sparqlPrefixes ;
31+
sh:select """
32+
SELECT DISTINCT ?this WHERE {
33+
?action a schema:CreateAction ;
34+
schema:agent ?this .
35+
}
36+
"""
37+
] ;
38+
39+
sh:property [
40+
a sh:PropertyShape ;
41+
sh:name "memberOf" ;
42+
sh:path schema:memberOf;
43+
sh:class schema:Project ;
44+
sh:severity sh:Violation ;
45+
sh:message """The 'memberOf' property of an agent MUST be of type Project.""" ;
46+
] .
47+
48+
49+
five-safes-crate:AgentProjectIntersection
50+
a sh:NodeShape ;
51+
sh:name "Agent Project Intersection" ;
52+
sh:description """At least one Project referenced by Agent -> memberOf MUST be included in the set of Projects referenced by RootDataEntity -> sourceOrganization.""" ;
53+
sh:target [
54+
a sh:SPARQLTarget ;
55+
sh:prefixes ro-crate:sparqlPrefixes ;
56+
sh:select """
57+
SELECT DISTINCT ?this WHERE {
58+
?action a schema:CreateAction ;
59+
schema:agent ?this .
60+
}
61+
"""
62+
] ;
63+
sh:sparql [
64+
a sh:SPARQLConstraint ;
65+
sh:name "Agent Project Intersection" ;
66+
sh:description """At least one Project referenced by Agent -> memberOf MUST be included in the set of Projects referenced by RootDataEntity -> sourceOrganization.""" ;
67+
sh:prefixes ro-crate:sparqlPrefixes ;
68+
sh:select """
69+
SELECT $this WHERE {
70+
FILTER EXISTS {
71+
$this schema:memberOf ?anyProject .
72+
}
73+
FILTER NOT EXISTS {
74+
$this schema:memberOf ?commonProject .
75+
?metadata schema:about ?root .
76+
?root schema:sourceOrganization ?commonProject .
77+
}
78+
}
79+
""" ;
80+
sh:severity sh:Violation ;
81+
sh:message """At least one Project referenced by Agent -> memberOf MUST be included in the set of Projects referenced by RootDataEntity -> sourceOrganization.""" ;
82+
] .
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:ResponsibleProject
26+
a sh:NodeShape ;
27+
sh:name "Responsible Project" ;
28+
sh:target [
29+
a sh:SPARQLTarget ;
30+
sh:prefixes ro-crate:sparqlPrefixes ;
31+
sh:select """
32+
SELECT DISTINCT ?this WHERE {
33+
?action a schema:CreateAction ;
34+
schema:agent ?agent .
35+
?agent schema:memberOf ?this .
36+
}
37+
"""
38+
] ;
39+
40+
sh:property [
41+
a sh:PropertyShape ;
42+
sh:name "funding" ;
43+
sh:path schema:funding;
44+
sh:class schema:Grant ;
45+
sh:severity sh:Violation ;
46+
sh:message """The property 'funding' of the Responsible Project MUST be of type schema:Grant.""" ;
47+
] ;
48+
49+
sh:property [
50+
a sh:PropertyShape ;
51+
sh:name "member" ;
52+
sh:path schema:member;
53+
sh:or (
54+
[ sh:class schema:Organization ]
55+
[ sh:class schema:Person ]
56+
) ;
57+
sh:severity sh:Violation ;
58+
sh:message """The property 'member' of the Responsible Project MUST be of type schema:Organization or schema:Person.""" ;
59+
] .
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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:RootDataEntityRequiredProperties
26+
a sh:NodeShape ;
27+
sh:name "RootDataEntity" ;
28+
sh:targetClass ro-crate:RootDataEntity ;
29+
30+
sh:property [
31+
a sh:PropertyShape ;
32+
sh:name "sourceOrganization" ;
33+
sh:path schema:sourceOrganization;
34+
sh:minCount 1 ;
35+
sh:severity sh:Violation ;
36+
sh:message """The Root Data Entity MUST have a `sourceOrganization` property.""" ;
37+
] ;
38+
39+
sh:property [
40+
a sh:PropertyShape ;
41+
sh:name "sourceOrganization" ;
42+
sh:path schema:sourceOrganization ;
43+
sh:class schema:Project ;
44+
sh:severity sh:Violation ;
45+
sh:message """The `sourceOrganization` property of the RootDataEntity MUST point to a Project entity.""" ;
46+
] .
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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:AgentIsMemberOf
26+
a sh:NodeShape ;
27+
sh:name "Requesting Agent" ;
28+
sh:target [
29+
a sh:SPARQLTarget ;
30+
sh:prefixes ro-crate:sparqlPrefixes ;
31+
sh:select """
32+
SELECT DISTINCT ?this WHERE {
33+
?action a schema:CreateAction ;
34+
schema:agent ?this .
35+
}
36+
"""
37+
] ;
38+
39+
sh:property [
40+
a sh:PropertyShape ;
41+
sh:name "memberOf" ;
42+
sh:path schema:memberOf;
43+
sh:minCount 1 ;
44+
sh:severity sh:Warning ;
45+
sh:message """The Requesting Agent SHOULD have a `memberOf` property.""" ;
46+
] .
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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:ResponsibleProjectMemberAndSourceOrganizationIntersection
26+
a sh:NodeShape ;
27+
sh:name "Organizations (members of Responsible Project)" ;
28+
sh:description """At least one of the organisations that are members of the responsible project SHOULD be included in the Requesting Agent's affiliations, if such properties exist.""" ;
29+
sh:target [
30+
a sh:SPARQLTarget ;
31+
sh:prefixes ro-crate:sparqlPrefixes ;
32+
sh:select """
33+
SELECT DISTINCT ?this WHERE {
34+
?action a schema:CreateAction ;
35+
schema:agent ?this .
36+
?this a schema:Person ;
37+
schema:memberOf ?project ;
38+
schema:affiliation ?someAffiliation .
39+
?project schema:member ?org2 .
40+
}
41+
"""
42+
] ;
43+
sh:sparql [
44+
a sh:SPARQLConstraint ;
45+
sh:name "Intersection with agent affiliations" ;
46+
sh:description """At least one of the organisations that are members of the responsible project SHOULD be included in the Requesting Agent's affiliations, if such properties exist.""" ;
47+
48+
sh:prefixes ro-crate:sparqlPrefixes ;
49+
sh:select """
50+
SELECT $this WHERE {
51+
FILTER NOT EXISTS {
52+
$this schema:affiliation ?org .
53+
$this schema:memberOf ?project .
54+
?project schema:member ?org .
55+
}
56+
}
57+
""" ;
58+
sh:severity sh:Warning ;
59+
sh:message """At least one of the organisations that are members of the responsible project SHOULD be included in the Requesting Agent's affiliations, if such properties exist.""" ;
60+
] .

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
"@type": "Organization",
102102
"name": "The University of Manchester"
103103
},
104+
{
105+
"@id": "https://ror.org/01ee9ar58",
106+
"@type": "Organization",
107+
"name": "University of Nottingham"
108+
},
104109
{
105110
"@id": "#project-be6ffb55-4f5a-4c14-b60e-47e0951090c70",
106111
"@type": "Project",

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@
366366
"@type": "Organization",
367367
"name": "The University of Manchester"
368368
},
369+
{
370+
"@id": "https://ror.org/01ee9ar58",
371+
"@type": "Organization",
372+
"name": "University of Nottingham"
373+
},
369374
{
370375
"@id": "https://gtr.ukri.org/projects?ref=10038961",
371376
"@type": "Grant",

0 commit comments

Comments
 (0)