changeset 657:a8909085dae6

New REST interface to create probe objects from messprogramm.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 12 May 2015 15:18:47 +0200
parents 866d05db7a6a
children 55af47529ebd
files src/main/java/de/intevation/lada/rest/ProbeService.java
diffstat 1 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/ProbeService.java	Tue May 12 15:18:03 2015 +0200
+++ b/src/main/java/de/intevation/lada/rest/ProbeService.java	Tue May 12 15:18:47 2015 +0200
@@ -38,6 +38,7 @@
 
 import org.apache.log4j.Logger;
 
+import de.intevation.lada.factory.ProbeFactory;
 import de.intevation.lada.lock.LockConfig;
 import de.intevation.lada.lock.LockType;
 import de.intevation.lada.lock.ObjectLocker;
@@ -139,13 +140,20 @@
     private ObjectLocker lock;
 
     /**
-     * The validator used for Rpobe objects.
+     * The validator used for Probe objects.
      */
     @Inject
     @ValidationConfig(type="Probe")
     private Validator validator;
 
     /**
+     * The factory to create Probe objects.
+     * Used for messprogramm.
+     */
+    @Inject
+    private ProbeFactory factory;
+
+    /**
      * Get all Probe objects.
      * <p>
      * The requested objects can be filtered using the following URL
@@ -339,6 +347,37 @@
     }
 
     /**
+     * Create new Probe objects from a messprogramm.
+     * <p>
+     * <p>
+     * <pre>
+     * <code>
+     * {
+     * }
+     * </code>
+     * </pre>
+     *
+     * @return Response object containing the new probe object.
+     */
+    @POST
+    @Path("/messprogramm")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response createFromMessprogramm(
+        @Context HttpHeaders headers,
+        @Context HttpServletRequest request,
+        JsonObject object
+    ) {
+        String id = object.get("id").toString();
+        long start = object.getJsonNumber("start").longValue();
+        long end = object.getJsonNumber("end").longValue();
+        List<LProbe> proben = factory.create(
+            id,
+            start,
+            end);
+        return new Response(true, 200, proben);
+    }
+
+    /**
      * Update an existing Probe object.
      * <p>
      * The object to update should come as JSON formatted string.
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)