Search in sources :

Example 1 with Severity

use of org.apache.jena.shacl.validation.Severity in project jena by apache.

the class ShapesParser method parseShape$.

private static Shape parseShape$(Set<Node> traversed, Map<Node, Shape> parsed, Graph shapesGraph, Node shapeNode) {
    if (DEBUG)
        OUT.printf("Parse shape : %s\n", displayStr(shapeNode));
    boolean isDeactivated = contains(shapesGraph, shapeNode, SHACL.deactivated, NodeConst.nodeTrue);
    Collection<Target> targets = targets(shapesGraph, shapeNode);
    List<Constraint> constraints = Constraints.parseConstraints(shapesGraph, shapeNode, parsed, traversed);
    Severity severity = severity(shapesGraph, shapeNode);
    List<Node> messages = listSP(shapesGraph, shapeNode, SHACL.message);
    if (DEBUG)
        OUT.incIndent();
    // sh:Property PropertyShapes from this shape.
    // sh:node is treated as a constraint.
    List<PropertyShape> propertyShapes = findPropertyShapes(traversed, parsed, shapesGraph, shapeNode);
    if (DEBUG)
        OUT.decIndent();
    boolean isPropertyShape = contains(shapesGraph, shapeNode, SHACL.path, Node.ANY);
    if (!isPropertyShape) {
        if (DEBUG)
            OUT.printf("Node shape %s\n", displayStr(shapeNode));
        return new NodeShape(shapesGraph, shapeNode, isDeactivated, severity, messages, targets, constraints, propertyShapes);
    }
    if (DEBUG)
        OUT.incIndent();
    Node pathNode = getOneSP(shapesGraph, shapeNode, SHACL.path);
    Path path = parsePath(shapesGraph, pathNode);
    if (DEBUG)
        OUT.printf("Property shape: path = %s\n", pathToString(shapesGraph, path));
    // 2.3.2 Non-Validating Property Shape Characteristics
    // 2.3.2.1 sh:name and sh:description
    // 2.3.2.2 sh:order
    // 2.3.2.3 sh:group
    // 2.3.2.4 sh:defaultValue
    // sh:order and sh:defaultValue - unique.
    List<Node> names = listSP(shapesGraph, shapeNode, SHACL.name);
    List<Node> descriptions = listSP(shapesGraph, shapeNode, SHACL.description);
    List<Node> groups = listSP(shapesGraph, shapeNode, SHACL.group);
    Node defaultValue = G.getZeroOrOneSP(shapesGraph, shapeNode, SHACL.defaultValue);
    // The values of sh:order are decimals. "maybe used on any type of subject" but section is "property shapes".
    // We allow more than decimals.
    Node order = G.getZeroOrOneSP(shapesGraph, shapeNode, SHACL.order);
    if (order != null && !isDecimalCompatible(order))
        throw new ShaclParseException("Not an xsd:decimal for sh:order");
    if (DEBUG) {
        OUT.printf("Property shape %s\n", displayStr(shapeNode));
        OUT.decIndent();
    }
    return new PropertyShape(shapesGraph, shapeNode, isDeactivated, severity, messages, targets, path, constraints, propertyShapes);
}
Also used : Path(org.apache.jena.sparql.path.Path) JLogConstraint(org.apache.jena.shacl.engine.constraint.JLogConstraint) Node(org.apache.jena.graph.Node) Severity(org.apache.jena.shacl.validation.Severity) Target(org.apache.jena.shacl.engine.Target)

Aggregations

Node (org.apache.jena.graph.Node)1 Target (org.apache.jena.shacl.engine.Target)1 JLogConstraint (org.apache.jena.shacl.engine.constraint.JLogConstraint)1 Severity (org.apache.jena.shacl.validation.Severity)1 Path (org.apache.jena.sparql.path.Path)1