@SuppressWarnings("unchecked") public Node<? extends View<?>, Edge> getTargetNode(final GraphCommandExecutionContext context) { if (null == targetNode) { targetNode = getEdge(context).getTargetNode(); } return targetNode; }
@SuppressWarnings("unchecked") private void buildChildEdge(Node parentNode) { final List<Node> nodes = (List<Node>) parentNode.getOutEdges().stream() .map(e -> ((Edge) e).getTargetNode()).collect(Collectors.toList()); for (int i = 0, n = nodes.size() - 1; i < n; i++) { createEdge(UUID.uuid(), nodes.get(i), nodes.get(i + 1)); } }
@SuppressWarnings("unchecked") private void deleteChild(Node parent, Node child) { parent.getOutEdges().stream().filter(edge -> child.equals(((Edge) edge).getTargetNode())) .findAny().ifPresent(edge -> { parent.getOutEdges().remove(edge); child.getInEdges().remove(edge); }); }
private void updateConnectionEdges(AbstractCanvasHandler context, Node<? extends Definition<?>, Edge> candidate) { // Update incoming edges for the new shape Optional.ofNullable(candidate.getInEdges()) .ifPresent(edges -> edges.stream() .filter(this::isViewEdge) .forEach(edge -> updateConnections(context, edge, edge.getSourceNode(), candidate))); // Update outgoing edges for the new shape. Optional.ofNullable(candidate.getOutEdges()) .ifPresent(edges -> edges.stream() .filter(this::isViewEdge) .forEach(edge -> updateConnections(context, edge, candidate, edge.getTargetNode()))); }
private static boolean isNotCyclicEdge(final Edge edge) { final String sourceId = edge.getSourceNode() != null ? edge.getSourceNode().getUUID() : null; final String targetId = edge.getTargetNode() != null ? edge.getTargetNode().getUUID() : null; return !Objects.equals(sourceId, targetId); } }
@SuppressWarnings("unchecked") private void startEdgeTraversal(final Edge edge) { final String uuid = edge.getUUID(); if (!this.processesEdges.contains(uuid)) { processesEdges.add(uuid); if (callback.startEdgeTraversal(edge)) { ifNotProcessed(edge.getTargetNode(), () -> startNodeTraversal(edge.getTargetNode())); } endEdgeTraversal(edge); } }
@SuppressWarnings("unchecked") public SetConnectionSourceNodeCommand(final Node<? extends View<?>, Edge> sourceNode, final Edge<? extends View, Node> edge, final Connection connection) { this(null != sourceNode ? sourceNode.getUUID() : null, edge.getUUID(), connection); this.sourceNode = sourceNode; this.edge = edge; this.targetNode = edge.getTargetNode(); }
@SuppressWarnings("unchecked") private static boolean isTargetChanged(final Node node, final Edge<ViewConnector<?>, Node> connector, final Connection connection) { final ViewConnector vc = connector.getContent(); return (!eq(node, connector.getTargetNode(), connection, null != vc ? vc.getTargetConnection() : Optional.empty())); }
@Override public String toString() { return getClass().getName() + " [candidate=" + getUUID(candidate) + "," + " sourceNode=" + getUUID(candidate.getSourceNode()) + "," + " targetNode=" + getUUID(candidate.getTargetNode()) + "]"; } }
@Override public String toString() { return getClass().getName() + " [candidate=" + getUUID(edge) + "," + " sourceNode=" + getUUID(edge.getSourceNode()) + "," + " targetNode=" + getUUID(edge.getTargetNode()) + "]"; } }
protected BPMNDefinition getEdgeTarget(Edge edge) { Node targetNode = edge.getTargetNode(); if (targetNode != null && targetNode.getContent() instanceof View) { Object definition = ((View) targetNode.getContent()).getDefinition(); if (definition instanceof BPMNDefinition) { return (BPMNDefinition) definition; } } return null; } }
@SuppressWarnings("unchecked") private void initializeTheChildNode() { Child edgeContent = mock(Child.class); when(edge.getContent()).thenReturn(edgeContent); when(edge.getSourceNode()).thenReturn(node); when(edge.getTargetNode()).thenReturn(node1); nodeOutEdges.add(edge); nodeInEdges1.add(edge); } }
private <T extends BPMNViewDefinition> Edge mockEdge(Node<View<T>, ?> sourceNode, Node<View<T>, ?> targetNode) { Edge edge = mock(Edge.class); when(edge.getContent()).thenReturn(mock(Child.class)); when(edge.getSourceNode()).thenReturn(sourceNode); when(edge.getTargetNode()).thenReturn(targetNode); return edge; }
private void shortcut(final Edge<? extends ViewConnector<?>, Node> in, final Edge<? extends ViewConnector<?>, Node> out) { final ViewConnector<?> outContent = out.getContent(); final Node targetNode = out.getTargetNode(); addCommand(new DeleteConnectorCommand(out)); safeDeleteCallback.ifPresent(c -> c.deleteCandidateConnector(out)); addCommand(new SetConnectionTargetNodeCommand(targetNode, in, outContent.getTargetConnection().orElse(null))); safeDeleteCallback.ifPresent(c -> c.setEdgeTargetNode(targetNode, in)); }
@Test public void checkGetChildIndex() { final Edge edge = mock(Edge.class); when(edge.getTargetNode()).thenReturn(child); when(parent.getOutEdges()).thenReturn(Collections.singletonList(edge)); assertEquals(0, CaseManagementCanvasCommandFactory.getChildIndex(parent, child)); } }
@Before public void setUp() { super.setup(); final Edge edge = mock(Edge.class); when(edge.getTargetNode()).thenReturn(candidate); parent.getOutEdges().add(edge); tested = new CaseManagementRemoveChildCommand(parent, candidate); }
@Override public void startChildEdgeTraversal(final Edge<Object, Node> edge) { log("(Child= Edge UUID: " + edge.getUUID()); final Node outNode = edge.getTargetNode(); if (outNode == null) { log(indent + " No outgoing node found"); } else { log(indent + " Outgoing Node"); log(indent + " =============="); } }
@Test @SuppressWarnings("unchecked") public void testSkipRulesForSameTargetNodeAsBefore() { when(edge.getTargetNode()).thenReturn(node); CommandResult<RuleViolation> result = tested.allow(graphCommandExecutionContext); assertEquals(CommandResult.Type.INFO, result.getType()); verify(ruleManager, times(0)).evaluate(eq(ruleSet), any(RuleEvaluationContext.class)); }
public static void log(final Edge<?, Node> edge) { log("Edge UUID: " + edge.getUUID()); final Object content = edge.getContent(); log(" Edge Content: " + content.getClass().getName()); final Node inNode = edge.getSourceNode(); final Node outNode = edge.getTargetNode(); log(" Edge In Node: " + (null != inNode ? inNode.getUUID() : "null")); log(" Edge Out Node: " + (null != outNode ? outNode.getUUID() : "null")); if (edge.getContent() instanceof ViewConnector) { log((ViewConnector) edge.getContent()); } }
@Test public void testGraphCommand() { assertCommandSuccess(command.execute(canvasHandler)); assertEquals(1, parent.getOutEdges().size()); assertEquals(candidate, parent.getOutEdges().get(index).getTargetNode()); assertEquals(1, candidate.getInEdges().size()); assertEquals(parent, candidate.getInEdges().get(0).getSourceNode()); }