/** * Constructs a <code>BlockingControlLink</code> with the specified blocked and control <code>Processor</code>s. * <p> * The parent {@link Workflow} is set to be the same as the parent of the block <code>Processor</code>. * * @param block * the <code>Processor</code> that is blocked from starting. <strong>Must * not</strong> be <code>null</code> * @param untilFinished * the <code>Processor</code> that controls the block. Can be <code>null</code>. */ public BlockingControlLink(Processor block, Processor untilFinished) { setUntilFinished(untilFinished); setBlock(block); setParent(block.getParent()); }
protected void parseControlLink(Blocking original) { URI blockUri = getParserState().getCurrentBase().resolve( original.getBlock().getResource()); URI untilFinishedUri = getParserState().getCurrentBase().resolve( original.getUntilFinished().getResource()); WorkflowBean block = resolveBeanUri(blockUri); WorkflowBean untilFinished = resolveBeanUri(untilFinishedUri); BlockingControlLink blocking = new BlockingControlLink(); blocking.setBlock((uk.org.taverna.scufl2.api.core.Processor) block); blocking.setUntilFinished((uk.org.taverna.scufl2.api.core.Processor) untilFinished); blocking.setParent(getParserState().getCurrent(Workflow.class)); mapBean(getParserState().getCurrentBase().resolve(original.getAbout()), blocking); }
BlockingControlLink null_blocks_c = new BlockingControlLink(); null_blocks_c.setBlock(c); null_blocks_c.setParent(wf); BlockingControlLink a_blocks_b = new BlockingControlLink(b, a); BlockingControlLink b_blocks_null = new BlockingControlLink(); b_blocks_null.setUntilFinished(b); b_blocks_null.setParent(wf); null_blocks_null.setParent(wf);
@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 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()); } }