neosemantics
neosemantics copied to clipboard
Support for sh:inversePath for one-to-one condition
How one-to-one condition can be implemented?
As I understand in SHACL we can define 2 shapes for direct and reverse conditions with sh:maxCount 1; sh:minCount 1 for singe edge (e.g. HAS_PART)
But for reverse one sh:inversePath
is needed but it seems that it is not supported by cur version of neosemantics
call n10s.validation.shacl.import.inline('
@prefix neo4j: <neo4j://graph.schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
neo4j:PartShape a sh:NodeShape;
sh:targetClass neo4j:Part;
sh:property [
sh:inversePath neo4j:HAS_PART;
sh:maxCount 1;
sh:minCount 1;
sh:class neo4j:System;
] ;
.
','Turtle')
how about using a blank node with sh:path
for the sh:inversePath
?
@prefix neo4j: <neo4j://graph.schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
neo4j:PartShape a sh:NodeShape;
sh:targetClass neo4j:Part;
sh:property [
sh:path [sh:inversePath neo4j:HAS_PART];
sh:maxCount 1;
sh:minCount 1;
sh:class neo4j:System;
] .
Hello, Currently working with neosemantics, I'm facing the exact same problem.
The first solution by @palandlom fail at constraint creation with a NullPointerException. For the second solution by @joedavid91 , the creation is ok but at validation, we get a ClassCastException. (into cypher.internal.expressions package : HasDegreeLessThan cannot be cast to InequalityExpression).
Have you find any solution?
In my case - it wasn't solved. My suggestion - consider to use https://neo4j.com/docs/cypher-manual/current/constraints/ in addition to neosemantic OR/AND implement restrictions on a "higher" level of application.