use of org.kie.workbench.common.stunner.core.rule.context.GraphConnectionContext in project kie-wb-common by kiegroup.
the class GraphConnectionEvaluationHandler method evaluate.
@Override
public RuleViolations evaluate(final CanConnect rule, final GraphConnectionContext context) {
final Edge<? extends View<?>, ? extends Node> connector = context.getConnector();
final Node<? extends View<?>, ? extends Edge> source = context.getSource().orElse(null);
final Node<? extends View<?>, ? extends Edge> target = context.getTarget().orElse(null);
if (source == null || target == null) {
return new DefaultRuleViolations();
}
final Set<String> edgeLabels = evalUtils.getLabels(connector);
final Optional<Set<String>> sourceLabels = Optional.of(evalUtils.getLabels(source));
final Optional<Set<String>> targetLabels = Optional.of(evalUtils.getLabels(target));
final DefaultRuleViolations result = new DefaultRuleViolations();
edgeLabels.stream().filter(pr -> rule.getRole().equals(pr)).forEach(pr -> result.addViolations(connectionEvaluationHandler.evaluate(rule, RuleContextBuilder.DomainContexts.connection(pr, sourceLabels, targetLabels))));
return GraphEvaluationHandlerUtils.addViolationsSourceUUID(connector.getUUID(), result);
}
Aggregations