Search in sources :

Example 1 with ElementViolation

use of org.kie.workbench.common.stunner.core.validation.ElementViolation in project kie-wb-common by kiegroup.

the class CanvasDiagramValidator method checkViolations.

@SuppressWarnings("unchecked")
private void checkViolations(final H canvasHandler, final Collection<DiagramElementViolation<RuleViolation>> elementViolations) {
    final String uuid = canvasHandler.getUuid();
    final Diagram diagram = canvasHandler.getDiagram();
    final String name = diagram.getName();
    final String title = diagram.getMetadata().getTitle();
    final Stream<ElementViolation> violationsStream = getElementViolationsStream(elementViolations);
    final List<ElementViolation> violationsList = violationsStream.collect(Collectors.toList());
    final boolean valid = violationsList.stream().noneMatch(v -> applyViolation(canvasHandler, v));
    if (valid) {
        validationSuccessEvent.fire(new CanvasValidationSuccessEvent(uuid, name, title));
    } else {
        validationFailEvent.fire(new CanvasValidationFailEvent(uuid, name, title, elementViolations));
    }
}
Also used : ElementViolation(org.kie.workbench.common.stunner.core.validation.ElementViolation) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Aggregations

Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)1 DiagramElementViolation (org.kie.workbench.common.stunner.core.validation.DiagramElementViolation)1 ElementViolation (org.kie.workbench.common.stunner.core.validation.ElementViolation)1