changeset 23:00ed8e5b05b6

Added functions to Rest-Service to add and delete a item
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 26 Apr 2013 15:02:05 +0200
parents c19770952a6e
children dc3bfcc5f717
files src/main/java/de/intevation/data/LProbeRepository.java src/main/java/de/intevation/rest/LProbeRESTService.java
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/data/LProbeRepository.java	Fri Apr 26 15:00:56 2013 +0200
+++ b/src/main/java/de/intevation/data/LProbeRepository.java	Fri Apr 26 15:02:05 2013 +0200
@@ -35,6 +35,11 @@
     public LProbe findById(Long id) {
         return em.find(LProbe.class, id);
     }
+    
+    
+    public void delete(LProbe item) {
+        em.remove(item);
+    }
 
     //public LProbe findByEmail(String email) {
     //    CriteriaBuilder cb = em.getCriteriaBuilder();
--- a/src/main/java/de/intevation/rest/LProbeRESTService.java	Fri Apr 26 15:00:56 2013 +0200
+++ b/src/main/java/de/intevation/rest/LProbeRESTService.java	Fri Apr 26 15:02:05 2013 +0200
@@ -41,7 +41,23 @@
    public String loadById() {
       return "Eine Probe!";
    }
+   
+   @GET
+   @Path("/deleteLast")
+   @Produces("text/plain")
+   public String deleteLast() {
+	   final List<LProbe> result = repository.findAll();
+	   LProbe last_element = result.get(result.size()-1);
+	   repository.delete(last_element);
+	   return "Gelöscht id" + last_element.getProbeId();
+   }
 
+   @GET
+   @Path("/new")
+   @Produces("text/plain")
+   public String create() {
+      return "Neu";
+   }
    //@GET
    //@Produces("text/xml")
    //public List<Member> listAllMembers() {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)