for (Node node : graphContext.getGraph().getNodes()) { final NodeContext nodeContext = graphContext.getNodeContext(node); currentOperator = nodeContext.getOperator(); if (currentOperator instanceof ReadOp) { final Product product = currentOperator.getTargetProduct();
Node node = getGraph().getNode(referenceNodeId); NodeContext referredNodeContext = getNodeContext(node); Operator operator = referredNodeContext.getOperator(); OperatorConfiguration.PropertyReference propertyReference = new OperatorConfiguration.PropertyReference(parameterName, propertyName, operator); references.add(propertyReference);
@Override public void initialize() throws OperatorException { try { Graph graph = ((Spi) getSpi()).graph; OperatorContext operatorContext = getOperatorContext(); setOperatorParameters(graph, operatorContext); NodeContext targetNodeContext = getTargetNodeContext(graph); if (targetNodeContext == null) { throw new OperatorException("No target node found..."); } setTargetProduct(targetNodeContext.getOperator().getTargetProduct()); } catch (GraphException e) { throw new OperatorException(e); } }
public void testSpiCreation() throws GraphException { Graph graph = new Graph("chain1"); Node node1 = new Node("node1", "Op1"); graph.addNode(node1); GraphContext graphContext = new GraphContext(graph); NodeContext nodeContext = graphContext.getNodeContext(node1); assertEquals("Op1", graph.getNode("node1").getOperatorName()); assertEquals("org.esa.beam.framework.gpf.TestOps$Op1", nodeContext.getOperator().getClass().getName()); }
public void testTargetProductIsSetByAnnotation() throws GraphException { Graph graph = new Graph("graph"); Node node = new Node("OutputNotSet", notInitTargetProductOpSPI.getOperatorAlias()); graph.addNode(node); GraphContext graphContext = new GraphContext(graph); NodeContext nodeContext = graphContext.getNodeContext(node); NotInitOutputOperator notInitOutputOperator = (NotInitOutputOperator) nodeContext.getOperator(); assertNotNull("Output of operator is null", notInitOutputOperator.output); assertSame(nodeContext.getTargetProduct(), notInitOutputOperator.output); }
TestOps.Op4 op4 = (TestOps.Op4) bertNodeContext.getOperator(); final Object targetProperty = op4.getTargetProperty("pi"); assertNotNull(targetProperty); TestOps.Op2 op2 = (TestOps.Op2) bazNodeContext.getOperator(); assertEquals(3.142, op2.threshold, 0.0);
public void testSourceProductWithAlias() throws GraphException { Graph graph = new Graph("graph"); Node goodNode = new Node("Good", goodOpSpi.getOperatorAlias()); Node consumerNode = new Node("AliasConsumer", aliasConsumerOpSpi.getOperatorAlias()); consumerNode.addSource(new NodeSource("alias", "Good")); graph.addNode(goodNode); graph.addNode(consumerNode); GraphContext graphContext = new GraphContext(graph); NodeContext consumerNodeContext = graphContext.getNodeContext(consumerNode); assertSame(((ConsumerWithAliasSourceOperator) consumerNodeContext.getOperator()).input1, consumerNodeContext.getSourceProduct("alias")); }
TestOps.Op4 op4 = (TestOps.Op4) bertNodeContext.getOperator(); final Object targetProperty = op4.getTargetProperty("pi"); assertNotNull(targetProperty); TestOps.Op2 op2 = (TestOps.Op2) bazNodeContext.getOperator(); assertEquals(3.142, op2.threshold, 0.0);
public void testAnnotationsProcessed() throws Exception { Graph graph = new Graph("graph"); Node node1 = new Node("node1", "Op1"); Node node2 = new Node("node2", "Op2"); Node node3 = new Node("node3", "Op3"); node2.addSource(new NodeSource("input", "node1")); node3.addSource(new NodeSource("input1", "node1")); node3.addSource(new NodeSource("input2", "node2")); graph.addNode(node1); graph.addNode(node2); graph.addNode(node3); GraphContext graphContext = new GraphContext(graph); NodeContext nodeContext2 = graphContext.getNodeContext(node2); NodeContext nodeContext3 = graphContext.getNodeContext(node3); TestOps.Op2 op2 = ((TestOps.Op2) nodeContext2.getOperator()); TestOps.Op3 op3 = ((TestOps.Op3) nodeContext3.getOperator()); assertNotNull(op2.input); assertSame(nodeContext2.getSourceProduct("input"), op2.input); assertNotNull(op3.input1); assertNotNull(op3.input2); assertSame(nodeContext3.getSourceProduct("input1"), op3.input1); assertSame(nodeContext3.getSourceProduct("input2"), op3.input2); assertNotNull(op3.inputs); assertEquals(0, op3.inputs.length); assertEquals(false, op3.ignoreSign); // has NO default value assertEquals("NN", op3.interpolMethod); // has default value assertEquals(1.5, op3.factor); // has default value }
TestOps.Op2 op2 = (TestOps.Op2) nodeContext2.getOperator(); assertEquals(0.86, op2.threshold, 1.e-10); TestOps.Op3 op3 = (TestOps.Op3) nodeContext3.getOperator(); assertEquals(true, op3.ignoreSign); assertEquals("A+B", op3.expression);