Mercurial > lada > lada-server
view src/main/java/de/intevation/rest/LProbeRESTService.java @ 21:f4bc98fb8aac
Added new links to trigger creation and deletion
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Fri, 26 Apr 2013 15:00:08 +0200 |
parents | 7a9e22e7e8af |
children | 00ed8e5b05b6 |
line wrap: on
line source
package de.intevation.rest; import java.util.List; import java.util.logging.Logger; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import de.intevation.data.LProbeRepository; import de.intevation.model.LProbe; /** * JAX-RS Example * * This class produces a RESTful service to read the contents of the members table. */ @Path("/proben") @RequestScoped public class LProbeRESTService { @Inject private LProbeRepository repository; @Inject private Logger log; @GET @Produces("text/json") public List<LProbe> listAllMembers() { final List<LProbe> result = repository.findAll(); return result; } @GET @Path("/{id:[0-9][0-9]*}") @Produces("text/plain") public String loadById() { return "Eine Probe!"; } //@GET //@Produces("text/xml") //public List<Member> listAllMembers() { // // Us @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of // // this query // @SuppressWarnings("unchecked") // // We recommend centralizing inline queries such as this one into @NamedQuery annotations on // // the @Entity class // // as described in the named query blueprint: // // https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html // final List<Member> results = em.createQuery("select m from Member m order by m.name").getResultList(); // return results; //} //@GET //@Path("/{id:[0-9][0-9]*}") //@Produces("text/xml") //public Member lookupMemberById(@PathParam("id") long id) { // return em.find(Member.class, id); //} }