changeset 103:ffb008cf7c77

Added method to update a probe
author Torsten Irländer <torsten.irlaender@intevation.de>
date Tue, 11 Jun 2013 13:06:31 +0200
parents 1c4a7c27c054
children ba35b1f642ec
files src/main/java/de/intevation/lada/data/LProbeRepository.java
diffstat 1 files changed, 34 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/data/LProbeRepository.java	Tue Jun 11 13:05:50 2013 +0200
+++ b/src/main/java/de/intevation/lada/data/LProbeRepository.java	Tue Jun 11 13:06:31 2013 +0200
@@ -94,7 +94,7 @@
      * Validate and persist a new LProbe object.
      *
      * @param probe The new LProbe object
-     * @return True on success, else returns false.
+     * @return Response.
      */
     public Response create(LProbe probe) {
         Response response = new Response(true, 200, probe);
@@ -130,4 +130,37 @@
         return response;
     }
 
+    public Response update(LProbe probe) {
+        Response response = new Response(true, 200, probe);
+        // Try to save the new LProbe.
+        try {
+            validator.validate(probe);
+            manager.update(probe);
+            response.setWarnings(validator.getWarnings());
+            return response;
+        }
+        catch (EntityExistsException eee) {
+            response.setSuccess(false);
+            response.setMessage(601);
+        }
+        catch (IllegalArgumentException iae) {
+            response.setSuccess(false);
+            response.setMessage(602);
+        }
+        catch (TransactionRequiredException tre) {
+            response.setSuccess(false);
+            response.setMessage(603);
+        }
+        catch (ValidationException ve) {
+            response.setSuccess(false);
+            response.setMessage(604);
+            response.setErrors(ve.getErrors());
+            response.setWarnings(validator.getWarnings());
+        }
+        catch (EJBTransactionRolledbackException te) {
+            response.setSuccess(false);
+            response.setMessage(604);
+        }
+        return response;
+    }
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)