// Calculate missing attributes
//
ProjectCalendar calendar = m_projectFile.getCalendar();
if (calendar != null)
{
Duration duration = calendar.getWork(mpxjTask.getStart(), mpxjTask.getFinish(), TimeUnit.HOURS);
double durationDays = duration.getDuration() / 8;
if (durationDays > 0)
{
duration = Duration.getInstance(durationDays, TimeUnit.DAYS);
}
mpxjTask.setDuration(duration);
if (percentComplete.intValue() != 0)
{
mpxjTask.setActualStart(mpxjTask.getStart());
if (percentComplete.intValue() == 100)
{
mpxjTask.setActualFinish(mpxjTask.getFinish());
mpxjTask.setActualDuration(duration);
mpxjTask.setActualWork(mpxjTask.getWork());
mpxjTask.setRemainingWork(Duration.getInstance(0, TimeUnit.HOURS));
}
else
{
Duration work = mpxjTask.getWork();
Duration actualWork = Duration.getInstance((work.getDuration() * percentComplete.doubleValue()) / 100.0d, work.getUnits());
mpxjTask.setActualDuration(Duration.getInstance((duration.getDuration() * percentComplete.doubleValue()) / 100.0d, duration.getUnits()));
mpxjTask.setActualWork(actualWork);
mpxjTask.setRemainingWork(Duration.getInstance(work.getDuration() - actualWork.getDuration(), work.getUnits()));
}
}
}
mpxjTask.setEffortDriven(true);