@SuppressWarnings("unchecked") @Override public int compareTo(Object o) { if (!(o instanceof BlockingControlLink)) return o.getClass().getCanonicalName() .compareTo(getClass().getCanonicalName()); BlockingControlLink o1 = this; BlockingControlLink o2 = (BlockingControlLink) o; int untilFinishedCompare = nullSafeCompare.compare( o1.getUntilFinished(), o2.getUntilFinished()); if (untilFinishedCompare != 0) return untilFinishedCompare; return nullSafeCompare.compare(o1.getBlock(), o2.getBlock()); }
@SuppressWarnings("unchecked") public List<BlockingControlLink> controlLinksBlocking(Processor blocked) { List<BlockingControlLink> controlLinks = new ArrayList<>(); for (ControlLink link : blocked.getParent().getControlLinks()) { if (!(link instanceof BlockingControlLink)) continue; BlockingControlLink blockingControlLink = (BlockingControlLink) link; if (blockingControlLink.getBlock().equals(blocked)) controlLinks.add(blockingControlLink); } Collections.sort(controlLinks); return controlLinks; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (getUntilFinished() == null ? 0 : getUntilFinished() .hashCode()); result = prime * result + (parent == null ? 0 : parent.hashCode()); result = prime * result + (getBlock() == null ? 0 : getBlock().hashCode()); return result; }
List<BlockingControlLink> controlledConditions = controlLinksWaitingFor(processor); for (BlockingControlLink condition : controlledConditions) { Processor downstreamProc = condition.getBlock(); if (!downStream.contains(downstreamProc)) { downStream.add(downstreamProc);
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BlockingControlLink other = (BlockingControlLink) obj; if (getUntilFinished() == null) { if (other.getUntilFinished() != null) return false; } else if (!getUntilFinished().equals(other.getUntilFinished())) return false; if (getParent() == null) { if (other.getParent() != null) return false; } else if (!getParent().equals(other.getParent())) return false; if (getBlock() == null) { if (other.getBlock() != null) return false; } else if (!getBlock().equals(other.getBlock())) return false; return true; }
@Override protected void cloneInto(WorkflowBean clone, Cloning cloning) { BlockingControlLink cloneLink = (BlockingControlLink) clone; cloneLink.setBlock(cloning.cloneOrOriginal(getBlock())); cloneLink.setUntilFinished(cloning.cloneOrOriginal(getUntilFinished())); }
uriForBean(runAfterCondition.getBlock())); URI after = relativePath(wfUri, uriForBean(runAfterCondition.getUntilFinished()));
@Override public void visitBlockingControlLink(BlockingControlLink bean) { // Also checks from Child Workflow parent = bean.getParent(); Processor block = bean.getBlock(); Processor untilFinished = bean.getUntilFinished(); // Check the block and untilFinished processors are in the same workflow if (block != null) { Workflow blockParent = block.getParent(); if ((parent == null) || !parent.equals(blockParent)) listener.outOfScopeValue(bean, "block", block); } if (untilFinished != null) { Workflow untilFinishedParent = untilFinished.getParent(); if ((parent == null) || !parent.equals(untilFinishedParent)) listener.outOfScopeValue(bean, "untilFinished", untilFinished); } // Check the block and untilFinished processors are specified if (checkComplete) { if (block == null) listener.nullField(bean, "block"); if (untilFinished == null) listener.nullField(bean, "untilFinished"); } }
@Test public void readControlLinks() throws Exception { URL wfResource = getClass().getResource(SLEEPERS_T2FLOW); assertNotNull("Could not find workflow " + SLEEPERS_T2FLOW, wfResource); T2FlowParser parser = new T2FlowParser(); parser.setStrict(true); WorkflowBundle bundle = parser.parseT2Flow(wfResource.openStream()); Workflow mainWorkflow = bundle.getMainWorkflow(); NamedSet<Processor> processors = mainWorkflow.getProcessors(); assertEquals(4, mainWorkflow.getControlLinks().size()); List<BlockingControlLink> blocking2 = scufl2Tools.controlLinksBlocking(processors.getByName("second_sleeper")); assertEquals(1, blocking2.size()); assertEquals("first_sleeper", blocking2.get(0).getUntilFinished().getName()); List<BlockingControlLink> waiting2 = scufl2Tools.controlLinksWaitingFor(processors.getByName("second_sleeper")); assertEquals(1, waiting2.size()); assertEquals("third_sleeper", waiting2.get(0).getBlock().getName()); List<BlockingControlLink> blocking3 = scufl2Tools.controlLinksBlocking(processors.getByName("third_sleeper")); assertEquals(2, blocking3.size()); assertEquals("second_sleeper", blocking3.get(0).getUntilFinished().getName()); assertEquals("second_sleeper_2", blocking3.get(1).getUntilFinished().getName()); }
BlockingControlLink controlLink = (BlockingControlLink) node; URI blockUri = uriTools.relativeUriForBean( controlLink.getBlock(), wf); URI untilUri = uriTools.relativeUriForBean( controlLink.getUntilFinished(), wf);
newLine(3); append("block"); append(blockingControlLink.getBlock()); append(" until"); append(blockingControlLink.getUntilFinished());