Skip to content

Commit b27c830

Browse files
committed
Refactored code
1 parent 5279b6f commit b27c830

File tree

2 files changed

+53
-87
lines changed

2 files changed

+53
-87
lines changed

rocrate_validator/profiles/five-safes-crate/must/2_requesting_agent.ttl

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,57 +22,41 @@
2222
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2323

2424

25-
# Any CreateAction entity must have one (and only one) agent
25+
2626
five-safes-crate:CreateActionHasAgent
27-
a sh:NodeShape ;
28-
sh:description "CreateAction MUST have an agent property." ;
29-
sh:targetClass schema:CreateAction ;
30-
sh:property [
31-
sh:path schema:agent ;
32-
sh:minCount 1 ;
33-
sh:nodeKind sh:IRI ;
34-
sh:message "CreateAction MUST have an agent property." ;
35-
] .
27+
a sh:NodeShape ;
28+
sh:name: "CreateAction" ;
29+
sh:targetClass schema:CreateAction ;
30+
sh:description "Checks that a CreateAction has an agent and that each agent is a schema:Person." ;
3631

32+
# CreateAction entity MUST have an agent (IRI)
33+
sh:property [
34+
a sh:PropertyShape ;
35+
sh:name "Has Agent" ;
36+
sh:path schema:agent ;
37+
sh:minCount 1 ;
38+
sh:nodeKind sh:IRI ;
39+
sh:severity sh:Violation ;
40+
sh:message "CreateAction MUST have at least one schema:agent that is an IRI." ;
41+
] ;
3742

38-
# The agent of a CreateAction must be a Person
39-
five-safes-crate:CreateActionAgentIsPerson
40-
a sh:NodeShape ;
41-
sh:description "The agent of a CreateAction entity MUST be a Person." ;
42-
sh:target [
43-
a sh:SPARQLTarget ;
44-
sh:prefixes ro-crate:sparqlPrefixes ;
45-
sh:select """
46-
SELECT DISTINCT ?this WHERE {
47-
?action a schema:CreateAction ;
48-
schema:agent ?this .
49-
}
50-
"""
51-
] ;
43+
# The agent of a CreateAction entity MUST be a Person
44+
sh:property [
45+
a sh:PropertyShape ;
46+
sh:name "Agent is a Person" ;
47+
sh:path schema:agent ;
5248
sh:class schema:Person ;
5349
sh:severity sh:Violation ;
54-
sh:message "The agent of a CreateAction entity MUST be a Person." .
55-
50+
sh:message "Each CreateAction agent MUST be typed as schema:Person and be an IRI." ;
51+
] ;
5652

57-
# The affiliation (if any) of a CreateAction's agent MUST be an Organization
58-
five-safes-crate:AgentAffiliationIsOrganization
59-
a sh:NodeShape ;
60-
sh:description "The affiliation (if any) of a CreateAction's agent MUST be an Organization" ;
53+
# If any agent affiliation exists, it MUST be an Organization (IRI)
54+
sh:property [
55+
a sh:PropertyShape ;
56+
sh:name "Affiliation is an Organization" ;
57+
sh:path ( schema:agent schema:affiliation ) ;
58+
sh:class schema:Organization ;
59+
sh:nodeKind sh:IRI ;
6160
sh:severity sh:Violation ;
62-
sh:target [
63-
a sh:SPARQLTarget ;
64-
sh:prefixes ro-crate:sparqlPrefixes ;
65-
sh:select """
66-
SELECT DISTINCT ?this WHERE {
67-
?action a schema:CreateAction ;
68-
schema:agent ?this .
69-
?this a schema:Person .
70-
?this schema:affiliation ?aff .
71-
}
72-
"""
73-
] ;
74-
sh:property [
75-
sh:path schema:affiliation ;
76-
sh:class schema:Organization ;
77-
sh:message "The affiliation (if any) of a CreateAction's agent MUST be an Organization" ;
78-
] .
61+
sh:message "The affiliation (if any) of a CreateAction's agent MUST be a schema:Organization and be an IRI." ;
62+
] .

rocrate_validator/profiles/five-safes-crate/should/2_requesting_agent.ttl

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,40 @@
1111
# Person who is the agent of a CreateAction SHOULD have an affiliation
1212
five-safes-crate:PersonAgentHasAffiliation
1313
a sh:NodeShape ;
14-
sh:name "Agent's affiliation" ;
15-
sh:description "The agent of a CreateAction entity SHOULD have an affiliation" ;
16-
sh:message "The agent of a CreateAction entity SHOULD have an affiliation" ;
14+
sh:name "Agent of CreateAction" ;
15+
sh:description "The agent of a CreateAction entity" ;
1716
sh:target [
1817
a sh:SPARQLTarget ;
1918
sh:prefixes ro-crate:sparqlPrefixes ;
2019
sh:select """
2120
SELECT DISTINCT ?this WHERE {
2221
?action a schema:CreateAction ;
2322
schema:agent ?this .
24-
?this a schema:Person .
2523
}
2624
"""
2725
] ;
26+
27+
# The agent of a CreateAction entity SHOULD have an affiliation
2828
sh:property [
29+
sh:name "Presence of affiliations" ;
2930
sh:path schema:affiliation ;
3031
sh:minCount 1 ;
32+
sh:severity sh:Warning ;
3133
sh:message "The agent of a CreateAction entity SHOULD have an affiliation" ;
32-
] .
33-
34-
35-
five-safes-crate:PersonAgentOfCreateAction_AffiliationPermalinkCheck
36-
a sh:NodeShape ;
37-
sh:name "Person (agent of CreateAction) → affiliation Organization PID check" ;
38-
sh:description "For Persons who are agents of a CreateAction, validate that any affiliation Organization has a PID permalink @id." ;
39-
40-
# Target: Persons that are objects of schema:agent where the subject is a CreateAction
41-
sh:target [
42-
a sh:SPARQLTarget ;
43-
sh:prefixes ro-crate:sparqlPrefixes ;
44-
sh:select """
45-
SELECT ?this WHERE {
46-
?this a schema:Person .
47-
?action a schema:CreateAction ;
48-
schema:agent ?this .
49-
}
50-
""" ;
51-
] ;
34+
] ;
5235

53-
# If the Person has an affiliation, validate the affiliation node's IRI
54-
sh:property [
55-
a sh:PropertyShape ;
56-
sh:name "affiliation Organization PID permalink" ;
57-
sh:path schema:affiliation ;
58-
# Optional typing requirement (keep or drop as you prefer)
59-
sh:class schema:Organization ;
60-
sh:nodeKind sh:IRI ;
61-
# Match the string form of the IRI against approved PID patterns.
62-
# - ROR: https://ror.org/0XXXXXXX## (Crockford base32 + 2 digits)
63-
# - ISNI: https://isni.org/isni/NNNNNNNNNNNNNNNX (X allowed as checksum)
64-
# - Wikidata: https://www.wikidata.org/entity/Q<digits> (or without www)
65-
sh:pattern "^(?:https://(?:ror\\.org/0[0-9a-hjkmnp-tv-z]{6}[0-9]{2}|isni\\.org/isni/\\d{15}[\\dX]|(?:www\\.)?wikidata\\.org/entity/Q\\d+))$" ;
66-
sh:flags "i" ;
67-
sh:message "Affiliation Organization @id SHOULD be a PID permalink (ROR/ISNI/Wikidata)." ;
68-
] .
36+
# If the agent has an affiliation, validate the affiliation node's IRI
37+
sh:property [
38+
a sh:PropertyShape ;
39+
sh:name "Affiliation IRI" ;
40+
sh:path schema:affiliation ;
41+
sh:nodeKind sh:IRI ;
42+
sh:or (
43+
[ sh:pattern "^https://ror\\.org/0[0-9a-hjkmnp-tv-z]{6}[0-9]{2}$" ]
44+
[ sh:pattern "^https://isni\\.org/isni/\\d{15}[\\dX]$" ]
45+
[ sh:pattern "^https://(?:www\\.)?wikidata\\.org/entity/Q\\d+$" ]
46+
) ;
47+
sh:flags "i" ;
48+
sh:severity sh:Warning ;
49+
sh:message "Affiliation Organization @id SHOULD be a permalink (ROR/ISNI/Wikidata)." ;
50+
] .

0 commit comments

Comments
 (0)