/**
* Percent complete is calculated based on assignments
*/
public double getPercentComplete() {
boolean parent = isWbsParent();
DivisionSummaryVisitor divisionClosure = ScheduleUtil.percentCompleteClosureInstance(parent);
Project proj = (Project) (getMasterDocument() == null ? getProject() : getMasterDocument());
NodeModel nodeModel = proj.getTaskOutline();
if (isWbsParent()) {
try {
LeafWalker.recursivelyTreatBranch(nodeModel,this, divisionClosure);
} catch (NullPointerException n ){
ErrorLogger.logOnce("getPercentComplete","getPercentComplete() Task: " + this + " Project " + project,n);
return 0; // better this than crashing
}
} else {
CollectionUtils.forAllDo(((NormalTask)this).getAssignments(),divisionClosure);
}
double val = divisionClosure.getValue();
if (val >=COMPLETE_THRESHOLD) // adjust for rounding
val = 1.0D;
return val;
}