int blockCount = MPPUtility.getShort(data, 0);
if (blockCount == 0)
{
if (!timephasedComplete.isEmpty() && units != 0)
{
TimephasedWork lastComplete = timephasedComplete.get(timephasedComplete.size() - 1);
Date startWork = calendar.getNextWorkStart(lastComplete.getFinish());
double time = MPPUtility.getDouble(data, 16);
time /= 1000;
Duration totalWork = Duration.getInstance(time, TimeUnit.MINUTES);
Duration adjustedTotalWork = Duration.getInstance((time * 100) / units, TimeUnit.MINUTES);
Date finish = calendar.getDate(startWork, adjustedTotalWork, false);
time = MPPUtility.getDouble(data, 8);
time /= 2000;
time *= 6;
Duration workPerDay = Duration.getInstance(time, TimeUnit.MINUTES);
TimephasedWork assignment = new TimephasedWork();
assignment.setStart(startWork);
assignment.setAmountPerDay(workPerDay);
assignment.setModified(false);
assignment.setFinish(finish);
assignment.setTotalAmount(totalWork);
if (assignment.getStart().getTime() != assignment.getFinish().getTime())
{
list.add(assignment);
}
}
}
else
{
Date offset = startDate;
if (!timephasedComplete.isEmpty())
{
TimephasedWork lastComplete = timephasedComplete.get(timephasedComplete.size() - 1);
offset = lastComplete.getFinish();
}
int index = 40;
double previousCumulativeWork = 0;
TimephasedWork previousAssignment = null;
int currentBlock = 0;
while (currentBlock < blockCount && index + 28 <= data.length)
{
double time = MPPUtility.getInt(data, index);
time /= 80;
Duration blockDuration = Duration.getInstance(time, TimeUnit.MINUTES);
Date start;
if (blockDuration.getDuration() == 0)
{
start = offset;
}
else
{
start = calendar.getDate(offset, blockDuration, true);
}
double currentCumulativeWork = MPPUtility.getDouble(data, index + 4);
double assignmentDuration = currentCumulativeWork - previousCumulativeWork;
assignmentDuration /= 1000;
Duration totalWork = Duration.getInstance(assignmentDuration, TimeUnit.MINUTES);
previousCumulativeWork = currentCumulativeWork;
time = MPPUtility.getDouble(data, index + 12);
time /= 2000;
time *= 6;
Duration workPerDay = Duration.getInstance(time, TimeUnit.MINUTES);
int modifiedFlag = MPPUtility.getShort(data, index + 22);
boolean modified = (modifiedFlag == 0 && currentBlock != 0) || ((modifiedFlag & 0x3000) != 0);
TimephasedWork assignment = new TimephasedWork();
assignment.setStart(start);
assignment.setAmountPerDay(workPerDay);
assignment.setModified(modified);
assignment.setTotalAmount(totalWork);
if (previousAssignment != null)
{
Date finish = calendar.getDate(offset, blockDuration, false);
previousAssignment.setFinish(finish);