# HG changeset patch # User Raimund Renkert # Date 1372681096 -7200 # Node ID 0ae1ee3d8db3112018841229be78d7fa72c83f1e # Parent 253160854d794a1ff850ffa7281b8f12ecf0c594 New service interface to delete a 'zusatzwert'. diff -r 253160854d79 -r 0ae1ee3d8db3 src/main/java/de/intevation/lada/rest/LZusatzwertService.java --- 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 builder = + new QueryBuilder( + repository.getEntityManager(), + LZusatzWert.class); + builder.and("pzsId", pzsId).and("probeId", probeId); + Response response = repository.filter(builder.getQuery()); + List list = (List)response.getData(); + if (!list.isEmpty()) { + repository.delete(list.get(0)); + return new Response(true, 200, null); + } + return new Response(false, 600, null); + } }