use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge in project kie-wb-common by kiegroup.
the class NodeConnector method connectEdgeToNodes.
void connectEdgeToNodes(final String connectorTypeId, final JSITDMNElement jsiDMNElement, final JSITDMNElementReference jsiDMNElementReference, final Map<String, List<NodeEntry>> entriesById, final String diagramId, final List<JSIDMNEdge> edges, final boolean isDMNDIPresent, final Node currentNode) {
final String reqInputID = getId(jsiDMNElementReference);
final List<NodeEntry> nodeEntries = entriesById.get(reqInputID);
if (nodeEntries == null || nodeEntries.isEmpty()) {
return;
}
final Optional<JSIDMNEdge> existingEdge = findExistingEdge(jsiDMNElement, edges);
if (!isDMNDIPresent) {
// Generate new a edge and connect it
final NodeEntry nodeEntry = nodeEntries.get(0);
final Node requiredNode = nodeEntry.getNode();
final View<?> view = (View<?>) requiredNode.getContent();
final double viewWidth = view.getBounds().getWidth();
final double viewHeight = view.getBounds().getHeight();
connectWbEdge(connectorTypeId, diagramId, currentNode, requiredNode, newEdge(viewWidth / 2, viewHeight / 2), uuid());
} else if (existingEdge.isPresent()) {
// Connect existing edge
final JSIDMNEdge edge = Js.uncheckedCast(existingEdge.get());
final Optional<Node> requiredNode = getSourceNode(edge, nodeEntries);
final String id = edge.getDmnElementRef().getLocalPart();
final String currentNodeId = ((DRGElement) ((Definition) currentNode.getContent()).getDefinition()).getContentDefinitionId();
// The edge can be connected with another instance of the same Node and not the currentNode
if (isEdgeConnectedWithNode(edge, currentNode, entriesById.get(currentNodeId))) {
connectWbEdge(connectorTypeId, diagramId, currentNode, requiredNode.get(), edge, id);
}
}
}
Aggregations