*/
private void mergeSameDay(ProjectCalendar calendar, LinkedList<TimephasedWork> list)
{
LinkedList<TimephasedWork> result = new LinkedList<TimephasedWork>();
TimephasedWork previousAssignment = null;
for (TimephasedWork assignment : list)
{
if (previousAssignment == null)
{
assignment.setAmountPerDay(assignment.getTotalAmount());
result.add(assignment);
}
else
{
Date previousAssignmentStart = previousAssignment.getStart();
Date previousAssignmentStartDay = DateUtility.getDayStartDate(previousAssignmentStart);
Date assignmentStart = assignment.getStart();
Date assignmentStartDay = DateUtility.getDayStartDate(assignmentStart);
if (previousAssignmentStartDay.getTime() == assignmentStartDay.getTime())
{
Duration previousAssignmentWork = previousAssignment.getTotalAmount();
Duration assignmentWork = assignment.getTotalAmount();
if (previousAssignmentWork.getDuration() != 0 && assignmentWork.getDuration() == 0)
{
continue;
}
result.removeLast();
if (previousAssignmentWork.getDuration() != 0 && assignmentWork.getDuration() != 0)
{
double work = previousAssignment.getTotalAmount().getDuration();
work += assignment.getTotalAmount().getDuration();
Duration totalWork = Duration.getInstance(work, TimeUnit.MINUTES);
TimephasedWork merged = new TimephasedWork();
merged.setStart(previousAssignment.getStart());
merged.setFinish(assignment.getFinish());
merged.setTotalAmount(totalWork);
assignment = merged;
}
else
{
if (assignmentWork.getDuration() == 0)