private void populateConstraintReportIndividual() { Constraints constraints = this.report.getConstraints(); LOGGER.debug("Populating constraints: {}",constraints); reportInd().addValue(vocabularyTerm(RDF.TYPE), externalIndividual(ldp4jTerm("ConstraintReport"))); reportInd().addValue(ldp4jTerm("failureId"), literal(this.report.id().failureId())); reportInd().addValue(ldp4jTerm("failureDate"), literal(this.report.getDate())); reportInd().addValue(ldp4jTerm("failureRequest"), requestInd()); IndividualTranslator translator = new IndividualTranslator(); ShapeIndividualCache shapeCache=new ShapeIndividualCache(); Queue<Shape> pendingShapes=Lists.newLinkedList(constraints.shapes()); while(!pendingShapes.isEmpty()) { Shape shape=pendingShapes.poll(); if(!shapeCache.isPopulated(shape)) { shapeCache.populate(shape); Set<Shape> foundShapes = populateShapeDefinition(shape, shapeCache, translator); pendingShapes.addAll(foundShapes); } } for(URI type:constraints.types()) { Individual<?,?> typeInd=externalIndividual(type); typeInd.addValue(shaclTerm("typeShape"), shapeCache.individual(constraints.typeShape(type))); } for(Individual<?, ?> node:constraints.nodes(dataset)) { Individual<?, ?> individual = translator.translate(node); individual.addValue(shaclTerm("nodeShape"), shapeCache.individual(constraints.nodeShape(node))); } }
private Set<Shape> populateShapeDefinition(Shape shape, ShapeIndividualCache cache, IndividualTranslator translator) { LocalIndividual shapeInd = cache.individual(shape); String shapeId = cache.id(shape); reportInd().addValue(ldp4jTerm("hasShape"), shapeInd); shapeInd.addValue(vocabularyTerm(RDF.TYPE), externalIndividual(shaclTerm("Shape"))); Shape valueShape = pc.valueShape(); if(valueShape!=null) { populateValueShape(pcInd,cache.individual(valueShape)); shapes.add(valueShape); Shape valueShape = ipc.valueShape(); if(valueShape!=null) { populateValueShape(ipcInd,cache.individual(valueShape)); shapes.add(valueShape);
public void populate(Shape shape) { getOrCreate(shape).populate(); }
public boolean isPopulated(Shape shape) { return getOrCreate(shape).isPopulated(); }
String id(Shape shape) { return getOrCreate(shape).id(); }
LocalIndividual individual(Shape shape) { return getOrCreate(shape).individual(); }