changeset 65:8078fde8b02b

Persist a new LProbe using the LProbeValidator.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 31 May 2013 14:02:45 +0200
parents 132eca870434
children 54ff6ded05b2
files src/main/java/de/intevation/lada/manage/LProbeManager.java
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/manage/LProbeManager.java	Fri May 31 14:00:25 2013 +0200
+++ b/src/main/java/de/intevation/lada/manage/LProbeManager.java	Fri May 31 14:02:45 2013 +0200
@@ -1,14 +1,20 @@
 package de.intevation.lada.manage;
 
+import java.util.Map;
 import java.util.logging.Logger;
 
 import javax.ejb.Stateless;
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
 import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.EntityExistsException;
 import javax.persistence.EntityManager;
+import javax.persistence.TransactionRequiredException;
 
 import de.intevation.lada.model.LProbe;
+import de.intevation.lada.validation.ValidationException;
+import de.intevation.lada.validation.Validator;
 
 @Stateless
 public class LProbeManager {
@@ -19,10 +25,34 @@
     @Inject
     private EntityManager em;
 
+    @Inject
+    @Named("lprobevalidator")
+    private Validator validator;
+
+    /**
+     * Delete a LProbe object by id.
+     * 
+     * @param id
+     * @throws Exception
+     */
     @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);
     }
+
+    @TransactionAttribute(TransactionAttributeType.REQUIRED)
+    public void create(LProbe probe)
+    throws EntityExistsException,
+        IllegalArgumentException,
+        TransactionRequiredException,
+        ValidationException {
+        validator.validate(probe);
+        em.persist(probe);
+    }
+
+    public Map<String, Integer> getWarnings() {
+        return validator.getWarnings();
+    }
 }
\ No newline at end of file
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)