List<WorkReportLineDTO> listWRL) {
List<WorkReportLineDTO> groupedByDateList = new ArrayList<WorkReportLineDTO>();
if (!listWRL.isEmpty()) {
Iterator<WorkReportLineDTO> iterador = listWRL.iterator();
WorkReportLineDTO currentWRL = iterador.next();
groupedByDateList.add(currentWRL);
while (iterador.hasNext()) {
WorkReportLineDTO nextWRL = iterador.next();
LocalDate currentDate = currentWRL.getLocalDate();
LocalDate nextDate = nextWRL.getLocalDate();
if ((currentWRL.getResource().getId().equals(nextWRL
.getResource().getId()))
&& (currentWRL.getTypeOfWorkHours().getId()
.equals(nextWRL.getTypeOfWorkHours().getId()))
&& (currentDate.compareTo(nextDate) == 0)) {
// sum the number of hours to the next WorkReportLineDTO
currentWRL.setSumEffort(currentWRL.getSumEffort().plus(
nextWRL.getSumEffort()));
} else {
groupedByDateList.add(nextWRL);
currentWRL = nextWRL;
}
}