Search in sources :

Example 1 with NodeContainmentContext

use of org.kie.workbench.common.stunner.core.rule.context.NodeContainmentContext in project kie-wb-common by kiegroup.

the class CanvasLayoutUtils method canContain.

private boolean canContain(final CanvasHandler canvasHandler, final Node container, final Node candidate) {
    boolean canContain = true;
    NodeContainmentContext containmentContext = RuleContextBuilder.GraphContexts.containment(canvasHandler.getDiagram().getGraph(), container, candidate);
    String definitionSetId = canvasHandler.getDiagram().getMetadata().getDefinitionSetId();
    Object definitionSet = definitionManager.definitionSets().getDefinitionSetById(definitionSetId);
    RuleSet ruleSet = definitionManager.adapters().forRules().getRuleSet(definitionSet);
    RuleViolations violations = ruleManager.evaluate(ruleSet, containmentContext);
    if (violations.violations(Violation.Type.ERROR).iterator().hasNext()) {
        canContain = false;
    }
    return canContain;
}
Also used : RuleSet(org.kie.workbench.common.stunner.core.rule.RuleSet) NodeContainmentContext(org.kie.workbench.common.stunner.core.rule.context.NodeContainmentContext) RuleViolations(org.kie.workbench.common.stunner.core.rule.RuleViolations)

Aggregations

RuleSet (org.kie.workbench.common.stunner.core.rule.RuleSet)1 RuleViolations (org.kie.workbench.common.stunner.core.rule.RuleViolations)1 NodeContainmentContext (org.kie.workbench.common.stunner.core.rule.context.NodeContainmentContext)1