Closed ensaremirerol closed 10 months ago
Basically added a extra flag for CLI tool named -addBlankNodes. With this flag enabled tool will append all blank nodes that references shapes file.
Here is the data/shape file I used in testing and the validation report outputted from tool with mention flag enabled
Data and Shape
@prefix : <https://biomedit.ch/rdf/sphn-schema/sphn#> . @prefix chop: <https://biomedit.ch/rdf/sphn-resource/chop/> . @prefix constraints: <https://biomedit.ch/rdf/sphn-schema-constraints/sphn#> . @prefix dcterms: <http://purl.org/dc/terms/> . @prefix eco: <http://purl.obolibrary.org/obo/ECO_> . @prefix edam: <http://edamontology.org/> . @prefix efo: <http://www.ebi.ac.uk/efo/EFO_> . @prefix emdn: <https://biomedit.ch/rdf/sphn-resource/emdn/> . @prefix genepio: <http://purl.obolibrary.org/obo/GENEPIO_> . @prefix geno: <http://purl.obolibrary.org/obo/GENO_> . @prefix icd-10-gm: <https://biomedit.ch/rdf/sphn-resource/icd-10-gm/> . @prefix obi: <http://purl.obolibrary.org/obo/OBI_> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix sh: <http://www.w3.org/ns/shacl#> . @prefix skos: <http://www.w3.org/2004/02/skos/core#> . @prefix snomed: <http://snomed.info/id/> . @prefix so: <http://purl.obolibrary.org/obo/SO_> . @prefix sphn-atc: <https://biomedit.ch/rdf/sphn-resource/atc/> . @prefix sphn-loinc: <https://biomedit.ch/rdf/sphn-resource/loinc/> . @prefix ucum: <https://biomedit.ch/rdf/sphn-resource/ucum/> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix ex: <http://example.org/> . constraints:AccessDevice a sh:NodeShape ; sh:closed false ; sh:ignoredProperties ( rdf:type ) ; sh:property [ sh:maxCount 1 ; sh:message "constraint:AccessDevice_1", "message:MinCount, Or, or MaxCount constraint violated, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, http://snomed.info/id/105789008, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology", "sparql:SELECT ?this (COUNT(?o) AS ?actualCount) ?actual WHERE { ?this <https://biomedit.ch/rdf/sphn-schema/sphn#hasTypeCode> ?o . ?o rdf:type ?actual . }", "template:MinCount, Or, or MaxCount constraint violated on {this} on hasTypeCode, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, http://snomed.info/id/105789008, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology, found {actualCount} objects of type {actual}" ; sh:minCount 0 ; sh:or ( [ sh:class :Code ] [ sh:class snomed:105789008 ] [ sh:class :Terminology ] ) ; sh:path :hasTypeCode ], [ sh:maxCount 1 ; sh:message "constraint:AccessDevice_2", "message:MinCount, Or, or MaxCount constraint violated, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology", "sparql:SELECT ?this (COUNT(?o) AS ?actualCount) ?actual WHERE { ?this <https://biomedit.ch/rdf/sphn-schema/sphn#hasProductCode> ?o . ?o rdf:type ?actual . }", "template:MinCount, Or, or MaxCount constraint violated on {this} on hasProductCode, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology, found {actualCount} objects of type {actual}" ; sh:minCount 0 ; sh:or ( [ sh:class :Code ] [ sh:class :Terminology ] ) ; sh:path :hasProductCode ] ; sh:targetClass :AccessDevice . ex:test a :AccessDevice ; :hasTypeCode ex:dummy ; :hasTypeCode ex:dummy2 . ex:dummy a ex:dummyType1 . ex:dummy2 a ex:dummyType2 .
Validation Report with Blank Node/s
@prefix : <https://biomedit.ch/rdf/sphn-schema/sphn#> . @prefix chop: <https://biomedit.ch/rdf/sphn-resource/chop/> . @prefix constraints: <https://biomedit.ch/rdf/sphn-schema-constraints/sphn#> . @prefix dash: <http://datashapes.org/dash#> . @prefix dcterms: <http://purl.org/dc/terms/> . @prefix eco: <http://purl.obolibrary.org/obo/ECO_> . @prefix edam: <http://edamontology.org/> . @prefix efo: <http://www.ebi.ac.uk/efo/EFO_> . @prefix emdn: <https://biomedit.ch/rdf/sphn-resource/emdn/> . @prefix ex: <http://example.org/> . @prefix genepio: <http://purl.obolibrary.org/obo/GENEPIO_> . @prefix geno: <http://purl.obolibrary.org/obo/GENO_> . @prefix graphql: <http://datashapes.org/graphql#> . @prefix icd-10-gm: <https://biomedit.ch/rdf/sphn-resource/icd-10-gm/> . @prefix obi: <http://purl.obolibrary.org/obo/OBI_> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix sh: <http://www.w3.org/ns/shacl#> . @prefix skos: <http://www.w3.org/2004/02/skos/core#> . @prefix snomed: <http://snomed.info/id/> . @prefix so: <http://purl.obolibrary.org/obo/SO_> . @prefix sphn-atc: <https://biomedit.ch/rdf/sphn-resource/atc/> . @prefix sphn-loinc: <https://biomedit.ch/rdf/sphn-resource/loinc/> . @prefix swa: <http://topbraid.org/swa#> . @prefix tosh: <http://topbraid.org/tosh#> . @prefix ucum: <https://biomedit.ch/rdf/sphn-resource/ucum/> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . _:b0 sh:maxCount 1 ; sh:message "template:MinCount, Or, or MaxCount constraint violated on {this} on hasTypeCode, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, http://snomed.info/id/105789008, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology, found {actualCount} objects of type {actual}" , "sparql:SELECT ?this (COUNT(?o) AS ?actualCount) ?actual WHERE { ?this <https://biomedit.ch/rdf/sphn-schema/sphn#hasTypeCode> ?o . ?o rdf:type ?actual . }" , "message:MinCount, Or, or MaxCount constraint violated, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, http://snomed.info/id/105789008, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology" , "constraint:AccessDevice_1" ; sh:minCount 0 ; sh:or ( [ sh:class :Code ] [ sh:class snomed:105789008 ] [ sh:class :Terminology ] ) ; sh:path :hasTypeCode . [ rdf:type sh:ValidationReport ; sh:conforms false ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:test ; sh:resultMessage "constraint:AccessDevice_1" , "sparql:SELECT ?this (COUNT(?o) AS ?actualCount) ?actual WHERE { ?this <https://biomedit.ch/rdf/sphn-schema/sphn#hasTypeCode> ?o . ?o rdf:type ?actual . }" , "message:MinCount, Or, or MaxCount constraint violated, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, http://snomed.info/id/105789008, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology" , "template:MinCount, Or, or MaxCount constraint violated on {this} on hasTypeCode, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, http://snomed.info/id/105789008, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology, found {actualCount} objects of type {actual}" ; sh:resultPath :hasTypeCode ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; sh:sourceShape _:b0 ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:test ; sh:resultMessage "sparql:SELECT ?this (COUNT(?o) AS ?actualCount) ?actual WHERE { ?this <https://biomedit.ch/rdf/sphn-schema/sphn#hasTypeCode> ?o . ?o rdf:type ?actual . }" , "constraint:AccessDevice_1" , "template:MinCount, Or, or MaxCount constraint violated on {this} on hasTypeCode, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, http://snomed.info/id/105789008, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology, found {actualCount} objects of type {actual}" , "message:MinCount, Or, or MaxCount constraint violated, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, http://snomed.info/id/105789008, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology" ; sh:resultPath :hasTypeCode ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:OrConstraintComponent ; sh:sourceShape _:b0 ; sh:value ex:dummy ] ; sh:result [ rdf:type sh:ValidationResult ; sh:focusNode ex:test ; sh:resultMessage "template:MinCount, Or, or MaxCount constraint violated on {this} on hasTypeCode, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, http://snomed.info/id/105789008, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology, found {actualCount} objects of type {actual}" , "message:MinCount, Or, or MaxCount constraint violated, expected minCount is 0 and maxCount is 1 and expected one of the following: https://biomedit.ch/rdf/sphn-schema/sphn#Code, http://snomed.info/id/105789008, https://biomedit.ch/rdf/sphn-schema/sphn#Terminology" , "constraint:AccessDevice_1" , "sparql:SELECT ?this (COUNT(?o) AS ?actualCount) ?actual WHERE { ?this <https://biomedit.ch/rdf/sphn-schema/sphn#hasTypeCode> ?o . ?o rdf:type ?actual . }" ; sh:resultPath :hasTypeCode ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:OrConstraintComponent ; sh:sourceShape _:b0 ; sh:value ex:dummy2 ] ] .
I've refactored code based on your feedback. Thanks!
88
Basically added a extra flag for CLI tool named -addBlankNodes. With this flag enabled tool will append all blank nodes that references shapes file.
Here is the data/shape file I used in testing and the validation report outputted from tool with mention flag enabled
Data and Shape
Validation Report with Blank Node/s