[Lada-commits] [PATCH 5 of 8] New REST interface to create probe objects from messprogramm
Wald Commits
scm-commit at wald.intevation.org
Tue May 12 15:20:07 CEST 2015
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1431436727 -7200
# Node ID a8909085dae690a6189603f712ada5d62fe08ef0
# Parent 866d05db7a6a77f4050e72c5e8c12f91913f81f8
New REST interface to create probe objects from messprogramm.
diff -r 866d05db7a6a -r a8909085dae6 src/main/java/de/intevation/lada/rest/ProbeService.java
--- 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.
More information about the Lada-commits
mailing list