if (unopenedSubproject) { // need to put back old dates because we want the reverse pass to work right
newBegin = oldBegin;
newEnd = oldEnd;
}
Collection list = task.getDependencyList(!forward);
Task parent = task.getWbsParentTask();
TaskSchedule parentSchedule = null;
long parentEnd = 0;
if (parent != null) {
parentSchedule = parent.getSchedule(type);
parentEnd = parentSchedule.getEnd();
}
if (context.taskReferenceType == PredecessorTaskList.TaskReference.PARENT_BEGIN) {
if (oldBegin != newBegin) { // if parent start (finish) changed, then all of its children need to me marked
flagChildren();
setDependencyDate(newBegin); //This fixes a problem in incorrect propagation of constraints to children hk 16/8/05
// make sure that in second pass over this, the schedule will change so it will be marked in backward pass. However, we don't want to lose
// information - specificially whether this task affects its parent's task. In case it does, it is marked with a special value (Dependency.NEEDS_CALCULATION)
// This is a bit of a hack, but it's for optimization purposes.
if (parentEnd == oldEnd)
setEnd(needsCalculation);
else
setEnd(0);
}
return;
}
Dependency dependency;
if (list.isEmpty()) {
if (!task.isExternal() && task != context.sentinel) { // When the task is the sentinel, do nothing, otherwise find dependency and update it
dependency = (Dependency) context.sentinel.getDependencyList(forward).find(forward,task); // find sentinel's dependency concerning this task
if (dependency != null) { // tasks in a subproject won't have a sentinel dependency
dependency.calcDependencyDate(forward,newBegin,newEnd,false); // calculate it to store off value
context.sentinel.setCalculationStateCount(context.stateCount); // need to process successor(predecessor) later on in pass
context.sentinel.getSchedule(type).setDependencyDate(needsCalculation); //sentinel needs dependencies calculated - I assume more than one
}
}
} else {
// Go Thru Successors (Predecessors) and calculate a dependency date for them and mark them for further treatment. There is an optimization here:
// If the successor(pred) task only has one predecessor(succ), then just set its dependency date instead of calculating it. This avoids reprocessing
// the predecessor(successor) list of that task later on. Since in most cases, a task has only one predecessor, this saves time.
for (Iterator d = list.iterator(); d.hasNext();) {
Task dependencyTask;
TaskSchedule dependencyTaskSchedule;
dependency = (Dependency) d.next();
if (dependency.isDisabled())
continue;
dependencyTask = (Task) dependency.getTask(!forward); // get the successor(pred) task
dependencyTaskSchedule = dependencyTask.getSchedule(type);
// if this task is the only predecessor(successor) for the successor(predecessor) task, avoid long calculation and just calculate the date, otherwise
// flag the task for later calculation
long dependencyCount = dependencyTask.getDependencyList(forward).size();
long dep = newBegin; // by default (if no preds for example)
if (dependencyCount > 0) {
boolean useSooner = !dependencyTask.isWbsParent() && dependencyTask.hasDuration();
dep = dependency.calcDependencyDate(forward,newBegin,newEnd,useSooner); // calculate it and store off value
if (dependencyCount > 1) // can't just set date directly because more than one
dep = needsCalculation; // it will need to be calculated later
}
dependencyTaskSchedule.setDependencyDate(dep);
dependencyTask.setCalculationStateCount(context.stateCount); // need to process successor(predecessor) later on in pass
}
}
// mark parent also if it is affected and isn't marked already
if (parent != null && parent.getCalculationStateCount() != context.stateCount) {