Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
eclipse-rdf4j/rdf4j#1488 initial support for sh:xone
Browse files Browse the repository at this point in the history
Signed-off-by: Håvard Ottestad <[email protected]>
  • Loading branch information
hmottestad committed Aug 9, 2019
1 parent b4ecc21 commit 2010c42
Show file tree
Hide file tree
Showing 31 changed files with 785 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ static List<PathPropertyShape> getPropertyShapesInner(SailRepositoryConnection c
shaclProperties.deactivated, parent, shaclProperties.path, or));
});
}
if (!shaclProperties.xone.isEmpty()) {
shaclProperties.xone.forEach(xone -> {
propertyShapes.add(new XonePropertyShape(propertyShapeId, connection, nodeShape,
shaclProperties.deactivated, parent, shaclProperties.path, xone));
});
}
if (shaclProperties.minLength != null) {
propertyShapes.add(new MinLengthPropertyShape(propertyShapeId, connection, nodeShape,
shaclProperties.deactivated, parent, shaclProperties.path, shaclProperties.minLength));
Expand Down
244 changes: 124 additions & 120 deletions shacl/src/main/java/org/eclipse/rdf4j/sail/shacl/AST/ShaclProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ShaclProperties {
List<Resource> or = new ArrayList<>(0);
List<Resource> and = new ArrayList<>(0);
List<Resource> not = new ArrayList<>(0);
List<Resource> xone = new ArrayList<>(0);
Long minCount;
Long maxCount;

Expand Down Expand Up @@ -62,128 +63,131 @@ public ShaclProperties(Resource propertyShapeId, SailRepositoryConnection connec
String predicate = statement.getPredicate().toString();
Value object = statement.getObject();
switch (predicate) {
case "http://www.w3.org/ns/shacl#or":
or.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#and":
and.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#not":
not.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#languageIn":
if (languageIn != null) {
throw new IllegalStateException(predicate + " already populated");
}
languageIn = (Resource) object;
break;
case "http://www.w3.org/ns/shacl#nodeKind":
if (nodeKind != null) {
throw new IllegalStateException(predicate + " already populated");
}
nodeKind = (Resource) object;
break;
case "http://www.w3.org/ns/shacl#datatype":
if (datatype != null) {
throw new IllegalStateException(predicate + " already populated");
}
datatype = (Resource) object;
break;
case "http://www.w3.org/ns/shacl#minCount":
if (minCount != null) {
throw new IllegalStateException(predicate + " already populated");
}
minCount = ((Literal) object).longValue();
break;
case "http://www.w3.org/ns/shacl#maxCount":
if (maxCount != null) {
throw new IllegalStateException(predicate + " already populated");
}
maxCount = ((Literal) object).longValue();
break;
case "http://www.w3.org/ns/shacl#minLength":
if (minLength != null) {
throw new IllegalStateException(predicate + " already populated");
}
minLength = ((Literal) object).longValue();
break;
case "http://www.w3.org/ns/shacl#maxLength":
if (maxLength != null) {
throw new IllegalStateException(predicate + " already populated");
}
maxLength = ((Literal) object).longValue();
break;
case "http://www.w3.org/ns/shacl#minExclusive":
if (minExclusive != null) {
throw new IllegalStateException(predicate + " already populated");
}
minExclusive = (Literal) object;
break;
case "http://www.w3.org/ns/shacl#maxExclusive":
if (maxExclusive != null) {
throw new IllegalStateException(predicate + " already populated");
}
maxExclusive = (Literal) object;
break;
case "http://www.w3.org/ns/shacl#minInclusive":
if (minInclusive != null) {
throw new IllegalStateException(predicate + " already populated");
}
minInclusive = (Literal) object;
break;
case "http://www.w3.org/ns/shacl#maxInclusive":
if (maxInclusive != null) {
throw new IllegalStateException(predicate + " already populated");
}
maxInclusive = (Literal) object;
break;
case "http://www.w3.org/ns/shacl#pattern":
pattern.add(object.stringValue());
break;
case "http://www.w3.org/ns/shacl#class":
clazz.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#targetNode":
targetNode.add(object);
break;
case "http://www.w3.org/ns/shacl#targetClass":
targetClass.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#targetSubjectsOf":
targetSubjectsOf.add((IRI) object);
break;
case "http://www.w3.org/ns/shacl#targetObjectsOf":
targetObjectsOf.add((IRI) object);
break;
case "http://www.w3.org/ns/shacl#deactivated":
deactivated = ((Literal) object).booleanValue();
break;
case "http://www.w3.org/ns/shacl#uniqueLang":
uniqueLang = ((Literal) object).booleanValue();
break;
case "http://www.w3.org/ns/shacl#flags":
flags += object.stringValue();
break;
case "http://www.w3.org/ns/shacl#path":
if (path != null) {
throw new IllegalStateException(predicate + " already populated");
}
path = (Resource) object;
break;
case "http://www.w3.org/ns/shacl#in":
if (in != null) {
throw new IllegalStateException(predicate + " already populated");
}
in = (Resource) object;
break;
case "http://www.w3.org/ns/shacl#property":
break;
default:
if (predicate.startsWith("http://www.w3.org/ns/shacl#")) {
logger.debug("Unsupported SHACL feature detected {} in statement {}",
case "http://www.w3.org/ns/shacl#or":
or.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#and":
and.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#not":
not.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#xone":
xone.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#languageIn":
if (languageIn != null) {
throw new IllegalStateException(predicate + " already populated");
}
languageIn = (Resource) object;
break;
case "http://www.w3.org/ns/shacl#nodeKind":
if (nodeKind != null) {
throw new IllegalStateException(predicate + " already populated");
}
nodeKind = (Resource) object;
break;
case "http://www.w3.org/ns/shacl#datatype":
if (datatype != null) {
throw new IllegalStateException(predicate + " already populated");
}
datatype = (Resource) object;
break;
case "http://www.w3.org/ns/shacl#minCount":
if (minCount != null) {
throw new IllegalStateException(predicate + " already populated");
}
minCount = ((Literal) object).longValue();
break;
case "http://www.w3.org/ns/shacl#maxCount":
if (maxCount != null) {
throw new IllegalStateException(predicate + " already populated");
}
maxCount = ((Literal) object).longValue();
break;
case "http://www.w3.org/ns/shacl#minLength":
if (minLength != null) {
throw new IllegalStateException(predicate + " already populated");
}
minLength = ((Literal) object).longValue();
break;
case "http://www.w3.org/ns/shacl#maxLength":
if (maxLength != null) {
throw new IllegalStateException(predicate + " already populated");
}
maxLength = ((Literal) object).longValue();
break;
case "http://www.w3.org/ns/shacl#minExclusive":
if (minExclusive != null) {
throw new IllegalStateException(predicate + " already populated");
}
minExclusive = (Literal) object;
break;
case "http://www.w3.org/ns/shacl#maxExclusive":
if (maxExclusive != null) {
throw new IllegalStateException(predicate + " already populated");
}
maxExclusive = (Literal) object;
break;
case "http://www.w3.org/ns/shacl#minInclusive":
if (minInclusive != null) {
throw new IllegalStateException(predicate + " already populated");
}
minInclusive = (Literal) object;
break;
case "http://www.w3.org/ns/shacl#maxInclusive":
if (maxInclusive != null) {
throw new IllegalStateException(predicate + " already populated");
}
maxInclusive = (Literal) object;
break;
case "http://www.w3.org/ns/shacl#pattern":
pattern.add(object.stringValue());
break;
case "http://www.w3.org/ns/shacl#class":
clazz.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#targetNode":
targetNode.add(object);
break;
case "http://www.w3.org/ns/shacl#targetClass":
targetClass.add((Resource) object);
break;
case "http://www.w3.org/ns/shacl#targetSubjectsOf":
targetSubjectsOf.add((IRI) object);
break;
case "http://www.w3.org/ns/shacl#targetObjectsOf":
targetObjectsOf.add((IRI) object);
break;
case "http://www.w3.org/ns/shacl#deactivated":
deactivated = ((Literal) object).booleanValue();
break;
case "http://www.w3.org/ns/shacl#uniqueLang":
uniqueLang = ((Literal) object).booleanValue();
break;
case "http://www.w3.org/ns/shacl#flags":
flags += object.stringValue();
break;
case "http://www.w3.org/ns/shacl#path":
if (path != null) {
throw new IllegalStateException(predicate + " already populated");
}
path = (Resource) object;
break;
case "http://www.w3.org/ns/shacl#in":
if (in != null) {
throw new IllegalStateException(predicate + " already populated");
}
in = (Resource) object;
break;
case "http://www.w3.org/ns/shacl#property":
break;
default:
if (predicate.startsWith("http://www.w3.org/ns/shacl#")) {
logger.debug("Unsupported SHACL feature detected {} in statement {}",
predicate.replace("http://www.w3.org/ns/shacl#", "sh:"),
statement);
}
}
}

});
Expand Down
Loading

0 comments on commit 2010c42

Please sign in to comment.