use of org.kie.workbench.common.stunner.core.rule.violations.ConnectionRuleViolation in project kie-wb-common by kiegroup.
the class ConnectionEvaluationHandler method evaluate.
@Override
public RuleViolations evaluate(final CanConnect rule, final ConnectionContext context) {
final List<CanConnect.PermittedConnection> permittedConnections = rule.getPermittedConnections();
final String currentConnectorRole = context.getConnectorRole();
final Set<String> incomingLabels = context.getTargetRoles().orElse(Collections.emptySet());
final Set<String> outgoingLabels = context.getSourceRoles().orElse(Collections.emptySet());
final DefaultRuleViolations results = new DefaultRuleViolations();
final Set<Pair<String, String>> couples = new LinkedHashSet<>();
for (CanConnect.PermittedConnection pc : permittedConnections) {
final boolean startMatch = outgoingLabels.contains(pc.getStartRole());
final boolean endMatch = startMatch && incomingLabels.contains(pc.getEndRole());
if (endMatch) {
return results;
}
couples.add(new Pair<>(pc.getStartRole(), pc.getEndRole()));
}
results.addViolation(new ConnectionRuleViolation(currentConnectorRole, serializeAllowedConnections(couples)));
return results;
}
Aggregations