in taverna-workflowmodel-impl/src/main/java/org/apache/taverna/workflowmodel/processor/iteration/impl/IterationStrategyImpl.java [307:342]
public void normalize() {
boolean finished = false;
do {
finished = true;
@SuppressWarnings("unchecked")
Enumeration<AbstractIterationStrategyNode> e = getTerminalNode()
.breadthFirstEnumeration();
while (e.hasMoreElements() && finished == true) {
AbstractIterationStrategyNode n = e.nextElement();
AbstractIterationStrategyNode parent = (AbstractIterationStrategyNode) n
.getParent();
// Check whether anything needs doing
// Check for collation nodes with no children
if (!(n instanceof NamedInputPortNode) && parent != null
&& n.getChildCount() == 0) {
// Remove the node from its parent and set finished to false
parent.remove(n);
finished = false;
} else if (!(n.isLeaf()) && parent != null
&& n.getChildCount() == 1) {
/*
* Is a collation node with a single child, and therefore
* pointless. Replace it with the child node
*/
AbstractIterationStrategyNode child = (AbstractIterationStrategyNode) n
.getChildAt(0);
// Find the index of the collation node in its parent
int oldIndex = parent.getIndex(n);
parent.remove(n);
parent.insert(child, oldIndex);
finished = false;
}
}
} while (!finished);
}