本文整理汇总了Java中org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack类的典型用法代码示例。如果您正苦于以下问题:Java IterationStrategyStack类的具体用法?Java IterationStrategyStack怎么用?Java IterationStrategyStack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IterationStrategyStack类属于org.apache.taverna.scufl2.api.iterationstrategy包,在下文中一共展示了IterationStrategyStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addIterationStrategy
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
private void addIterationStrategy(Processor processor,
org.apache.taverna.workflowmodel.Processor dataflowProcessor)
throws EditException, InvalidWorkflowException {
// get the iteration strategy from the processor
org.apache.taverna.workflowmodel.processor.iteration.IterationStrategyStack dataflowIterationStrategyStack = dataflowProcessor
.getIterationStrategy();
// clear the iteration strategy
edits.getClearIterationStrategyStackEdit(dataflowIterationStrategyStack)
.doEdit();
IterationStrategyStack iterationStrategyStack = processor
.getIterationStrategyStack();
for (IterationStrategyTopNode iterationStrategyTopNode : iterationStrategyStack) {
// create iteration strategy
IterationStrategy dataflowIterationStrategy = edits
.createIterationStrategy();
// add iteration strategy to the stack
edits.getAddIterationStrategyEdit(dataflowIterationStrategyStack,
dataflowIterationStrategy).doEdit();
// add the node to the iteration strategy
addIterationStrategyNode(dataflowIterationStrategy,
dataflowIterationStrategy.getTerminalNode(),
iterationStrategyTopNode);
}
}
示例2: testStagedCombinationOfDot1
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
@Test
public void testStagedCombinationOfDot1() {
Processor p = new Processor();
IterationStrategyStack iss = new IterationStrategyStack(p);
iss.add(getDot(1, 1));
iss.add(getDot(0, 0));
StructuralValidator sv = new StructuralValidator();
sv.getValidatorState().setProcessor(p);
Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>();
tempDepths.put(a,2);
tempDepths.put(b,2);
assertEquals(Integer.valueOf(2), sv.calculateResultWrappingDepth(tempDepths));
}
示例3: testStagedCombinationOfDot2
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
@Test
public void testStagedCombinationOfDot2() {
Processor p = new Processor();
IterationStrategyStack iss = new IterationStrategyStack(p);
iss.add(getDot(1, 1));
iss.add(getDot(0, 0));
StructuralValidator sv = new StructuralValidator();
sv.getValidatorState().setProcessor(p);
Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>();
tempDepths.put(a,0);
tempDepths.put(b,0);
// Should pass because the single items (depth 0) are promoted to single
// item lists before being passed into the iteration system so are
// effectively both depth 1 going into the second stage which then
// iterates to produce an index array length of 1
assertEquals(Integer.valueOf(1), sv.calculateResultWrappingDepth(tempDepths));
}
示例4: testStagedCombinationOfDot3
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
@Test
public void testStagedCombinationOfDot3() {
Processor p = new Processor();
IterationStrategyStack iss = new IterationStrategyStack(p);
iss.add(getDot(1, 1));
iss.add(getDot(0, 0));
StructuralValidator sv = new StructuralValidator();
sv.getValidatorState().setProcessor(p);
Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>();
tempDepths.put(a,1);
tempDepths.put(b,0);
// Slightly strange superficially that this should work, but in fact
// what happens is that the first single item is lifted to a list before
// being passed to the iteration strategy. The result is that it's fine
// to match with the dot product against the other list as neither at
// this point have index arrays, then in the second stage both are lists
// to be iterated over and both have single length index arrays.
assertEquals(Integer.valueOf(1), sv.calculateResultWrappingDepth(tempDepths));
}
示例5: testStagedCombinationOfCross
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
@Test
public void testStagedCombinationOfCross() {
Processor p = new Processor();
IterationStrategyStack iss = new IterationStrategyStack(p);
iss.add(getCross(1, 1));
iss.add(getCross(0, 0));
StructuralValidator sv = new StructuralValidator();
sv.getValidatorState().setProcessor(p);
Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>();
tempDepths.put(a,2);
tempDepths.put(b,2);
assertEquals(Integer.valueOf(4), sv.calculateResultWrappingDepth(tempDepths));
}
示例6: testStagedCombinationOfDotAndCross
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
/**
* Test whether Paul's example of iterating with dot product then cross
* product can typecheck in a single staged iteration. This was an example
* where the user had two lists of folders (a1, a2, b1, b2, c1, c2) and
* wanted to compare all the contents of each 'a' folder with the other 'a'
* folder and so on, doing a dot match to only compare a1 and a2 then a
* cross product join within each pair to compare all contents of a1 with
* all contents of a2. This appears to work!
*/
@Test
public void testStagedCombinationOfDotAndCross() {
Processor p = new Processor();
IterationStrategyStack iss = new IterationStrategyStack(p);
iss.add(getDot(1, 1));
iss.add(getCross(0, 0));
StructuralValidator sv = new StructuralValidator();
sv.getValidatorState().setProcessor(p);
Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>();
tempDepths.put(a,2);
tempDepths.put(b,2);
assertEquals(Integer.valueOf(3), sv.calculateResultWrappingDepth(tempDepths));
}
示例7: testInScopeInputProcessorPort
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
@Test
public void testInScopeInputProcessorPort() {
Processor p = new Processor();
InputProcessorPort ipp = new InputProcessorPort();
ipp.setParent(p);
IterationStrategyStack iss = new IterationStrategyStack();
p.setIterationStrategyStack(iss);
CrossProduct cp = new CrossProduct();
iss.add(cp);
cp.setParent(iss);
PortNode pn = new PortNode();
pn.setInputProcessorPort(ipp);
cp.add(pn);
pn.setParent(cp);
CorrectnessValidator cv = new CorrectnessValidator();
ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener();
cv.checkCorrectness(pn, false, rcvl);
Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems();
assertEquals(Collections.EMPTY_SET, outOfScopeValueProblems);
}
示例8: parseIterationStrategyStack
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
protected IterationStrategyStack parseIterationStrategyStack(
org.apache.taverna.scufl2.xml.t2flow.jaxb.IterationStrategyStack originalStack)
throws ReaderException {
IterationStrategyStack newStack = new IterationStrategyStack();
for (TopIterationNode strategy : originalStack.getIteration()
.getStrategy()) {
IterationNode topNode = strategy.getCross();
if (topNode == null)
topNode = strategy.getDot();
if (topNode == null)
continue;
IterationNodeParent parent = (IterationNodeParent) topNode;
if (parent.getCrossOrDotOrPort().isEmpty())
continue;
try {
newStack.add((IterationStrategyTopNode) parseIterationStrategyNode(topNode));
} catch (ReaderException e) {
if (isStrict())
throw e;
logger.warning(e.getMessage());
}
}
return newStack;
}
示例9: cloneIterationStack
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
@Test
public void cloneIterationStack() throws Exception {
WorkflowBundleIO io = new WorkflowBundleIO();
WorkflowBundle wf = io.readBundle(getClass().getResource("/clone-error.wfbundle"), null);
Processor proc = wf.getMainWorkflow().getProcessors().getByName("Beanshell");
IterationStrategyStack stack = proc.getIterationStrategyStack();
IterationStrategyTopNode root = stack.get(0);
assertNotSame(stack, root);
assertNotEquals(stack, root);
System.out.println(stack);
System.out.println(root);
@SuppressWarnings("unused")
AbstractCloneable clone = wf.clone();
}
示例10: calculateResultWrappingDepth
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
Integer calculateResultWrappingDepth(
Map<InputProcessorPort, Integer> inputDepths) {
Processor p = validatorState.get().getProcessor();
IterationStrategyStack iss = p.getIterationStrategyStack();
if (iss == null) {
validatorState.get().getEventListener()
.missingIterationStrategyStack(p);
// validatorState.get().addMissingIterationStrategyStack(p);
validatorState.get().getEventListener().failedProcessorAdded(p);
// validatorState.get().failCurrentProcessor();
return null;
}
if (iss.isEmpty())
return 0;
IterationStrategyTopNode iterationStrategyTopNode = iss.get(0);
Integer depth = getIterationDepth(iterationStrategyTopNode, inputDepths);
if (depth == null)
return null;
IterationStrategyTopNode previousNode = iterationStrategyTopNode;
for (int index = 1; index < iss.size(); index++) {
/*
* Construct the input depths for the staged iteration strategies
* after the first one by looking at the previous iteration
* strategy's desired cardinalities on its input ports.
*/
Map<InputProcessorPort, Integer> stagedInputDepths = getDesiredCardinalities(previousNode);
iterationStrategyTopNode = iss.get(index);
Integer nodeDepth = getIterationDepth(iterationStrategyTopNode,
stagedInputDepths);
if (nodeDepth == null)
return null;
depth += nodeDepth;
previousNode = iterationStrategyTopNode;
}
return depth;
}
示例11: visitIterationStrategyStack
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
@Override
public void visitIterationStrategyStack(IterationStrategyStack bean) {
Processor parent = bean.getParent();
if (parent != null && checkComplete) {
Set<Port> mentionedPorts = new HashSet<>();
for (IterationStrategyTopNode node : bean)
mentionedPorts.addAll(getReferencedPorts(node));
NamedSet<InputProcessorPort> inputPorts = parent.getInputPorts();
if (inputPorts != null)
for (Port p : inputPorts)
if (!mentionedPorts.contains(p))
listener.portMissingFromIterationStrategyStack(p, bean);
}
}
示例12: createDefaultIterationStrategyStack
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
public void createDefaultIterationStrategyStack(Processor p) {
p.setIterationStrategyStack(new IterationStrategyStack());
CrossProduct crossProduct = new CrossProduct();
for (InputProcessorPort in : p.getInputPorts()) {
// As this is a NamedSet the above will always be in
// the same alphabetical order
// FIXME: What about different Locales?
crossProduct.add(new PortNode(crossProduct, in));
}
p.getIterationStrategyStack().add(crossProduct);
}
示例13: testSimpleIteration
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
@Test
public void testSimpleIteration() {
WorkflowBundle wb = new WorkflowBundle();
Workflow w = new Workflow();
wb.setMainWorkflow(w);
InputWorkflowPort a = new InputWorkflowPort(w, "a");
a.setDepth(1);
Processor p = new Processor(w, "p");
InputProcessorPort ipp = new InputProcessorPort(p, "in");
ipp.setDepth(0);
OutputProcessorPort opp = new OutputProcessorPort(p, "out");
opp.setDepth(3);
DataLink inLink = new DataLink(w, a, ipp);
IterationStrategyStack iss = new IterationStrategyStack(p);
CrossProduct cp = new CrossProduct();
iss.add(cp);
PortNode portNode = new PortNode(cp, ipp);
portNode.setDesiredDepth(0);
StructuralValidator sv = new StructuralValidator();
ReportStructuralValidationListener l = new ReportStructuralValidationListener();
sv.checkStructure(wb, l);
ValidatorState vs = sv.getValidatorState();
assertEquals(0, l.getIncompleteWorkflows().size());
assertEquals(Integer.valueOf(1), vs.getPortResolvedDepth(a));
assertEquals(Integer.valueOf(1), vs.getDataLinkResolvedDepth(inLink));
assertEquals(Integer.valueOf(1), vs.getPortResolvedDepth(ipp));
assertEquals(Integer.valueOf(4), vs.getPortResolvedDepth(opp));
}
示例14: testValidIterationStrategyStack
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
@Test
public void testValidIterationStrategyStack() {
Processor p = new Processor();
IterationStrategyStack iss = new IterationStrategyStack();
iss.setParent(p);
InputProcessorPort p1 = new InputProcessorPort();
p1.setParent(p);
InputProcessorPort p2 = new InputProcessorPort();
p2.setParent(p);
InputProcessorPort p3 = new InputProcessorPort();
p3.setParent(p);
CrossProduct cp = new CrossProduct();
PortNode pNode1 = new PortNode();
pNode1.setInputProcessorPort(p1);
cp.add(pNode1);
iss.add(cp);
DotProduct dp = new DotProduct();
PortNode pNode2 = new PortNode();
pNode2.setInputProcessorPort(p2);
PortNode pNode3 = new PortNode();
pNode3.setInputProcessorPort(p3);
dp.add(pNode2);
dp.add(pNode3);
iss.add(dp);
CorrectnessValidator cv = new CorrectnessValidator();
ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener();
cv.checkCorrectness(p, true, rcvl);
Set<PortMissingFromIterationStrategyStackProblem> problems = rcvl.getPortMissingFromIterationStrategyStackProblems();
assertEquals(Collections.EMPTY_SET, problems);
}
示例15: testOutOfScopeInputProcessorPort
import org.apache.taverna.scufl2.api.iterationstrategy.IterationStrategyStack; //导入依赖的package包/类
@Test
public void testOutOfScopeInputProcessorPort() {
Processor p = new Processor();
InputProcessorPort ipp = new InputProcessorPort();
// ipp.setParent(p);
IterationStrategyStack iss = new IterationStrategyStack();
p.setIterationStrategyStack(iss);
CrossProduct cp = new CrossProduct();
iss.add(cp);
cp.setParent(iss);
PortNode pn = new PortNode();
pn.setInputProcessorPort(ipp);
cp.add(pn);
pn.setParent(cp);
CorrectnessValidator cv = new CorrectnessValidator();
ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener();
cv.checkCorrectness(pn, false, rcvl);
Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems();
assertFalse(outOfScopeValueProblems.isEmpty());
boolean problem = false;
for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) {
if (nlp.getBean().equals(pn) && nlp.getFieldName().equals("inputProcessorPort") && nlp.getValue().equals(ipp)) {
problem = true;
}
}
assertTrue(problem);
}