private void initNodeContext(final NodeContext nodeContext, Operator graphOp) throws GraphException { if (nodeContext.isInitialized()) { return; } for (NodeSource source : nodeContext.getNode().getSources()) { NodeContext sourceNodeContext = getNodeContext(source.getSourceNode()); Product sourceProduct = null; if (sourceNodeContext != null) { initNodeContext(sourceNodeContext, graphOp); sourceProduct = sourceNodeContext.getTargetProduct(); } else { if (graphOp != null) { sourceProduct = graphOp.getSourceProduct(source.getSourceNodeId()); } } if (sourceProduct == null) { throw new GraphException(getMissingSourceMessage(nodeContext.getNode(), source)); } nodeContext.addSourceProduct(source.getName(), sourceProduct); } Node node = nodeContext.getNode(); DomElement configuration = node.getConfiguration(); OperatorConfiguration opConfiguration = this.createOperatorConfiguration(configuration, new HashMap<String, Object>()); nodeContext.setOperatorConfiguration(opConfiguration); nodeContext.initTargetProduct(); getInitNodeContextDeque().addFirst(nodeContext); }
private void testGraph(String[] args, int expectedNodeCount, String expectedLog, Map<String, String> expectedSourceNodeIdFilePathMap, String expectedTargetNodeId, String expectedTargetFilepath, String expectedTargetFormat) throws Exception { clTool.run(args); assertEquals(expectedLog, context.logString); Graph executedGraph = context.executedGraph; assertNotNull(executedGraph); assertEquals(expectedNodeCount, executedGraph.getNodeCount()); for (Map.Entry<String, String> entry : expectedSourceNodeIdFilePathMap.entrySet()) { String expectedSourceFilePath = entry.getValue(); if (expectedSourceFilePath != null) { final String key = entry.getKey(); Node generatedReaderNode1 = executedGraph.getNode(key); assertNotNull("Source ID not found: " + key, generatedReaderNode1); assertEquals(expectedSourceFilePath, generatedReaderNode1.getConfiguration().getChild("file").getValue()); } } Node generatedWriterNode = executedGraph.getNode(expectedTargetNodeId); assertNotNull(generatedWriterNode); assertEquals("node1", generatedWriterNode.getSource(0).getSourceNodeId()); DomElement parameters = generatedWriterNode.getConfiguration(); assertNotNull(parameters); assertNotNull(expectedTargetFilepath, parameters.getChild("file").getValue()); assertNotNull(expectedTargetFormat, parameters.getChild("formatName").getValue()); }
DomElement configurationDomElement = bandMathsNode.getConfiguration(); ParameterDescriptorFactory parameterDescriptorFactory = new ParameterDescriptorFactory();
assertEquals(expectedThreshold, node1.getConfiguration().getChild("threshold").getValue()); assertEquals(expectedExpression, node2.getConfiguration().getChild("expression").getValue()); assertEquals(expectedSourceFilepath1, generatedReaderNode1.getConfiguration().getChild("file").getValue()); Node generatedReaderNode2 = executedGraph.getNode(expectedSourceNodeId2); assertNotNull(generatedReaderNode2); assertEquals(expectedSourceFilepath2, generatedReaderNode2.getConfiguration().getChild("file").getValue()); assertEquals("node2", generatedWriterNode.getSource(0).getSourceNodeId()); DomElement parameters = generatedWriterNode.getConfiguration(); assertNotNull(parameters); assertNotNull(expectedTargetFilepath, parameters.getChild("file").getValue());