Add method to remove a work report line from the web service
FEA: ItEr77S06AllowDeleteWorkReports
This commit is contained in:
parent
8509515e75
commit
1a973577e3
3 changed files with 61 additions and 0 deletions
|
|
@ -41,4 +41,6 @@ public interface IWorkReportService {
|
|||
|
||||
Response removeWorkReport(String code);
|
||||
|
||||
Response removeWorkReportLine(String code);
|
||||
|
||||
}
|
||||
|
|
@ -21,6 +21,9 @@
|
|||
|
||||
package org.libreplan.ws.workreports.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
|
|
@ -37,7 +40,9 @@ import org.libreplan.business.common.exceptions.ValidationException;
|
|||
import org.libreplan.business.orders.daos.IOrderElementDAO;
|
||||
import org.libreplan.business.orders.daos.ISumChargedEffortDAO;
|
||||
import org.libreplan.business.workreports.daos.IWorkReportDAO;
|
||||
import org.libreplan.business.workreports.daos.IWorkReportLineDAO;
|
||||
import org.libreplan.business.workreports.entities.WorkReport;
|
||||
import org.libreplan.business.workreports.entities.WorkReportLine;
|
||||
import org.libreplan.ws.common.api.InstanceConstraintViolationsListDTO;
|
||||
import org.libreplan.ws.common.impl.GenericRESTService;
|
||||
import org.libreplan.ws.workreports.api.IWorkReportService;
|
||||
|
|
@ -62,6 +67,9 @@ public class WorkReportServiceREST extends
|
|||
@Autowired
|
||||
private IWorkReportDAO workReportDAO;
|
||||
|
||||
@Autowired
|
||||
private IWorkReportLineDAO workReportLineDAO;
|
||||
|
||||
@Autowired
|
||||
private IOrderElementDAO orderElementDAO;
|
||||
|
||||
|
|
@ -142,4 +150,21 @@ public class WorkReportServiceREST extends
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DELETE
|
||||
@Path("/line/{code}/")
|
||||
@Transactional
|
||||
public Response removeWorkReportLine(@PathParam("code") String code) {
|
||||
try {
|
||||
WorkReportLine workReportLine = workReportLineDAO.findByCode(code);
|
||||
sumChargedEffortDAO
|
||||
.updateRelatedSumChargedEffortWithDeletedWorkReportLineSet(new HashSet<WorkReportLine>(
|
||||
Arrays.asList(workReportLine)));
|
||||
workReportLineDAO.remove(workReportLine.getId());
|
||||
return Response.ok().build();
|
||||
} catch (InstanceNotFoundException e) {
|
||||
return Response.status(Status.NOT_FOUND).build();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
34
scripts/rest-clients/remove-work-report-line.sh
Executable file
34
scripts/rest-clients/remove-work-report-line.sh
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ./rest-common-env.sh
|
||||
|
||||
printf "Username: "
|
||||
read loginName
|
||||
printf "Password: "
|
||||
read password
|
||||
|
||||
code=$1
|
||||
|
||||
if [ "$1" = "--prod" ]; then
|
||||
baseServiceURL=$PRODUCTION_BASE_SERVICE_URL
|
||||
certificate=$PRODUCTION_CERTIFICATE
|
||||
code=$2
|
||||
elif [ "$1" = "--dev" ]; then
|
||||
baseServiceURL=$DEVELOPMENT_BASE_SERVICE_URL
|
||||
certificate=$DEVELOPMENT_CERTIFICATE
|
||||
code=$2
|
||||
else
|
||||
baseServiceURL=$DEMO_BASE_SERVICE_URL
|
||||
certificate=$DEMO_CERTIFICATE
|
||||
fi
|
||||
|
||||
authorization=`echo -n "$loginName:$password" | base64`
|
||||
|
||||
result=`curl -sv -X DELETE $certificate --header "Authorization: Basic $authorization" \
|
||||
$baseServiceURL/workreports/line/$code`
|
||||
|
||||
if hash tidy &> /dev/null; then
|
||||
echo $result | tidy -xml -i -q -utf8
|
||||
else
|
||||
echo $result
|
||||
fi
|
||||
Loading…
Add table
Reference in a new issue