From 8509515e75511e54b726b917a497dc517c6086d1 Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Mon, 27 Aug 2012 11:42:10 +0200 Subject: [PATCH] Add new method to delete a work report from the web service FEA: ItEr77S06AllowDeleteWorkReports --- .../workreports/api/IWorkReportService.java | 4 ++- .../impl/WorkReportServiceREST.java | 20 +++++++++++ ...ibreplan-webapp-spring-security-config.xml | 3 ++ scripts/rest-clients/remove-work-report.sh | 34 +++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 scripts/rest-clients/remove-work-report.sh diff --git a/libreplan-webapp/src/main/java/org/libreplan/ws/workreports/api/IWorkReportService.java b/libreplan-webapp/src/main/java/org/libreplan/ws/workreports/api/IWorkReportService.java index 059c51447..ffd63a90f 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/ws/workreports/api/IWorkReportService.java +++ b/libreplan-webapp/src/main/java/org/libreplan/ws/workreports/api/IWorkReportService.java @@ -3,7 +3,7 @@ * * Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e * Desenvolvemento Tecnolóxico de Galicia - * Copyright (C) 2010-2011 Igalia, S.L. + * Copyright (C) 2010-2012 Igalia, S.L. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -39,4 +39,6 @@ public interface IWorkReportService { public Response getWorkReport(String code); + Response removeWorkReport(String code); + } \ No newline at end of file diff --git a/libreplan-webapp/src/main/java/org/libreplan/ws/workreports/impl/WorkReportServiceREST.java b/libreplan-webapp/src/main/java/org/libreplan/ws/workreports/impl/WorkReportServiceREST.java index 6891408de..2338ba65b 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/ws/workreports/impl/WorkReportServiceREST.java +++ b/libreplan-webapp/src/main/java/org/libreplan/ws/workreports/impl/WorkReportServiceREST.java @@ -22,12 +22,14 @@ package org.libreplan.ws.workreports.impl; import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; import org.libreplan.business.common.daos.IIntegrationEntityDAO; import org.libreplan.business.common.exceptions.InstanceNotFoundException; @@ -122,4 +124,22 @@ public class WorkReportServiceREST extends public Response getWorkReport(@PathParam("code") String code) { return getDTOByCode(code); } + + @Override + @DELETE + @Path("/{code}/") + @Transactional + public Response removeWorkReport(@PathParam("code") String code) { + try { + WorkReport workReport = workReportDAO.findByCode(code); + sumChargedEffortDAO + .updateRelatedSumChargedEffortWithDeletedWorkReportLineSet(workReport + .getWorkReportLines()); + workReportDAO.remove(workReport.getId()); + return Response.ok().build(); + } catch (InstanceNotFoundException e) { + return Response.status(Status.NOT_FOUND).build(); + } + } + } \ No newline at end of file diff --git a/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml b/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml index 0349da62f..457f0deaa 100644 --- a/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml +++ b/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml @@ -25,6 +25,9 @@ + /dev/null; then + echo $result | tidy -xml -i -q -utf8 +else + echo $result +fi