-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds a feature of dimension anotations #202
Changes from 7 commits
641d841
1010867
abfab69
400a1fb
160bdb2
58f152b
8dea9ea
ab75afa
a3575ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"cube-link": patch | ||
--- | ||
|
||
Adding dimension annotations (`meta:annotation`) re https://gitlab.ldbar.ch/bafu/visualize/-/issues/542 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
PREFIX ex: <http://example.org/> | ||
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> . | ||
|
||
<observationA> a cube:Observation ; | ||
cube:observedBy <observer> ; | ||
<measure> 4.9 ; | ||
<year> <https://ld.admin.ch/time/year/2020> ; | ||
. | ||
|
||
<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 <measure> ; | ||
schema:name "measure" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
meta:annotation | ||
[ | ||
a meta:Limit ; | ||
schema:value 97 ; | ||
schema:name "Target 2020+" ; | ||
meta:annotationContext | ||
[ | ||
sh:path <year> ; | ||
sh:minInclusive <https://ld.admin.ch/time/year/2020> ; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why two lower bounds? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a test cases which should fail There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, I see, to check they are not accepted :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to make this even more accurate but I seem to have hit a limitation of shat SHACL can do when there are multiple properties with same value. I failed to make a validation to catch for example sh:minInclusive <https://ld.admin.ch/time/year/2020>
sh:minExclusive <https://ld.admin.ch/time/year/2020> |
||
sh:minExclusive <https://ld.admin.ch/time/year/2022> ; | ||
] ; | ||
] ; | ||
] ; | ||
sh:property | ||
[ | ||
a meta:KeyDimension ; | ||
sh:path <year> ; | ||
schema:name "year" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
sh:nodeKind sh:IRI ; | ||
] ; | ||
sh:property | ||
[ | ||
a meta:KeyDimension ; | ||
sh:path <station> ; | ||
schema:name "station" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
sh:nodeKind sh:IRI ; | ||
] ; | ||
. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@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:XoneConstraintComponent ; | ||
sh:sourceShape <https://cube.link/shape/standalone-constraint-constraint#AnnotationContext> ; | ||
sh:focusNode _:b5 ; | ||
sh:value _:b5 ; | ||
sh:resultMessage "annotation context only allows constraints sh:hasValue, sh:in, sh:minInclusive, sh:maxInclusive, sh:minExclusive, sh:maxExclusive and they cannot be mixed" ; | ||
] ; | ||
sh:conforms false . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
PREFIX ex: <http://example.org/> | ||
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> . | ||
|
||
<observationA> a cube:Observation ; | ||
cube:observedBy <observer> ; | ||
<measure> 4.9 ; | ||
<year> <https://ld.admin.ch/time/year/2020> ; | ||
. | ||
|
||
<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 <measure> ; | ||
schema:name "measure" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
meta:annotation | ||
[ | ||
a meta:Limit ; | ||
schema:value 95 ; | ||
meta:annotationContext | ||
[ | ||
sh:path <non-dimension> ; | ||
sh:hasValue 10 ; | ||
] ; | ||
] , | ||
[ | ||
a meta:Limit ; | ||
schema:value 95 ; | ||
meta:annotationContext | ||
[ | ||
sh:path <station> ; | ||
sh:hasValue ex:Station ; | ||
] ; | ||
] ; | ||
] ; | ||
sh:property | ||
[ | ||
a meta:KeyDimension ; | ||
sh:path <year> ; | ||
schema:name "year" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
sh:nodeKind sh:IRI ; | ||
] ; | ||
sh:property | ||
[ | ||
sh:path <station> ; | ||
schema:name "station" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
sh:nodeKind sh:IRI ; | ||
] ; | ||
. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@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:NotConstraintComponent ; | ||
sh:sourceShape <https://cube.link/shape/standalone-constraint-constraint#AnnotationContextDimensionType> ; | ||
sh:focusNode _:b5 ; | ||
sh:value _:b5 ; | ||
sh:resultMessage "annotation context must have exactly one sh:path which is cube's key dimension" ; | ||
], [ | ||
rdf:type sh:ValidationResult ; | ||
sh:resultSeverity sh:Violation ; | ||
sh:sourceConstraintComponent sh:XoneConstraintComponent ; | ||
sh:sourceShape [ | ||
sh:path _:b706 ; | ||
sh:xone ( | ||
[ | ||
sh:class <https://cube.link/meta/KeyDimension> ; | ||
] | ||
[ | ||
sh:property [ | ||
sh:path [ | ||
sh:inversePath <https://cube.link/meta/annotationContext> ; | ||
] ; | ||
sh:minCount 1 ; | ||
] ; | ||
] | ||
) ; | ||
] ; | ||
sh:focusNode _:b7 ; | ||
sh:value _:b9 ; | ||
sh:resultPath _:b706 ; | ||
] ; | ||
sh:conforms false . | ||
|
||
_:b706 rdf:first sh:path ; | ||
rdf:rest ( | ||
[ | ||
sh:inversePath sh:path ; | ||
] | ||
) . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find a simple enough way to include this in the validation shape