Mercurial > lada > lada-server
changeset 192:0ae1ee3d8db3
New service interface to delete a 'zusatzwert'.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 01 Jul 2013 14:18:16 +0200 |
parents | 253160854d79 |
children | 7f97c469faf0 |
files | src/main/java/de/intevation/lada/rest/LZusatzwertService.java |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/LZusatzwertService.java Mon Jul 01 14:17:33 2013 +0200 +++ b/src/main/java/de/intevation/lada/rest/LZusatzwertService.java Mon Jul 01 14:18:16 2013 +0200 @@ -1,11 +1,13 @@ package de.intevation.lada.rest; import java.util.ArrayList; +import java.util.List; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; @@ -87,4 +89,23 @@ public Response create(LZusatzWert zusatzwert) { return repository.create(zusatzwert); } + + @DELETE + @Path("/{pzsId}/{probeId}") + public Response delete( + @PathParam("pzsId") String pzsId, + @PathParam("probeId") String probeId ) { + QueryBuilder<LZusatzWert> builder = + new QueryBuilder<LZusatzWert>( + repository.getEntityManager(), + LZusatzWert.class); + builder.and("pzsId", pzsId).and("probeId", probeId); + Response response = repository.filter(builder.getQuery()); + List<LZusatzWert> list = (List<LZusatzWert>)response.getData(); + if (!list.isEmpty()) { + repository.delete(list.get(0)); + return new Response(true, 200, null); + } + return new Response(false, 600, null); + } }