changeset 48:afc3ef3dc3c3

New REST service for 'Probenart Stammdaten'.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 24 May 2013 11:56:07 +0200
parents c9cfb34983f0
children 4a987b6be57e
files src/main/java/de/intevation/lada/rest/SProbenartService.java
diffstat 1 files changed, 62 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/rest/SProbenartService.java	Fri May 24 11:56:07 2013 +0200
@@ -0,0 +1,62 @@
+package de.intevation.lada.rest;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import de.intevation.lada.data.Repository;
+import de.intevation.lada.model.SProbenart;
+
+/**
+ * This class produces a RESTful service to read the contents of SProbenart table.
+ * 
+ * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
+ */
+@Path("/probenart")
+@RequestScoped
+public class SProbenartService
+{
+    /**
+     * The Repository for SProbenart.
+     */
+    @Inject @Named
+    private Repository repository;
+
+    /**
+     * The logger for this class
+     */
+    @Inject
+    private Logger logger;
+
+    /**
+     * Request all SProbenart objects.
+     *
+     * @return JSON Object via Rest service
+     */
+    @GET
+    @Produces("text/json")
+    public List<SProbenart> findAll() {
+        List<SProbenart> result = repository.findAll(SProbenart.class);
+        return result;
+    }
+
+    /**
+     * Request a single SProbenart via its id.
+     *
+     * @param id The mst_id
+     * @return JSON Object via REST service.
+     */
+    @GET
+    @Path("/{id}")
+    @Produces("text/json")
+    public SProbenart findById(@PathParam("id") String id) {
+        return repository.findById(SProbenart.class, id);
+    }
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)