/** * Constructs a <code>Processor</code> with the specified parent {@link Workflow} and name. * * @param parent * the <code>Workflow</code> to set as the <code>Processor</code>'s parent. Can be * <code>null</code>. * @param name * the name of the <code>Processor</code>. <strong>Must not</strong> be * <code>null</code> or an empty String. */ public Processor(Workflow parent, String name) { super(name); setParent(parent); }
/** * Set the <code>Processor</code>s to be the contents of the specified set. * <p> * <code>Processor</code>s can be added by using {@link #getProcessors()} * .add(processor). * * @param processors * the <code>Processor</code>s. <strong>Must not</strong> be null */ public void setProcessors(Set<Processor> processors) { this.processors.clear(); for (Processor processor : processors) { processor.setParent(this); } }
public Processor createConstant(Workflow workflow, Profile profile, String name) { Processor processor = new Processor(null, name); workflow.getProcessors().addWithUniqueName(processor); processor.setParent(workflow); OutputProcessorPort valuePort = new OutputProcessorPort(processor, CONSTANT_VALUE_PORT); valuePort.setDepth(0); valuePort.setGranularDepth(0); Activity activity = createActivityFromProcessor(processor, profile); activity.setType(CONSTANT); createConfigurationFor(activity, CONSTANT_CONFIG); return processor; }
@Test public void setName() throws Exception { Workflow wf = new Workflow(); Processor p = new Processor(); p.setName("fish"); p.setName("soup"); p.setParent(wf); }
String processorName = parseName(scanner); processor.setName(processorName); processor.setParent(workflow); workflow.getProcessors().add(processor); return;
@Test public void testWronglyScopedBlock() { Workflow wf = new Workflow(); BlockingControlLink bcl = new BlockingControlLink(); bcl.setParent(wf); Processor block = new Processor(); Workflow otherWorkflow = new Workflow(); block.setParent(otherWorkflow); bcl.setBlock(block); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(bcl, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertEquals(1, outOfScopeValueProblems.size()); boolean outOfScopeValueProblem = false; for (OutOfScopeValueProblem oosvp : outOfScopeValueProblems) { if (oosvp.getBean().equals(bcl) && oosvp.getFieldName().equals("block") && oosvp.getValue().equals(block)) { outOfScopeValueProblem = true; } } assertTrue(outOfScopeValueProblem); }
@Test public void testCorrectnessOfOutOfScopeBoundProcessor2() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Workflow w = new Workflow(); Processor processor = new Processor(); processor.setParent(w); pb.setBoundProcessor(processor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(processor)) { problem = true; } } assertTrue(problem); }
@Test public void testValidlyScopedBlock() { Workflow wf = new Workflow(); BlockingControlLink bcl = new BlockingControlLink(); bcl.setParent(wf); Processor block = new Processor(); block.setParent(wf); bcl.setBlock(block); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(bcl, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertEquals(0, outOfScopeValueProblems.size()); } }
@Test public void testCorrectnessOfInScopeBoundProcessor() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Workflow w = new Workflow(); Processor processor = new Processor(); processor.setParent(w); w.setParent(wb); pb.setBoundProcessor(processor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); // assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(processor)) { problem = true; } } assertFalse(problem); }
@Test public void testInScopeProcessorPorts() { Workflow w = new Workflow(); DataLink dataLink = new DataLink(); dataLink.setParent(w); Processor p1 = new Processor(); p1.setParent(w); InputProcessorPort ipp = new InputProcessorPort(); ipp.setParent(p1); Processor p2 = new Processor(); p2.setParent(w); OutputProcessorPort opp = new OutputProcessorPort(); opp.setParent(p2); dataLink.setReceivesFrom(opp); dataLink.setSendsTo(ipp); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(dataLink, true, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertEquals(Collections.EMPTY_SET, outOfScopeValueProblems); }
@Ignore @Test public void writeBundleFileSetParents() throws Exception { File bundleFile = tempFile(); // Deliberately orphan a profile and a processor Profile profile = wfBundle.getProfiles().getByName("tavernaWorkbench"); profile.setParent(null); wfBundle.getProfiles().add(profile); processor.setParent(null); workflow.getProcessors().add(processor); assertNull(processor.getParent()); assertNull(profile.getParent()); bundleIO.writeBundle(wfBundle, bundleFile, TEXT_VND_TAVERNA_SCUFL2_STRUCTURE); assertNotNull(processor.getParent()); assertNotNull(profile.getParent()); String bundleTxt = FileUtils.readFileToString(bundleFile, UTF_8); assertTrue(bundleTxt.contains("Processor 'Hello'")); assertTrue(bundleTxt.contains("Profile 'tavernaWorkbench'")); }
@Test public void nullParentNotCopied() throws Exception { Workflow wf = new Workflow(); Processor orphan = new Processor(); orphan.setName("orphan"); // NOTE: NOT calling // orphan.setParent(wf) wf.getProcessors().add(orphan); assertNull(orphan.getParent()); Workflow clone = (Workflow) wf.clone(); assertTrue(clone.getProcessors().isEmpty()); orphan.setParent(wf); Workflow clone2 = (Workflow) wf.clone(); assertEquals(Collections.singleton("orphan"), clone2.getProcessors() .getNames()); }
getParserState().push(p); try { p.setParent(getParserState().getCurrent(Workflow.class)); mapBean(getParserState().getCurrentBase().resolve( processor.getAbout()), p);
@Test public void cloneProcessor() throws Exception { Workflow wf = originalWfBundle.getMainWorkflow(); Processor original = wf.getProcessors().getByName("Hello"); Processor clone = (Processor) original.clone(); assertEquals(clone.getName(), original.getName()); assertNotNull(original.getParent()); assertNull(clone.getParent()); wf.getProcessors().addWithUniqueName(clone); assertTrue(!clone.getName().equals(original.getName())); // Now it is safe to set the parent without loosing original clone.setParent(wf); assertSame(original, wf.getProcessors().getByName("Hello")); assertSame(clone, wf.getProcessors().getByName(clone.getName())); }
@Test public void setParents() throws Exception { // Deliberately orphan a profile and a processor Profile profile = workflowBundle.getProfiles().getByName("tavernaWorkbench"); profile.setParent(null); workflowBundle.getProfiles().add(profile); processor.setParent(null); workflow.getProcessors().add(processor); assertNull(processor.getParent()); assertNull(profile.getParent()); scufl2Tools.setParents(workflowBundle); assertNotNull(processor.getParent()); assertNotNull(profile.getParent()); }
@Test public void setNameWithParent() throws Exception { Workflow wf = new Workflow(); Processor p = new Processor(); p.setName("fish"); p.setParent(wf); assertTrue(wf.getProcessors().contains(p)); assertTrue(wf.getProcessors().containsName("fish")); assertFalse(wf.getProcessors().containsName("soup")); p.setName("soup"); assertFalse(wf.getProcessors().containsName("fish")); assertTrue(wf.getProcessors().containsName("soup")); }