public void restore() { for (GraphNode multiSrcNode : savedProductSetList) { final List<GraphNode> nodesToRemove = new ArrayList<>(); for (GraphNode n : graphNodeList.getGraphNodes()) { final String id = n.getID(); if (id.startsWith("inserted--" + multiSrcNode.getID()) && id.contains(multiSrcNode.getID())) { graphNodeList.switchConnections(n, multiSrcNode.getID()); nodesToRemove.add(n); } } for (GraphNode r : nodesToRemove) { removeNode(r); } graphNodeList.add(multiSrcNode); graph.addNode(multiSrcNode.getNode()); } }
private void moveWriterToLast(final Graph graph) { final String writeOperatorAlias = OperatorSpi.getOperatorAlias(WriteOp.class); final GraphNode writerNode = graphNodeList.findGraphNode(writeOperatorAlias); if (writerNode != null) { removeNode(writerNode); graphNodeList.add(writerNode); graph.addNode(writerNode.getNode()); } }
static GraphNode createNewGraphNode(final Graph graph, final GraphNodeList graphNodeList, final String opName, final String id) { final Node newNode = new Node(id, opName); final XppDomElement parameters = new XppDomElement("parameters"); newNode.setConfiguration(parameters); graph.addNode(newNode); final GraphNode newGraphNode = new GraphNode(newNode); graphNodeList.add(newGraphNode); newGraphNode.setOperatorUI(OperatorUIRegistry.CreateOperatorUI(newGraphNode.getOperatorName())); return newGraphNode; }
private GraphNode createNewGraphNode(final Graph graph, final String opName, final String id) { final Node newNode = new Node(id, opName); final XppDomElement parameters = new XppDomElement("parameters"); newNode.setConfiguration(parameters); graph.addNode(newNode); final GraphNode newGraphNode = new GraphNode(newNode); graphNodeList.add(newGraphNode); newGraphNode.setOperatorUI(OperatorUIRegistry.CreateOperatorUI(newGraphNode.getOperatorName())); moveWriterToLast(graph); return newGraphNode; }
public void restore() { for (GraphNode savedNode : savedSubGraphList) { final GraphNode[] nodesToRemove = subGraphNodesToRemoveMap.get(savedNode); for (GraphNode n : nodesToRemove) { final GraphNode[] connectedNodes = graphNodeList.findConnectedNodes(n); for (GraphNode node : connectedNodes) { node.connectOperatorSource(savedNode.getID()); final String name = node.getSourceName(n.getID()); node.setSourceName(name, savedNode.getNode().getId()); } removeNode(n); } graphNodeList.add(savedNode); graph.addNode(savedNode.getNode()); } }
graphNodeList.add(newGraphNode); toRemove.add(newGraphNode);
public void setGraph(final Graph graphFromFile, final boolean addUI) throws GraphException { if (graphFromFile != null) { graph = graphFromFile; graphNodeList.clear(); final XppDom presentationXML = graph.getApplicationData("Presentation"); if (presentationXML != null) { // get graph description final XppDom descXML = presentationXML.getChild("Description"); if (descXML != null && descXML.getValue() != null) { graphDescription = descXML.getValue(); } } final Node[] nodes = graph.getNodes(); for (Node n : nodes) { final GraphNode newGraphNode = new GraphNode(n); if (presentationXML != null) newGraphNode.setDisplayParameters(presentationXML); graphNodeList.add(newGraphNode); if (addUI) { OperatorUI ui = OperatorUIRegistry.CreateOperatorUI(newGraphNode.getOperatorName()); if (ui == null) { throw new GraphException("Unable to load " + newGraphNode.getOperatorName()); } newGraphNode.setOperatorUI(ui); } notifyGraphEvent(new GraphEvent(events.ADD_EVENT, newGraphNode)); } } }