# HG changeset patch # User Raimund Renkert # Date 1371195116 -7200 # Node ID 70895bc48470d148ca3ba406903da90968399d22 # Parent 4ff6903306cb093202ecb013881f5f526989d3ff New service for SStaat objects. diff -r 4ff6903306cb -r 70895bc48470 src/main/java/de/intevation/lada/rest/SStaatService.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/rest/SStaatService.java Fri Jun 14 09:31:56 2013 +0200 @@ -0,0 +1,53 @@ +package de.intevation.lada.rest; + +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.SStaat; + +/** + * This class produces a RESTful service to read the contents of s_staat table. + * + * @author Raimund Renkert + */ +@Path("/staat") +@RequestScoped +public class SStaatService +{ + /** + * The Repository for SUmwelt. + */ + @Inject + @Named("readolyrepository") + private Repository repository; + + /** + * Request all SUmwelt objects. + * + * @return JSON Object via Rest service + */ + @GET + @Produces("text/json") + public Response findAll() { + return repository.findAll(SStaat.class); + } + + /** + * Request a SUmwelt object via its id. + * + * @param id The SUmwelt id + * @return JSON Object via REST service. + */ + @GET + @Path("/{id:[0-9][0-9]*}") + @Produces("text/json") + public Response findById(@PathParam("id") String id) { + return repository.findById(SStaat.class, id); + } +}