Sort timesheet entries descending by date in bound users service

FEA: ItEr77S14BoundUsersWebServices
This commit is contained in:
Manuel Rego Casasnovas 2012-11-15 08:17:06 +01:00
parent e7aec7ccd3
commit 3542769a35

View file

@ -19,6 +19,7 @@
package org.libreplan.ws.boundusers.impl; package org.libreplan.ws.boundusers.impl;
import java.util.Collections;
import java.util.List; import java.util.List;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@ -87,6 +88,7 @@ public class BoundUserServiceREST implements IBoundUserService {
@GET @GET
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Path("/timesheets/{task-code}/") @Path("/timesheets/{task-code}/")
@SuppressWarnings("unchecked")
public Response getTimesheetEntriesByTask( public Response getTimesheetEntriesByTask(
@PathParam("task-code") String taskCode) { @PathParam("task-code") String taskCode) {
try { try {
@ -96,7 +98,8 @@ public class BoundUserServiceREST implements IBoundUserService {
.getBoundResourceFromSession()); .getBoundResourceFromSession());
List<WorkReportLine> workReportLines = workReportLineDAO List<WorkReportLine> workReportLines = workReportLineDAO
.findByOrderElementAndWorkReports(orderElement, workReports); .findByOrderElementAndWorkReports(orderElement, workReports);
Collections.sort(workReportLines);
Collections.reverse(workReportLines);
PersonalTimesheetEntryListDTO dto = PersonalTimesheetEntryConverter PersonalTimesheetEntryListDTO dto = PersonalTimesheetEntryConverter
.toDTO(workReportLines); .toDTO(workReportLines);
return Response.ok(dto).build(); return Response.ok(dto).build();