private Predicate<Edge> isDifferentParent() { return e -> e.getContent() instanceof Child && !parent.equals(e.getSourceNode()); }
@SuppressWarnings("unchecked") private Node<? extends View<?>, Edge> getSourceNode(final GraphCommandExecutionContext context) { if (null == sourceNode) { sourceNode = (Node<? extends View<?>, Edge>) getEdge(context).getSourceNode(); } return sourceNode; }
private Map<String, Node> findEdgesBydId(String nodeId) { Map<String, Node> nodes = new HashMap<>(); childEdges() .filter(e -> e.getSourceNode().getUUID().equals(nodeId)) .map(Edge::getTargetNode) .forEach(n -> nodes.put(n.getUUID(), n)); // use forEach instead of collect to avoid issues with type inference return nodes; }
private static boolean isCompensationTarget(final Node<?, ? extends Edge> node) { return node.getInEdges().stream() .filter(edge -> edge.getSourceNode().getContent() instanceof View && ((View) edge.getSourceNode().getContent()).getDefinition() instanceof IntermediateCompensationEvent) .findFirst() .isPresent(); }
@SuppressWarnings("unchecked") private static Node getParent(final Node node) { List<Edge> inEdges = node.getInEdges(); if (null != inEdges && !inEdges.isEmpty()) { for (final Edge edge : inEdges) { if (edge.getContent() instanceof Child) { return edge.getSourceNode(); } } } return null; }
@SuppressWarnings("unchecked") private Node<View, Edge> getDockSourceNode(final Node<View, Edge> node) { List<Edge> inEdges = node.getInEdges(); if (null != inEdges && !inEdges.isEmpty()) { for (Edge edge : inEdges) { if (isDockEdge(edge)) { return edge.getSourceNode(); } } } return null; }
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); } }
private Optional<Node> getParent() { List<Edge> inEdges = candidate.getInEdges(); if (null != inEdges && !inEdges.isEmpty()) { for (final Edge edge : inEdges) { if (isChildEdge(edge) || isDockEdge(edge)) { return Optional.ofNullable(edge.getSourceNode()); } } } return Optional.empty(); }
@SuppressWarnings("unchecked") public static Node getParent(final Node node) { List<Edge> inEdges = null != node ? node.getInEdges() : null; if (null != inEdges && !inEdges.isEmpty()) { for (final Edge edge : inEdges) { if (isChildEdge(edge) || isDockEdge(edge)) { return edge.getSourceNode(); } } } return null; }
@SuppressWarnings("unchecked") private static boolean isSourceChanged(final Node node, final Edge<ViewConnector<?>, Node> connector, final Connection connection) { final ViewConnector vc = connector.getContent(); return (!eq(node, connector.getSourceNode(), connection, null != vc ? vc.getSourceConnection() : 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()) + "]"; } }
@SuppressWarnings("unchecked") public SetConnectionTargetNodeCommand(final Node<? extends View<?>, Edge> targetNode, final Edge<? extends View, Node> edge, final Connection connection) { this(null != targetNode ? targetNode.getUUID() : null, edge.getUUID(), connection); this.edge = PortablePreconditions.checkNotNull("edge", edge); this.sourceNode = edge.getSourceNode(); this.targetNode = targetNode; }
@Override @SuppressWarnings("unchecked") protected boolean doStartEdgeTraversal(final Edge edge, final ChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>> callback) { if (accepts(edge)) { final Node<View, Edge> parent = edge.getSourceNode(); parentStack.push(parent); callback.startEdgeTraversal(edge); return true; } return false; }
@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; }
@Test @SuppressWarnings("unchecked") public void testSkipRulesForSameSourceNodeAsBefore() { when(edge.getSourceNode()).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()); }