use of org.apache.jena.shacl.engine.ValidationContext in project webofneeds by researchstudio-sat.
the class AuthShapeTest method assertConformsTo.
private void assertConformsTo(Node focusNode, Node shapeNode, Shapes shapes, Graph data, boolean expected) {
data = new Union(data, shapes.getGraph());
ResettableErrorHandler handler = new ResettableErrorHandler();
Shape shape = shapes.getShape(shapeNode);
if (shape == null) {
throw new IllegalArgumentException("no such shape: " + shapeNode);
}
boolean isFocusNode = VLib.isFocusNode(shape, focusNode, data);
if (expected && !isFocusNode) {
Assert.fail(String.format("%s should be focus node of %s", focusNode, shape));
}
if (!expected && isFocusNode) {
Assert.fail(String.format("%s should not be focus node of %s", focusNode, shape));
}
if (isFocusNode) {
ValidationContext vCtx = ValidationContext.create(shapes, shapes.getGraph(), handler);
VLib.validateShape(vCtx, data, shapes.getShape(shapeNode), focusNode);
if (vCtx.hasViolation()) {
ValidationReport report = vCtx.generateReport();
printNonconformingReport(report);
Assert.fail(String.format("Data does not conform to shapes"));
}
if (handler.isError() || handler.isFatal()) {
Assert.fail(String.format("Node %s %s to shape %s", focusNode, expected ? "does not conform" : "unexpectedly conforms", shapeNode));
}
}
}
use of org.apache.jena.shacl.engine.ValidationContext in project jena by apache.
the class QualifiedValueShape method conforms.
private static boolean conforms(ValidationContext vCxt, Shape shape, Node v) {
ValidationContext vCxt2 = ValidationContext.create(vCxt);
ValidationProc.execValidateShape(vCxt2, vCxt.getDataGraph(), shape, v);
ValidationReport report = vCxt2.generateReport();
return report.conforms();
}
use of org.apache.jena.shacl.engine.ValidationContext in project jena by apache.
the class ShNode method validate.
@Override
public ReportItem validate(ValidationContext vCxt, Graph data, Node node) {
ValidationContext vCxt2 = ValidationContext.create(vCxt);
ValidationProc.execValidateShape(vCxt2, data, other, node);
boolean innerConforms = vCxt2.generateReport().conforms();
if (innerConforms)
return null;
String msg = toString() + " at focusNode " + displayStr(node);
return new ReportItem(msg, node);
}
use of org.apache.jena.shacl.engine.ValidationContext in project jena by apache.
the class ShOr method validate.
@Override
public ReportItem validate(ValidationContext vCxt, Graph data, Node node) {
for (Shape sh : others) {
ValidationContext vCxt2 = ValidationContext.create(vCxt);
ValidationProc.execValidateShape(vCxt2, data, sh, node);
boolean innerConforms = vCxt2.generateReport().conforms();
if (innerConforms)
return null;
}
String msg = toString() + " at focusNode " + displayStr(node);
return new ReportItem(msg, node);
}
use of org.apache.jena.shacl.engine.ValidationContext in project jena by apache.
the class ShAnd method validate.
@Override
public ReportItem validate(ValidationContext vCxt, Graph data, Node node) {
for (Shape sh : others) {
ValidationContext vCxt2 = ValidationContext.create(vCxt);
ValidationProc.execValidateShape(vCxt2, data, sh, node);
boolean innerConforms = vCxt2.generateReport().conforms();
if (!innerConforms) {
String msg = toString() + " at focusNode " + displayStr(node);
return new ReportItem(msg, node);
}
}
return null;
}
Aggregations