changeset 24:dc3bfcc5f717

Added functions to delete and create (stub) proben items. Currently are not working because of violations of foreign key constraits in the underlying database scheme.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 26 Apr 2013 18:06:21 +0200
parents 00ed8e5b05b6
children 34d7ecfba8d1
files src/main/java/de/intevation/data/LProbeRepository.java src/main/java/de/intevation/rest/LProbeRESTService.java src/main/java/de/intevation/service/LProbeService.java
diffstat 3 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/data/LProbeRepository.java	Fri Apr 26 15:02:05 2013 +0200
+++ b/src/main/java/de/intevation/data/LProbeRepository.java	Fri Apr 26 18:06:21 2013 +0200
@@ -16,6 +16,9 @@
  */
 package de.intevation.data;
 
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+
 import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Inject;
 import javax.persistence.EntityManager;
@@ -25,12 +28,16 @@
 import java.util.List;
 
 import de.intevation.model.LProbe;
+import de.intevation.service.LProbeService;
 
 @ApplicationScoped
 public class LProbeRepository {
 
     @Inject
     private EntityManager em;
+    
+    @Inject
+    private LProbeService service;
 
     public LProbe findById(Long id) {
         return em.find(LProbe.class, id);
@@ -38,7 +45,12 @@
     
     
     public void delete(LProbe item) {
-        em.remove(item);
+    	try {
+			service.delete(item.getProbeId());
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
     }
 
     //public LProbe findByEmail(String email) {
--- a/src/main/java/de/intevation/rest/LProbeRESTService.java	Fri Apr 26 15:02:05 2013 +0200
+++ b/src/main/java/de/intevation/rest/LProbeRESTService.java	Fri Apr 26 18:06:21 2013 +0200
@@ -11,6 +11,7 @@
 
 import de.intevation.data.LProbeRepository;
 import de.intevation.model.LProbe;
+import de.intevation.service.LProbeService;
 
 /**
  * JAX-RS Example
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/service/LProbeService.java	Fri Apr 26 18:06:21 2013 +0200
@@ -0,0 +1,32 @@
+package de.intevation.service;
+
+import java.util.logging.Logger;
+
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+import de.intevation.model.LProbe;
+
+@Stateless
+public class LProbeService {
+
+    @Inject
+    private Logger log;
+
+    @Inject
+    private EntityManager em;
+
+//    @Inject
+//    private Event<Member> memberEventSrc;
+
+    @TransactionAttribute(TransactionAttributeType.REQUIRED)
+    public void delete(String id) throws Exception {
+    	LProbe probe = em.find(LProbe.class, id);
+        log.info("Deleting " + probe.getProbeId());
+        em.remove(probe);
+        //memberEventSrc.fire(member);
+    }
+}
\ No newline at end of file
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)