@Override public void setParent(Workflow parent) { if (this.parent != null && this.parent != parent) this.parent.getProcessors().remove(this); this.parent = parent; if (parent != null) parent.getProcessors().add(this); }
private void checkCompleteness() { Workflow w = validatorState.get().getWorkflow(); if (w.getProcessors().isEmpty() && w.getOutputPorts().isEmpty()) { validatorState.get().getEventListener().incompleteWorkflow(w); // validatorState.get().addIncompleteWorkflow(w); } }
@Before public void readWorkflow() throws ReaderException, IOException { WorkflowBundleIO io = new WorkflowBundleIO(); InputStream is = getClass().getResourceAsStream(ITERATIONSTRATEGIES_T2FLOW); wfBundle = io.readBundle(is, APPLICATION_VND_TAVERNA_T2FLOW_XML); wf = wfBundle.getMainWorkflow(); coloursLisr = wf.getProcessors().getByName("ColoursLisr"); concat = wf.getProcessors().getByName("Concatenate_two_strings"); shape = wf.getProcessors().getByName("ShapeAnimals"); }
@Test public void controlLinksBlocking() { Processor hello = workflowBundle.getMainWorkflow().getProcessors() .getByName("Hello"); Processor wait4me = workflowBundle.getMainWorkflow().getProcessors() .getByName("wait4me"); ControlLink controlLink = workflowBundle.getMainWorkflow().getControlLinks() .iterator().next(); assertEquals(Collections.singletonList(controlLink), scufl2Tools.controlLinksBlocking(hello)); assertTrue(scufl2Tools.controlLinksBlocking(wait4me).isEmpty()); }
@Test public void uriForProcessor() throws Exception { URI uri = uriTools.uriForBean(wfBundle.getMainWorkflow() .getProcessors().getByName("Hello")); assertEquals(HELLO_URI, uri.toASCIIString()); }
@Test public void resolveProcessorIterationStrategyStack() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); assertSame( hello.getIterationStrategyStack(), uriTools.resolveUri( HELLO_URI.resolve("iterationstrategy/"), wfBundle)); }
@Test public void uriForDatalinkWithMerge() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); List<DataLink> greetingLinks = scufl2Tools.datalinksFrom(hello .getOutputPorts().getByName("greeting")); URI uri = uriTools.uriForBean(greetingLinks.get(0)); assertEquals( HELLOWORLD_URI + "datalink?from=processor/Hello/out/greeting&to=out/results&mergePosition=0", uri.toASCIIString()); }
@Test public void uriForDatalink() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); List<DataLink> nameLinks = scufl2Tools.datalinksTo(hello .getInputPorts().getByName("name")); URI uri = uriTools.uriForBean(nameLinks.get(0)); assertEquals(HELLOWORLD_URI + "datalink?from=in/yourName&to=processor/Hello/in/name", uri.toASCIIString()); }
@Test public void unconfigureLoopLayer() throws Exception { URL wfResource = getClass().getResource(INTERACTION_WITH_LOOP); assertNotNull("Could not find workflow " + INTERACTION_WITH_LOOP, wfResource); T2FlowParser parser = new T2FlowParser(); parser.setStrict(false); WorkflowBundle wfBundle = parser.parseT2Flow(wfResource.openStream()); Scufl2Tools scufl2Tools = new Scufl2Tools(); Processor interaction = wfBundle.getMainWorkflow().getProcessors().getByName("BioSTIFInteraction"); Configuration config = scufl2Tools.configurationFor(interaction, wfBundle.getMainProfile()); assertNull(config.getJsonAsObjectNode().get("loop")); }
@Test public void uriForProcessorOutPort() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); URI uri = uriTools.uriForBean(hello.getOutputPorts().getByName( "greeting")); assertEquals(HELLO_URI + "out/greeting", uri.toASCIIString()); }
@Test public void resolveProcessorInput() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); InputProcessorPort helloName = hello.getInputPorts().getByName("name"); assertSame(helloName, uriTools.resolveUri(HELLO_URI.resolve("in/name"), wfBundle)); }
@Test public void resolveProcessorIterationStrategyRoot() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); assertSame(hello.getIterationStrategyStack().get(0), uriTools.resolveUri(HELLO_URI.resolve("iterationstrategy/0/"), wfBundle)); }
@Test public void resolveProcessorOutput() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); OutputProcessorPort greeting = hello.getOutputPorts().getByName( "greeting"); assertSame(greeting, uriTools.resolveUri( HELLO_URI.resolve("out/greeting"), wfBundle)); }
@Test public void uriForIterationStrategyCross() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); CrossProduct crossProduct = (CrossProduct) hello .getIterationStrategyStack().get(0); URI uri = uriTools.uriForBean(crossProduct.get(0)); assertEquals(HELLO_URI + "iterationstrategy/0/0/", uri.toASCIIString()); }
@Test public void resolveProcessorIterationStrategyNode() throws Exception { Processor hello = wfBundle.getMainWorkflow().getProcessors() .getByName("Hello"); CrossProduct rootStrategyNode = (CrossProduct) hello .getIterationStrategyStack().get(0); assertSame(rootStrategyNode.get(0), uriTools.resolveUri( HELLO_URI.resolve("iterationstrategy/0/0/"), wfBundle)); }
@Test public void readBundleStream() throws Exception { InputStream inputStream = new ByteArrayInputStream( getStructureFormatWorkflowBundle().getBytes("utf-8")); WorkflowBundle wfBundle = bundleIO.readBundle(inputStream, TEXT_VND_TAVERNA_SCUFL2_STRUCTURE); assertEquals("HelloWorld", wfBundle.getName()); assertEquals("HelloWorld", wfBundle.getMainWorkflow().getName()); assertTrue(wfBundle.getMainWorkflow().getProcessors() .containsName("Hello")); }
@Test public void iterationStrategyWait4Me() throws Exception { Processor wait4me = workflowBundle.getMainWorkflow().getProcessors() .getByName("wait4me"); assertEquals(0, wait4me.getIterationStrategyStack().size()); }
@Test public void processorPortsWait4Me() throws Exception { Processor wait4me = workflowBundle.getMainWorkflow().getProcessors() .getByName("wait4me"); assertEquals(0, wait4me.getInputPorts().size()); assertEquals(0, wait4me.getOutputPorts().size()); }
@Test public void processorInputPorts() throws Exception { Processor hello = workflowBundle.getMainWorkflow().getProcessors() .getByName("Hello"); assertEquals(1, hello.getInputPorts().size()); assertEquals("name", hello.getInputPorts().getByName("name").getName()); assertEquals(0, hello.getInputPorts().getByName("name").getDepth() .intValue()); }
@Test public void processorBinding() throws Exception { assertEquals(1, profile.getProcessorBindings().size()); ProcessorBinding hello = profile.getProcessorBindings().getByName( "Hello"); assertEquals(profile.getActivities().getByName("HelloScript"), hello.getBoundActivity()); assertEquals(bundle.getMainWorkflow().getProcessors() .getByName("Hello"), hello.getBoundProcessor()); assertEquals("Hello", hello.getName()); assertEquals(10, hello.getActivityPosition().intValue()); }