Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,87 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .


#=== MUST shapes ===#

five-safes-crate:CheckValueObjectHasDescriptiveNameAndIsAssessAction
a sh:NodeShape ;
sh:name "CheckValue" ;
sh:description "" ;

sh:target [
a sh:SPARQLTarget ;
sh:select """
PREFIX schema: <http://schema.org/>
PREFIX shp: <https://w3id.org/shp#>

SELECT ?this
WHERE {
?this schema:additionalType shp:CheckValue .
}
""" ;
] ;

sh:property [
sh:path rdf:type ;
sh:minCount 1 ;
sh:hasValue schema:AssessAction;
sh:severity sh:Violation ;
sh:message "CheckValue MUST be a `AssessAction`." ;
] ;

sh:property [
sh:a sh:PropertyShape ;
sh:name "name" ;
sh:description "CheckValue MUST have a human readable name string." ;
sh:path schema:name ;
sh:datatype xsd:string ;
sh:severity sh:Violation ;
sh:message "CheckValue MUST have a human readable name string." ;
] .


five-safes-crate:CheckValueActionStatusMustHaveAllowedValues
a sh:NodeShape ;
sh:name "CheckValue" ;
sh:description "" ;

sh:target [
a sh:SPARQLTarget ;
sh:select """
PREFIX schema: <http://schema.org/>
PREFIX shp: <https://w3id.org/shp#>

SELECT ?this
WHERE {
?this schema:additionalType shp:CheckValue ;
schema:actionStatus ?status .
}
""" ;
] ;

sh:property [
a sh:PropertyShape ;
sh:name "ActionStatus" ;
sh:path schema:actionStatus ;
sh:in (
"http://schema.org/PotentialActionStatus"
"http://schema.org/ActiveActionStatus"
"http://schema.org/CompletedActionStatus"
"http://schema.org/FailedActionStatus"
) ;
sh:severity sh:Violation ;
sh:message "`CheckValue` --> `actionStatus` MUST have one of the allowed values." ;
] .


#=== SHOULD shapes ===#

five-safes-crate:RootDataEntityShouldMentionCheckValueObject
a sh:NodeShape ;
sh:name "RootDataEntity" ;
sh:targetClass ro-crate:RootDataEntity ;
sh:description "" ;
sh:severity sh:Warning ;

sh:sparql [
a sh:SPARQLConstraint ;
Expand All @@ -44,7 +120,6 @@ five-safes-crate:RootDataEntityShouldMentionCheckValueObject
}
}
""" ;
sh:severity sh:Warning ;
sh:message "RootDataEntity SHOULD mention a check value object." ;
] .

Expand Down Expand Up @@ -188,3 +263,38 @@ five-safes-crate:CheckValueShouldHaveActionStatus
sh:severity sh:Warning ;
sh:message "CheckValue SHOULD have actionStatus property." ;
] .


#=== MAY shapes ===#

five-safes-crate:CheckValueMayHaveStartTime
a sh:NodeShape ;
sh:name "CheckValue" ;
sh:description "" ;
sh:target [
a sh:SPARQLTarget ;
sh:select """
PREFIX schema: <http://schema.org/>
PREFIX shp: <https://w3id.org/shp#>
SELECT ?this
WHERE {
?this schema:additionalType shp:CheckValue ;
schema:actionStatus ?status .
FILTER(?status IN (
"http://schema.org/CompletedActionStatus",
"http://schema.org/FailedActionStatus",
"http://schema.org/ActiveActionStatus"
))
}
""" ;
] ;

sh:property [
a sh:PropertyShape ;
sh:name "StartTime" ;
sh:path schema:startTime ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:severity sh:Info ;
sh:message "`CheckValue` MAY have the `startTime` property." ;
] .
56 changes: 0 additions & 56 deletions rocrate_validator/profiles/five-safes-crate/may/12_check_phase.ttl

This file was deleted.

This file was deleted.

19 changes: 18 additions & 1 deletion tests/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ def replace_uri_in_graph(graph, old_uri_str, new_uri_str):
return g


def _uses_https_schema(graph: rdflib.Graph) -> bool:
for s, p, o in graph.triples((None, None, None)):
for term in (s, p, o):
if isinstance(term, rdflib.URIRef) and str(term).startswith(
"https://schema.org/"
):
return True
return False


def do_entity_test(
rocrate_path: Union[Path, str],
requirement_severity: models.Severity,
Expand Down Expand Up @@ -152,10 +162,17 @@ def do_entity_test(
if rocrate_entity_mod_sparql is not None:
rocrate_graph = load_graph_and_preserve_relative_ids(rocrate)

if _uses_https_schema(rocrate_graph):
rocrate_entity_mod_sparql = rocrate_entity_mod_sparql.replace(
"http://schema.org/",
"https://schema.org/",
)

rocrate_graph.update(rocrate_entity_mod_sparql)

# save the updated RO-Crate metadata
context = "https://w3id.org/ro/crate/1.1/context"
# preserve the original context to avoid forcing a downgrade
context = rocrate.get("@context", "https://w3id.org/ro/crate/1.2/context")
rocrate_graph.serialize(
Path(temp_rocrate_path, "ro-crate-metadata.json"),
format="json-ld",
Expand Down
Loading