sortAlgorithm.sortTasksByStartDate(nestedTasks);
Set modifiedTasks = new HashSet();
for (int i=0; i<nestedTasks.size(); i++) {
Task nextNested = (Task) nestedTasks.get(i);
if (nextNested.getStart().getTime().before(supertask.getStart().getTime())) {
TaskMutator mutator = nextNested.createMutatorFixingDuration();
mutator.setStart(supertask.getStart());
mutator.commit();
//
modifiedTasks.add(nextNested);
}
if (nextNested.getEnd().getTime().after(supertask.getEnd().getTime())) {
TaskMutator mutator = nextNested.createMutatorFixingDuration();
mutator.shift(supertask.getManager().createLength(supertask.getDuration().getTimeUnit(), nextNested.getEnd().getTime(), supertask.getEnd().getTime()));
mutator.commit();
//
modifiedTasks.add(nextNested);
}
}
run((Task[])modifiedTasks.toArray(new Task[0]));