@Override public WorkflowDataToken pushOwningProcess(String localProcessName) throws ProcessIdentifierException { return new WorkflowDataToken(pushOwner(localProcessName), index, dataRef, context); }
@Override public WorkflowDataToken pushOwningProcess(String localProcessName) throws ProcessIdentifierException { return new WorkflowDataToken(pushOwner(localProcessName), index, dataRef, context); }
@Override public WorkflowDataToken popOwningProcess() throws ProcessIdentifierException { return new WorkflowDataToken(popOwner(), index, dataRef, context); }
@Override public WorkflowDataToken pushOwningProcess(String localProcessName) throws ProcessIdentifierException { return new WorkflowDataToken(pushOwner(localProcessName), index, dataRef, context); }
@Override public WorkflowDataToken popOwningProcess() throws ProcessIdentifierException { return new WorkflowDataToken(popOwner(), index, dataRef, context); }
@Override public WorkflowDataToken popOwningProcess() throws ProcessIdentifierException { return new WorkflowDataToken(popOwner(), index, dataRef, context); }
public void jobCreated(Job outputJob) { for (String outputPortName : outputJob.getData().keySet()) { WorkflowDataToken token = new WorkflowDataToken(outputJob .getOwningProcess(), outputJob.getIndex(), outputJob .getData().get(outputPortName), outputJob.getContext()); parent.getOutputPortWithName(outputPortName).receiveEvent(token); } }
public void jobCreated(Job outputJob) { for (String outputPortName : outputJob.getData().keySet()) { WorkflowDataToken token = new WorkflowDataToken(outputJob .getOwningProcess(), outputJob.getIndex(), outputJob .getData().get(outputPortName), outputJob.getContext()); parent.getOutputPortWithName(outputPortName).receiveEvent(token); } }
public void jobCreated(Job outputJob) { for (String outputPortName : outputJob.getData().keySet()) { WorkflowDataToken token = new WorkflowDataToken(outputJob .getOwningProcess(), outputJob.getIndex(), outputJob .getData().get(outputPortName), outputJob.getContext()); parent.getOutputPortWithName(outputPortName).receiveEvent(token); } }
public void testLockUnlock() throws UnsupportedEncodingException, MalformedIdentifierException, ActivityConfigurationException, EditException, InterruptedException { testLock(); System.out.println("Unlock (should produce both tokens) :"); Thread.sleep(200); WorkflowDataToken token2 = new WorkflowDataToken("outerProcess1", new int[0], Literal.buildLiteral("Another string"),context); p1.getInputPorts().get(0).receiveEvent(token2); assertTrue(deh2.getEventCount() == 1); }
@Test(expected=IllegalStateException.class) public void testFireIllegalStateException() throws Exception{ DummyProcessor processor = new DummyProcessor(); dataflow.processors.add(processor); DummyDataflowInputPort port1 = new DummyDataflowInputPort("test_port1",0,0,dataflow); dataflow.inputPorts.add(port1); facade.pushData(new WorkflowDataToken("", new int[]{}, null, context), "test_port1"); facade.fire(); }
protected void receiveEvent(WorkflowDataToken token, String portName) { int portIndex = inputPortNameToIndex(portName); if (portIndex == -1) { throw new WorkflowStructureException( "Received event on a port that doesn't exist, huh?"); } int[] currentIndex = token.getIndex(); int[] newIndex = new int[currentIndex.length + 1]; newIndex[0] = portIndex; for (int i = 0; i < currentIndex.length; i++) { newIndex[i + 1] = currentIndex[i]; } output.sendEvent(new WorkflowDataToken(token.getOwningProcess(), newIndex, token.getData(), token.getContext())); }
@Test public synchronized void singleDataTokenBehaviour() throws MalformedIdentifierException, EditException, JDOMException, IOException, ActivityConfigurationException, InterruptedException { // System.out.println("Single token, 'A string'"); // Build an input data token WorkflowDataToken token = new WorkflowDataToken("outerProcess1", new int[0], Literal.buildLiteral("A string"), context); processor.getInputPorts().get(0).receiveEvent(token); Thread.sleep(250); assertEquals(1, deh.getEventCount()); }
public void testLock() throws UnsupportedEncodingException, MalformedIdentifierException, ActivityConfigurationException, EditException { create(); System.out.println("Lock (should produce no output) :"); WorkflowDataToken token = new WorkflowDataToken("outerProcess1", new int[0], Literal.buildLiteral("A string"), context); p2.getInputPorts().get(0).receiveEvent(token); // p1.getInputPorts().get(0).receiveEvent(token); assertTrue(deh2.getEventCount() == 0); }
@Test public void testPushData() throws Exception { DummyDataflowInputPort port = new DummyDataflowInputPort("test",0,0,dataflow); dataflow.inputPorts.add(port); facade.pushData(new WorkflowDataToken("", new int[]{}, null, context), "test"); assertNotNull(port.tokenOwningProcess); assertEquals("facade0",port.tokenOwningProcess); }
public void testLockUnlockWithDifferentProcess() throws UnsupportedEncodingException, MalformedIdentifierException, ActivityConfigurationException, EditException, InterruptedException { testLock(); System.out.println("Unlock with diffent process, only output from p1 :"); Thread.sleep(200); WorkflowDataToken token2 = new WorkflowDataToken("outerProcess2", new int[0], Literal.buildLiteral("Another string"),context); p1.getInputPorts().get(0).receiveEvent(token2); assertTrue(deh2.getEventCount() == 0); assertTrue(deh1.getEventCount() == 1); }
@Test // test pushData doesn't fire port with non-matching name public void testPushData2() throws Exception { DummyDataflowInputPort port1 = new DummyDataflowInputPort("test_port1",0,0,dataflow); dataflow.inputPorts.add(port1); DummyDataflowInputPort port2 = new DummyDataflowInputPort("test_port2",0,0,dataflow); dataflow.inputPorts.add(port2); facade.pushData(new WorkflowDataToken("", new int[]{}, null, context), "test_port1"); assertNotNull(port1.tokenOwningProcess); assertEquals("facade0",port1.tokenOwningProcess); assertNull(port2.tokenOwningProcess); }
@Test public void singleEmptyListDataTokenBehaviour() throws MalformedIdentifierException, EditException, JDOMException, IOException, ActivityConfigurationException, InterruptedException { // System.out.println("Empty list"); EntityIdentifier listIdentifier = dManager.registerEmptyList(1); // Build an input data token of a single list WorkflowDataToken token = new WorkflowDataToken("outerProcess2", 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 to the processor where it // wanted a single item and that it therefore has a wrapping level of 1 // after the iteration strategy has been applied. processor.resultWrappingDepth = 1; processor.getInputPorts().get(0).receiveEvent(token); // This shouldn't do anything as we've got the filter by default set to // 0 so it ignores this list which has depth 1. It will now, however, // correctly iterate over what it thinks is an empty set and return a // single empty result on the output Thread.sleep(100); assertEquals(1, deh.getEventCount()); }
@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()); }
@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()); }