-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from zazuko/error-margin-validation
Dimension relation validations
- Loading branch information
Showing
8 changed files
with
319 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"cube-link": patch | ||
--- | ||
|
||
Improve validation of `meta:dimensionRelation`: | ||
|
||
1. Check that upper/lower bound has at most one `dcterms:type` | ||
2. Check that `meta:relatesTo` is actually a dimension |
63 changes: 63 additions & 0 deletions
63
test/standalone-constraint-constraint/invalid.dimensionRelation-multipleDcType.ttl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
PREFIX dcterms: <http://purl.org/dc/terms/> | ||
@prefix relation: <https://cube.link/relation/> . | ||
@prefix meta: <https://cube.link/meta/> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix cube: <https://cube.link/> . | ||
@prefix observation: <https://environment.ld.admin.ch/foen/nfi/observation/max_min_undefined> . | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix schema: <http://schema.org/> . | ||
@base <https://example.org/> . | ||
|
||
<cube> a cube:Cube ; | ||
cube:observationConstraint <shape> ; | ||
cube:observationSet <observationSet> . | ||
|
||
<observationSet> cube:observation <observationA>, <observationB>, <observationC> . | ||
|
||
<observationA> a cube:Observation ; | ||
cube:observedBy <observer> ; | ||
<dimension> 4.9 ; | ||
<upperConfidence> 0.1 ; | ||
. | ||
|
||
<shape> a cube:Constraint ; | ||
sh:targetClass cube:Observation ; | ||
sh:closed true ; | ||
sh:property | ||
[ | ||
sh:path rdf:type ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
sh:path cube:observedBy ; ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
a cube:MeasureDimension ; | ||
sh:datatype xsd:decimal ; | ||
sh:path <dimension> ; | ||
schema:name "dimension" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
], | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <upperConfidence> ; | ||
schema:name "upper confidence" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
meta:dimensionRelation | ||
[ | ||
a relation:ConfidenceUpperBound ; | ||
dcterms:type "Confidence interval", "bogus" ; | ||
meta:relatesTo <dimension> ; | ||
] ; | ||
]; | ||
. |
21 changes: 21 additions & 0 deletions
21
...tandalone-constraint-constraint/invalid.dimensionRelation-multipleDcType.ttl.approved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix schema: <http://schema.org/> . | ||
@prefix cube: <https://cube.link/> . | ||
|
||
_:report a sh:ValidationReport ; | ||
sh:result [ | ||
rdf:type sh:ValidationResult ; | ||
sh:resultSeverity sh:Violation ; | ||
sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; | ||
sh:sourceShape [ | ||
sh:path <http://purl.org/dc/terms/type> ; | ||
sh:maxCount 1 ; | ||
] ; | ||
sh:focusNode _:b5 ; | ||
sh:resultPath <http://purl.org/dc/terms/type> ; | ||
sh:resultMessage "More than 1 values" ; | ||
] ; | ||
sh:conforms false . |
62 changes: 62 additions & 0 deletions
62
test/standalone-constraint-constraint/invalid.dimensionRelation-relatesToNotMatching.ttl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@prefix dcterms: <http://purl.org/dc/terms/> . | ||
@prefix relation: <https://cube.link/relation/> . | ||
@prefix meta: <https://cube.link/meta/> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix cube: <https://cube.link/> . | ||
@prefix observation: <https://environment.ld.admin.ch/foen/nfi/observation/max_min_undefined> . | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix schema: <http://schema.org/> . | ||
@base <https://example.org/> . | ||
|
||
<cube> a cube:Cube ; | ||
cube:observationConstraint <shape> ; | ||
cube:observationSet <observationSet> . | ||
|
||
<observationSet> cube:observation <observationA>, <observationB>, <observationC> . | ||
|
||
<observationA> a cube:Observation ; | ||
cube:observedBy <observer> ; | ||
<dimension> 4.9 ; | ||
<upperConfidence> 0.1 ; | ||
. | ||
|
||
<shape> a cube:Constraint ; | ||
sh:targetClass cube:Observation ; | ||
sh:closed true ; | ||
sh:property | ||
[ | ||
sh:path rdf:type ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
sh:path cube:observedBy ; ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <dimension> ; | ||
schema:name "dimension" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
], | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <upperConfidence> ; | ||
schema:name "upper confidence" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
meta:dimensionRelation | ||
[ | ||
a relation:ConfidenceUpperBound ; | ||
dcterms:type "Confidence interval" ; | ||
meta:relatesTo <non-dimension> ; | ||
] ; | ||
]; | ||
. |
46 changes: 46 additions & 0 deletions
46
...one-constraint-constraint/invalid.dimensionRelation-relatesToNotMatching.ttl.approved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix schema: <http://schema.org/> . | ||
@prefix cube: <https://cube.link/> . | ||
|
||
_:report a sh:ValidationReport ; | ||
sh:result [ | ||
rdf:type sh:ValidationResult ; | ||
sh:resultSeverity sh:Violation ; | ||
sh:sourceConstraintComponent sh:NodeConstraintComponent ; | ||
sh:sourceShape [ | ||
sh:path sh:property ; | ||
sh:node <https://cube.link/shape/standalone-constraint-constraint#DimensionRelation> ; | ||
] ; | ||
sh:focusNode <https://example.org/shape> ; | ||
sh:resultPath sh:property ; | ||
sh:resultMessage "Value does not have shape <https://cube.link/shape/standalone-constraint-constraint#DimensionRelation>" ; | ||
sh:detail [ | ||
rdf:type sh:ValidationResult ; | ||
sh:resultSeverity sh:Violation ; | ||
sh:sourceConstraintComponent sh:MinCountConstraintComponent ; | ||
sh:sourceShape [ | ||
sh:path _:b675 ; | ||
sh:class cube:Constraint ; | ||
sh:minCount 1 ; | ||
sh:message "value of meta:relatesTo must be a cube dimension" ; | ||
] ; | ||
sh:focusNode _:b5 ; | ||
sh:resultPath _:b675 ; | ||
sh:resultMessage "value of meta:relatesTo must be a cube dimension" ; | ||
] ; | ||
sh:value _:b4 ; | ||
] ; | ||
sh:conforms false . | ||
|
||
_:b675 rdf:first <https://cube.link/meta/relatesTo> ; | ||
rdf:rest ( | ||
[ | ||
sh:inversePath sh:path ; | ||
] | ||
[ | ||
sh:inversePath sh:property ; | ||
] | ||
) . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
test/standalone-constraint-constraint/valid.dimensionRelation.ttl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
PREFIX dcterms: <http://purl.org/dc/terms/> | ||
@prefix relation: <https://cube.link/relation/> . | ||
@prefix meta: <https://cube.link/meta/> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix cube: <https://cube.link/> . | ||
@prefix observation: <https://environment.ld.admin.ch/foen/nfi/observation/max_min_undefined> . | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix schema: <http://schema.org/> . | ||
@base <https://example.org/> . | ||
|
||
<cube> a cube:Cube ; | ||
cube:observationConstraint <shape> ; | ||
cube:observationSet <observationSet> . | ||
|
||
<observationSet> cube:observation <observationA>, <observationB>, <observationC> . | ||
|
||
<observationA> a cube:Observation ; | ||
cube:observedBy <observer> ; | ||
<dimension> 4.9 ; | ||
<upperConfidence> 0.1 ; | ||
<lowerConfidence> 0.15 ; | ||
. | ||
|
||
<shape> a cube:Constraint ; | ||
sh:targetClass cube:Observation ; | ||
sh:closed true ; | ||
sh:property | ||
[ | ||
sh:path rdf:type ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
sh:path cube:observedBy ; ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
a cube:MeasureDimension ; | ||
sh:datatype xsd:decimal ; | ||
sh:path <dimension> ; | ||
schema:name "dimension" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
], | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <upperConfidence> ; | ||
schema:name "upper confidence" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
meta:dimensionRelation | ||
[ | ||
a relation:ConfidenceUpperBound ; | ||
dcterms:type "Confidence interval" ; | ||
meta:relatesTo <dimension> ; | ||
] ; | ||
], | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <lowerConfidence> ; | ||
schema:name "lower confidence" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
meta:dimensionRelation | ||
[ | ||
a relation:ConfidenceLowerBound ; | ||
dcterms:type "Confidence interval" ; | ||
meta:relatesTo <dimension> ; | ||
] ; | ||
] ; | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters