public ProcessorInputPort createProcessorInputPort(Processor processor, String name, int depth) { return new ProcessorInputPortImpl((ProcessorImpl) processor, name, depth); }
protected ProcessorInputPortImpl getInputPortWithName(String name) { for (ProcessorInputPortImpl p : inputPorts) { String portName = p.getName(); if (portName.equals(name)) { return p; } } return null; }
if (input.getIncomingLink() == null) { return false; } else { if (input.getIncomingLink().getResolvedDepth() == -1) { inputDepths.put(input.getName(), input.getIncomingLink() .getResolvedDepth()); input.setFilterDepth(input.getIncomingLink().getSource() .getGranularDepth());
@Override protected void doEditAction(ProcessorImpl processor) throws EditException { // Add a new InputPort object to the processor and also create an // appropriate NamedInputPortNode in any iteration strategies. By // default set the desired drill depth on each iteration strategy node // to the same as the input port, so this won't automatically trigger // iteration staging unless the depth is altered on the iteration // strategy itself.) if (processor.getInputPortWithName(port.getName()) != null) { throw new EditException( "Attempt to create duplicate input port with name '" + port.getName() + "'"); } previousIterationStrategyState = processor.iterationStack.asXML(); processor.inputPorts.add(port); for (IterationStrategyImpl is : processor.iterationStack.getStrategies()) { NamedInputPortNode nipn = new NamedInputPortNode(port.getName(), port.getDepth()); is.addInput(nipn); is.connectDefault(nipn); } }
@Test public void topLevelEmptyCollection() throws EditException, JDOMException, IOException, ActivityConfigurationException, MalformedIdentifierException, InterruptedException { // System.out.println("Top level empty list (depth 2)"); EntityIdentifier listIdentifier = dManager .registerEmptyList(2); ((ProcessorInputPortImpl) (processor.getInputPorts().get(0))) .setFilterDepth(0); WorkflowDataToken token = new WorkflowDataToken("outerProcess4", new int[0], listIdentifier, context); // This is not a public API! We're using it here because we need some // way to push the configuration data into the processor that would // normally be created during the typecheck operation. In this case // we're declaring that we've given a list of lists to the processor // where it wanted a single item and that it therefore has a wrapping // level of 2 after the iteration strategy has been applied. processor.resultWrappingDepth = 2; processor.getInputPorts().get(0).receiveEvent(token); Thread.sleep(100); assertEquals(1, deh.getEventCount()); }
if (input.getIncomingLink() == null) { return false; } else { if (input.getIncomingLink().getResolvedDepth() == -1) { inputDepths.put(input.getName(), input.getIncomingLink() .getResolvedDepth()); input.setFilterDepth(input.getIncomingLink().getSource() .getGranularDepth());
@Override protected void doEditAction(ProcessorImpl processor) throws EditException { // Add a new InputPort object to the processor and also create an // appropriate NamedInputPortNode in any iteration strategies. By // default set the desired drill depth on each iteration strategy node // to the same as the input port, so this won't automatically trigger // iteration staging unless the depth is altered on the iteration // strategy itself.) if (processor.getInputPortWithName(port.getName()) != null) { throw new EditException( "Attempt to create duplicate input port with name '" + port.getName() + "'"); } previousIterationStrategyState = processor.iterationStack.asXML(); processor.inputPorts.add(port); for (IterationStrategyImpl is : processor.iterationStack.getStrategies()) { NamedInputPortNode nipn = new NamedInputPortNode(port.getName(), port.getDepth()); is.addInput(nipn); is.connectDefault(nipn); } }
@Test public void singleListDataTokenWithFilterConfigured() throws EditException, JDOMException, IOException, ActivityConfigurationException, MalformedIdentifierException, InterruptedException { // System.out.println("List with two items, 'foo' and 'bar'"); EntityIdentifier listIdentifier = dManager .registerList(new EntityIdentifier[] { Literal.buildLiteral("foo"), Literal.buildLiteral("bar") }); WorkflowDataToken token = new WorkflowDataToken("outerProcess3", new int[0], listIdentifier, context); // Reconfigure processor to set the filter to level 1, i.e. consume // lists and iterate over them using the data manager's traversal // functionality ((ProcessorInputPortImpl) (processor.getInputPorts().get(0))) .setFilterDepth(1); processor.getInputPorts().get(0).receiveEvent(token); // Should produce two outputs followed by a collection Thread.sleep(100); assertEquals(3, deh.getEventCount()); }
if (input.getIncomingLink() == null) { return false; } else { if (input.getIncomingLink().getResolvedDepth() == -1) { inputDepths.put(input.getName(), input.getIncomingLink() .getResolvedDepth()); input.setFilterDepth(input.getIncomingLink().getSource() .getGranularDepth());
public ProcessorInputPort createProcessorInputPort(Processor processor, String name, int depth) { return new ProcessorInputPortImpl((ProcessorImpl) processor, name, depth); }
@Test public void testPartiallyEmptyCollection() throws EditException, JDOMException, IOException, ActivityConfigurationException, MalformedIdentifierException, InterruptedException { EntityIdentifier emptyListIdentifier = dManager.registerEmptyList(1); // System.out.println("Partially empty collection : {{}{foo, bar}}"); EntityIdentifier populatedListIdentifier = dManager .registerList(new EntityIdentifier[] { Literal.buildLiteral("foo"), Literal.buildLiteral("bar") }); EntityIdentifier listIdentifier = dManager .registerList(new EntityIdentifier[] { emptyListIdentifier, populatedListIdentifier }); ((ProcessorInputPortImpl) (processor.getInputPorts().get(0))) .setFilterDepth(2); WorkflowDataToken token = new WorkflowDataToken("outerProcess5", new int[0], listIdentifier, context); // This is not a public API! We're using it here because we need some // way to push the configuration data into the processor that would // normally be created during the typecheck operation. In this case // we're declaring that we've given a list of lists to the processor // where it wanted a single item and that it therefore has a wrapping // level of 2 after the iteration strategy has been applied. processor.resultWrappingDepth = 2; processor.getInputPorts().get(0).receiveEvent(token); Thread.sleep(COMPLETION_SLEEP); assertEquals(5, deh.getEventCount()); }
protected ProcessorInputPortImpl getInputPortWithName(String name) { for (ProcessorInputPortImpl p : inputPorts) { String portName = p.getName(); if (portName.equals(name)) { return p; } } return null; }
for (Element portElement : (List<Element>) ipElement .getChildren("port")) { ProcessorInputPortImpl pipi = new ProcessorInputPortImpl(this, portElement.getAttributeValue("name"), Integer .parseInt(portElement.getAttributeValue("depth")));
protected ProcessorInputPortImpl getInputPortWithName(String name) { for (ProcessorInputPortImpl p : inputPorts) { String portName = p.getName(); if (portName.equals(name)) { return p; } } return null; }
@Override protected void doEditAction(ProcessorImpl processor) throws EditException { // Add a new InputPort object to the processor and also create an // appropriate NamedInputPortNode in any iteration strategies. By // default set the desired drill depth on each iteration strategy node // to the same as the input port, so this won't automatically trigger // iteration staging unless the depth is altered on the iteration // strategy itself.) if (processor.getInputPortWithName(newPortName) != null) { throw new EditException( "Attempt to create duplicate input port with name '" + newPortName + "'"); } previousIterationStrategyState = processor.iterationStack.asXML(); processor.inputPorts.add(new ProcessorInputPortImpl(processor, newPortName, newPortDepth)); for (IterationStrategyImpl is : processor.iterationStack.getStrategies()) { NamedInputPortNode nipn = new NamedInputPortNode(newPortName, newPortDepth); is.addInput(nipn); is.connectDefault(nipn); } }
@Override protected void undoEditAction(ProcessorImpl processor) { processor.iterationStack .configureFromElement(previousIterationStrategyState); processor.inputPorts .remove(processor.getInputPortWithName(port.getName())); }
@Before public void setup() throws Exception { merge = new MergeImpl("the merge"); ProcessorImpl p1 = new ProcessorImpl(); ProcessorImpl p2 = new ProcessorImpl(); sourcePort=new ProcessorOutputPortImpl(p1,"source_port",0,0); sinkPort=new ProcessorInputPortImpl(p2,"sink_port",0); }
@Override protected void undoEditAction(ProcessorImpl processor) { processor.iterationStack .configureFromElement(previousIterationStrategyState); processor.inputPorts .remove(processor.getInputPortWithName(port.getName())); }
@Test(expected=EditException.class) public void invalidSinkPort() throws Exception { Edit<Merge> theEdit = new ConnectMergedDatalinkEdit(merge,sourcePort,sinkPort); theEdit.doEdit(); ProcessorImpl p2=new ProcessorImpl(); ProcessorInputPortImpl sinkPort2=new ProcessorInputPortImpl(p2,"sink_port2",0); theEdit = new ConnectMergedDatalinkEdit(merge,sourcePort,sinkPort2); theEdit.doEdit(); } }