use of org.kie.workbench.common.stunner.core.graph.util.ParentsTypeMatcher in project kie-wb-common by kiegroup.
the class ConnectorParentsMatchConnectionHandler method evaluateConnection.
private RuleViolations evaluateConnection(final RuleExtension rule, final GraphConnectionContext context) {
LOGGER.log(Level.INFO, "Evaluating rule handler [" + getClass().getName() + "]...");
final Optional<Node<? extends View<?>, ? extends Edge>> sourceNode = context.getSource();
final Optional<Node<? extends View<?>, ? extends Edge>> targetNode = context.getTarget();
final Class<?>[] typeArguments = rule.getTypeArguments();
final Class<?> parentType = null != typeArguments ? typeArguments[0] : null;
final DefaultRuleViolations result = new DefaultRuleViolations();
boolean isValid = true;
if (sourceNode.isPresent() && targetNode.isPresent()) {
isValid = new ParentsTypeMatcher(definitionManager).forParentType(parentType).test(sourceNode.get(), targetNode.get());
}
if (!isValid) {
addViolation(context.getConnector().getUUID(), rule, result);
}
return result;
}
Aggregations