Mercurial > lada > lada-server
changeset 47:c9cfb34983f0
New REST service for 'Datenbasis Stammdaten'.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 24 May 2013 11:55:41 +0200 |
parents | ff802c5e77f7 |
children | afc3ef3dc3c3 |
files | src/main/java/de/intevation/lada/rest/SDatenbasisService.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/SDatenbasisService.java Fri May 24 11:55:41 2013 +0200 @@ -0,0 +1,62 @@ +package de.intevation.lada.rest; + +import java.util.List; +import java.util.logging.Logger; + +import javax.faces.bean.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.SDatenbasis; + +/** + * This class produces a RESTful service to read the contents of SDatenbasis table. + * + * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> + */ +@Path("/datenbasis") +@RequestScoped +public class SDatenbasisService +{ + /** + * The Repository for SDatenbasis. + */ + @Inject @Named + private Repository repository; + + /** + * The logger for this class + */ + @Inject + private Logger logger; + + /** + * Request all SDatenbasis objects. + * + * @return JSON Object via Rest service + */ + @GET + @Produces("text/json") + public List<SDatenbasis> findAll() { + List<SDatenbasis> result = repository.findAll(SDatenbasis.class); + return result; + } + + /** + * Request a single SDatenbasis via its id. + * + * @param id The mst_id + * @return JSON Object via REST service. + */ + @GET + @Path("/{id}") + @Produces("text/json") + public SDatenbasis findById(@PathParam("id") String id) { + return repository.findById(SDatenbasis.class, id); + } +}