@SuppressWarnings("unchecked") private void removeDockEdge(final GraphCommandExecutionContext context, final Node<?, Edge> parent, final Node<?, Edge> candidate, final Edge edge) { edge.setSourceNode(null); edge.setTargetNode(null); parent.getOutEdges().remove(edge); candidate.getInEdges().remove(edge); getMutableIndex(context).removeEdge(edge); }
@SuppressWarnings("unchecked") private void removeRelationship(final Edge e, final Node parent, final Node child, final GraphCommandExecutionContext context) { e.setSourceNode(null); e.setTargetNode(null); parent.getOutEdges().remove(e); child.getInEdges().remove(e); getMutableIndex(context).removeEdge(e); }
@SuppressWarnings("unchecked") private void createChild(String uuid, Node parent, Node child, int parentIndex) { final Edge<Child, Node> edge = new EdgeImpl<>(uuid); edge.setContent(new Child()); edge.setSourceNode(parent); edge.setTargetNode(child); if (parentIndex >= 0) { parent.getOutEdges().add(parentIndex, edge); } else { parent.getOutEdges().add(edge); } child.getInEdges().add(edge); }
@SuppressWarnings("unchecked") private void connectNodes(final Node source, final Node target, final Edge connector) { source.getOutEdges().add(connector); target.getInEdges().add(connector); connector.setSourceNode(source); connector.setTargetNode(target); } }
@SuppressWarnings("unchecked") private void createEdge(String uuid, Node sourceNode, Node targetNode) { final Edge<View<SequenceFlow>, Node> edge = typedFactoryManager.newEdge(uuid, SequenceFlow.class); edge.setSourceNode(sourceNode); edge.setTargetNode(targetNode); sourceNode.getOutEdges().add(edge); targetNode.getInEdges().add(edge); ViewConnector<SequenceFlow> content = (ViewConnector<SequenceFlow>) edge.getContent(); content.setSourceConnection(MagnetConnection.Builder.forElement(sourceNode)); content.setTargetConnection(MagnetConnection.Builder.forElement(targetNode)); }
@SuppressWarnings("unchecked") private void addRelationship(final Node parent, final Node child, final OptionalInt index, final GraphCommandExecutionContext context) { final String uuid = UUID.uuid(); final Edge<Child, Node> edge = new EdgeImpl<>(uuid); edge.setContent(new Child()); edge.setSourceNode(parent); edge.setTargetNode(child); parent.getOutEdges().add(index.orElseGet(() -> parent.getOutEdges().size()), edge); child.getInEdges().add(edge); getMutableIndex(context).addEdge(edge); }
@Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Edge<? extends View, Node> edge = getEdge(context); final Node<?, Edge> sourceNode = getSourceNode(context); final Node<? extends View<?>, Edge> lastSourceNode = edge.getSourceNode(); // New connection being made if (null != lastSourceNode) { this.lastSourceNodeUUID = lastSourceNode.getUUID(); lastSourceNode.getOutEdges().remove(edge); } if (null != sourceNode) { sourceNode.getOutEdges().add(edge); } edge.setSourceNode(sourceNode); // Magnet being moved on node ViewConnector connectionContent = (ViewConnector) edge.getContent(); lastConnection = (Connection) connectionContent.getSourceConnection().orElse(null); connectionContent.setSourceConnection(connection); } return results; }
@Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Node<?, Edge> parent = getParent(context); final Node<?, Edge> candidate = getCandidate(context); final Edge<Parent, Node> edge = getEdgeForTarget(parent, candidate); if (null != edge) { edge.setSourceNode(null); edge.setTargetNode(null); parent.getInEdges().remove(edge); candidate.getOutEdges().remove(edge); getMutableIndex(context).removeEdge(edge); } } return results; }
@Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Node<?, Edge> parent = getParent(context); final Node<?, Edge> candidate = getCandidate(context); final Edge<Parent, Node> edge = getEdgeForTarget(parent, candidate); if (null != edge) { edge.setSourceNode(null); edge.setTargetNode(null); parent.getOutEdges().remove(edge); candidate.getInEdges().remove(edge); getMutableIndex(context).removeEdge(edge); } } return results; }
times(1)).setSourceConnection(any(Connection.class)); verify(edge, times(1)).setSourceNode(eq(node)); verify(targetInEdges, times(0)).remove(any(Edge.class));
@Before @SuppressWarnings("unchecked") public void setup() throws Exception { super.init(); this.parent = mockNode(PARENT_UUID); this.candidate = mockNode(CANDIDATE_UUID); this.edge = new EdgeImpl<>(EDGE_UUID); this.edge.setContent(new Dock()); this.edge.setSourceNode(parent); this.edge.setTargetNode(candidate); when(graphIndex.getNode(eq(PARENT_UUID))).thenReturn(parent); when(graphIndex.getNode(eq(CANDIDATE_UUID))).thenReturn(candidate); when(graphIndex.getEdge(eq(EDGE_UUID))).thenReturn(edge); when(parent.getOutEdges()).thenReturn(parentOutEdges); when(candidate.getInEdges()).thenReturn(candidateInEdges); parentOutEdges.add(edge); candidateInEdges.add(edge); this.tested = new UnDockNodeCommand(PARENT_UUID, CANDIDATE_UUID); }
@Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Node<?, Edge> parent = getParent(context); final Node<?, Edge> candidate = getCandidate(context); final String uuid = UUID.uuid(); final Edge<Child, Node> edge = new EdgeImpl<>(uuid); edge.setContent(new Child()); edge.setSourceNode(parent); edge.setTargetNode(candidate); parent.getOutEdges().add(edge); candidate.getInEdges().add(edge); getMutableIndex(context).addEdge(edge); } return results; }
@Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Node<?, Edge> parent = getParent(context); final Node<?, Edge> candidate = getCandidate(context); final String uuid = UUID.uuid(); final Edge<Dock, Node> edge = new EdgeImpl<>(uuid); edge.setContent(new Dock()); edge.setSourceNode(parent); edge.setTargetNode(candidate); parent.getOutEdges().add(edge); candidate.getInEdges().add(edge); getMutableIndex(context).addEdge(edge); } return results; }
@Override @SuppressWarnings("unchecked") public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { final CommandResult<RuleViolation> results = allow(context); if (!results.getType().equals(CommandResult.Type.ERROR)) { final Node<?, Edge> parent = getParent(context); final Node<?, Edge> candidate = getCandidate(context); // TODO: Create a ParentEdgeFactory iface extending EdgeFactory using as content generics type Relationship final String uuid = UUID.uuid(); final Edge<Parent, Node> edge = new EdgeImpl<>(uuid); edge.setContent(new Parent()); edge.setSourceNode(parent); edge.setTargetNode(candidate); parent.getOutEdges().add(edge); candidate.getInEdges().add(edge); getMutableIndex(context).addEdge(edge); } return results; }
c1.setSourceNode(node1); c1.setTargetNode(node2);
@Override @SuppressWarnings("unchecked") public ToolboxAction<AbstractCanvasHandler> onMouseClick(final AbstractCanvasHandler canvasHandler, final String uuid, final MouseClickEvent event) { // Obtain the connector and source node instances for proxying. final Element<?> element = CanvasLayoutUtils.getElement(canvasHandler, uuid); final Node<View<?>, Edge> sourceNode = (Node<View<?>, Edge>) element.asNode(); final Edge<? extends ViewConnector<?>, Node> connector = (Edge<? extends ViewConnector<?>, Node>) clientFactoryManager .newElement(UUID.uuid(), edgeId) .asEdge(); // Set the transient connection to the source node, for further rule evaluations. connector.setSourceNode(sourceNode); // Built and show a connector drag proxy, to check and finally set // candidate the target node. final double x = event.getX(); final double y = event.getY(); dragProxy = showDragProxy(canvasHandler, connector, sourceNode, (int) x, (int) y); return this; }
existingConnector.setSourceNode(node1); existingConnector.setTargetNode(node2);
@Before public void setup() { super.setup(); this.parent = CommandTestUtils.makeNode("uuid1", "parent", 10.0, 20.0, 50.0, 50.0); this.candidate = CommandTestUtils.makeNode("uuid2", "candidate", 10.0, 20.0, 50.0, 50.0); this.command = new CaseManagementRemoveChildCommand(parent, candidate); final Edge<Child, Node> edge = new EdgeImpl<>("edge1"); edge.setContent(new Child()); edge.setSourceNode(parent); edge.setTargetNode(candidate); parent.getOutEdges().add(edge); candidate.getInEdges().add(edge); }
stageInEdge.setSourceNode(rootNode); stageInEdge.setTargetNode(stageNode); stageInEdge.setContent(new Child()); subcaseInEdge.setSourceNode(stageNode); subcaseInEdge.setTargetNode(subcaseNode); subcaseInEdge.setContent(new Child());
stageInEdge.setSourceNode(rootNode); stageInEdge.setTargetNode(stageNode); stageInEdge.setContent(new Child());