final Collection<BasicOperator> added) {
if (clone instanceof Union) {
for (final BasicOperator toCloneNew : toClone
.getPrecedingOperators()) {
final BasicOperator cloneNew = toCloneNew.clone();
final OperatorIDTuple oid = toCloneNew
.getOperatorIDTuple(toClone);
cloneNew.removeSucceedingOperator(toClone);
// try {
cloneNew.addSucceedingOperator(new OperatorIDTuple(clone, oid
.getId()));
// } catch (final Exception e) {
// System.out.println("2");
// }
clone.removePrecedingOperator(toCloneNew);
clone.addPrecedingOperator(cloneNew);
added.add(cloneNew);
cloneFurther(cloneNew, toCloneNew, added);
}
} else {
// if (toClone instanceof TriplePattern)
// System.out.println();
while (toClone.getPrecedingOperators().size() == 1
&& !(toClone instanceof PatternMatcher
|| toClone instanceof Root || toClone
.getPrecedingOperators().get(0) instanceof TriggerOneTime)) {
final BasicOperator toCloneNew = toClone
.getPrecedingOperators().get(0);
final BasicOperator cloneNew = (toCloneNew instanceof PatternMatcher || toCloneNew instanceof Root) ? toCloneNew
: toCloneNew.clone();
final OperatorIDTuple oidOld = toClone.getPrecedingOperators()
.get(0).getOperatorIDTuple(toClone);
cloneNew.replaceOperatorIDTuple(oidOld, new OperatorIDTuple(
clone, toCloneNew.getSucceedingOperators().get(0)
.getId()));
clone.setPrecedingOperator(cloneNew);
clone = cloneNew;
toClone = toCloneNew;
if (!(toCloneNew instanceof PatternMatcher || toCloneNew instanceof Root))
added.add(cloneNew);
}
if (!(clone instanceof PatternMatcher || clone instanceof Root))
for (final BasicOperator bo : toClone.getPrecedingOperators()) {
final int id2 = bo.getOperatorIDTuple(toClone).getId();
bo.addSucceedingOperator(new OperatorIDTuple(clone, id2));
clone.addPrecedingOperator(bo);
}
}
}