public GraphNode findGraphNode(String id) { for (GraphNode n : nodeList) { if (n.getID().equals(id)) { return n; } } return null; }
public void remove(final GraphNode node) { // remove as a source from all nodes for (GraphNode n : nodeList) { n.disconnectOperatorSources(node.getID()); } nodeList.remove(node); }
public boolean isNodeSource(final GraphNode source) { final NodeSource[] sources = node.getSources(); for (NodeSource ns : sources) { if (ns.getSourceNodeId().equals(source.getID())) { return true; } } return false; }
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 removeNode(final GraphNode node) { graphNodeList.remove(node); graph.removeNode(node.getID()); }
/** * For coregistration * * @param graphEx the graph executer * @param productSetID the product set reader * @param masterFile master file * @param slaveFiles slave file list */ protected static void setSlaveIO(final GraphExecuter graphEx, final String productSetID, final File masterFile, final File[] slaveFiles) { final GraphNode productSetNode = graphEx.getGraphNodeList().findGraphNodeByOperator(productSetID); if (productSetNode != null) { StringBuilder str = new StringBuilder(masterFile.getAbsolutePath()); for (File slaveFile : slaveFiles) { str.append(','); str.append(slaveFile.getAbsolutePath()); } graphEx.setOperatorParam(productSetNode.getID(), "fileList", str.toString()); } }
private void removeNode(final GraphNode node) { graphNodeList.remove(node); graph.removeNode(node.getID()); }
private void removeNode(final GraphNode node) { graphNodeList.remove(node); graph.removeNode(node.getID()); }
private GraphNode[] replaceProductSetReaders() { final ProductSetData[] productSetDataList = findProductSets(ProductSetHandler.PRODUCT_SET_READER_NAME); final List<GraphNode> savedProductSetList = new ArrayList<>(); int cnt = 0; for (ProductSetData psData : productSetDataList) { final GraphNode sourceNode = graphNodeList.findGraphNode(psData.nodeID); for (String filePath : psData.fileList) { replaceProductSetWithReaders(sourceNode, "inserted--" + sourceNode.getID() + "--" + cnt++, filePath); } if (!psData.fileList.isEmpty()) { removeNode(sourceNode); savedProductSetList.add(sourceNode); } } return savedProductSetList.toArray(new GraphNode[savedProductSetList.size()]); }
public void autoConnectGraph() { final List<GraphNode> nodeList = Arrays.asList(GetGraphNodes()); Collections.sort(nodeList, new GraphNodePosComparator()); final GraphNode[] nodes = nodeList.toArray(new GraphNode[nodeList.size()]); for (int i = 0; i < nodes.length - 1; ++i) { if (!nodes[i].HasSources()) { nodes[i].connectOperatorSource(nodes[i + 1].getID()); } } notifyConnection(); }
protected void setIO(final GraphExecuter graphEx, final String readID, final File readPath, final String writeID, final File writePath, final String format) { final GraphNode readNode = graphEx.getGraphNodeList().findGraphNodeByOperator(readID); if (readNode != null) { graphEx.setOperatorParam(readNode.getID(), "file", readPath.getAbsolutePath()); } if (replaceWritersWithUniqueTargetProduct && writeID != null) { final GraphNode writeNode = graphEx.getGraphNodeList().findGraphNodeByOperator(writeID); if (writeNode != null) { if (format != null) graphEx.setOperatorParam(writeNode.getID(), "formatName", format); graphEx.setOperatorParam(writeNode.getID(), "file", writePath.getAbsolutePath()); } } }
/** * Update the nodes in the graph with the given reader file and writer file */ public static void setGraphIO(final GraphExecuter graphEx, final String readID, final File readPath, final String writeID, final File writePath, final String format) { final GraphNode readNode = graphEx.getGraphNodeList().findGraphNode(readID); if (readNode != null) { graphEx.setOperatorParam(readNode.getID(), "file", readPath.getAbsolutePath()); } if (writeID != null) { final GraphNode writeNode = graphEx.getGraphNodeList().findGraphNode(writeID); if (writeNode != null) { graphEx.setOperatorParam(writeNode.getID(), "formatName", format); graphEx.setOperatorParam(writeNode.getID(), "file", writePath.getAbsolutePath()); } } }
void RemoveSourceAction(String id) { if (selectedNode != null) { final GraphNode source = graphEx.getGraphNodeList().findGraphNode(id); selectedNode.disconnectOperatorSources(source.getID()); repaint(); } }
protected void cloneGraphs() throws Exception { final GraphExecuter graphEx = graphExecutorList.get(0); for (int graphIndex = 1; graphIndex < graphExecutorList.size(); ++graphIndex) { final GraphExecuter cloneGraphEx = graphExecutorList.get(graphIndex); cloneGraphEx.ClearGraph(); } graphExecutorList.clear(); graphExecutorList.add(graphEx); final File[] fileList = productSetPanel.getFileList(); for (int graphIndex = 1; graphIndex < fileList.length; ++graphIndex) { final GraphExecuter cloneGraphEx = new GraphExecuter(); LoadGraph(cloneGraphEx, graphFile, false); graphExecutorList.add(cloneGraphEx); // copy UI parameter to clone final GraphNode[] cloneGraphNodes = cloneGraphEx.GetGraphNodes(); for (GraphNode cloneNode : cloneGraphNodes) { final GraphNode node = graphEx.getGraphNodeList().findGraphNode(cloneNode.getID()); if (node != null) cloneNode.setOperatorUI(node.GetOperatorUI()); } } }
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()); } }
@Test public void testCreateGraph() throws GraphException { GraphNode nodeA = graphEx.addOperator("testOp"); GraphNode nodeB = graphEx.addOperator("testOp"); nodeB.connectOperatorSource(nodeA.getID()); //graphEx.writeGraph("D:\\data\\testGraph.xml"); //graphEx.executeGraph(new NullProgressMonitor()); }
@Test public void testFindGraphNode() { GraphNode lostNode = graphEx.addOperator("lostOp"); GraphNode foundNode = graphEx.getGraphNodeList().findGraphNode(lostNode.getID()); assertTrue(foundNode.equals(lostNode)); graphEx.ClearGraph(); }
private void replaceProductSetWithReaders(final GraphNode sourceNode, final String id, final String value) { final GraphNode newReaderNode = GraphExecuter.createNewGraphNode(graph, graphNodeList, OperatorSpi.getOperatorAlias(ReadOp.class), id); newReaderNode.setOperatorUI(null); final DomElement config = newReaderNode.getNode().getConfiguration(); final DomElement fileParam = new XppDomElement("file"); fileParam.setValue(value); config.addChild(fileParam); final String format = CommonReaders.findCommonProductFormat(new File(value)); if(format != null) { final DomElement formatParam = new XppDomElement("formatName"); formatParam.setValue(format); config.addChild(formatParam); } graphNodeList.switchConnections(sourceNode, newReaderNode.getID()); }
@Test public void testNode() { assertEquals(node, graphNode.getNode()); assertEquals(node.getId(), graphNode.getID()); assertEquals(node.getOperatorName(), graphNode.getOperatorName()); }
@Test public void testSourceConnection() { final Node sourceNode = new Node("sourceID", "testSourceNodeOp"); final XppDomElement parameters = new XppDomElement("parameters"); sourceNode.setConfiguration(parameters); GraphNode sourceGraphNode = new GraphNode(sourceNode); // test connect graphNode.connectOperatorSource(sourceGraphNode.getID()); NodeSource ns = node.getSource(0); assertNotNull(ns); assertEquals(ns.getSourceNodeId(), sourceNode.getId()); // test disconnect graphNode.disconnectOperatorSources(sourceGraphNode.getID()); NodeSource[] nsList = node.getSources(); assertEquals(nsList.length, 0); } }