torsten@8: package de.intevation.rest; torsten@8: torsten@15: import java.util.List; torsten@17: import java.util.logging.Logger; torsten@15: torsten@8: import javax.enterprise.context.RequestScoped; torsten@8: import javax.inject.Inject; torsten@8: import javax.ws.rs.GET; torsten@8: import javax.ws.rs.Path; torsten@8: import javax.ws.rs.Produces; torsten@8: torsten@15: import de.intevation.data.LProbeRepository; torsten@15: import de.intevation.model.LProbe; torsten@24: import de.intevation.service.LProbeService; torsten@15: torsten@8: /** torsten@8: * JAX-RS Example torsten@8: * torsten@8: * This class produces a RESTful service to read the contents of the members table. torsten@8: */ torsten@8: torsten@8: @Path("/proben") torsten@8: @RequestScoped torsten@8: public class LProbeRESTService { torsten@8: torsten@15: @Inject torsten@15: private LProbeRepository repository; torsten@15: torsten@15: @Inject torsten@15: private Logger log; torsten@8: torsten@8: @GET torsten@20: @Produces("text/json") torsten@20: public List listAllMembers() { torsten@15: final List result = repository.findAll(); torsten@20: return result; torsten@8: } torsten@8: torsten@8: @GET torsten@8: @Path("/{id:[0-9][0-9]*}") torsten@8: @Produces("text/plain") torsten@8: public String loadById() { torsten@8: return "Eine Probe!"; torsten@8: } torsten@23: torsten@23: @GET torsten@23: @Path("/deleteLast") torsten@23: @Produces("text/plain") torsten@23: public String deleteLast() { torsten@23: final List result = repository.findAll(); torsten@23: LProbe last_element = result.get(result.size()-1); torsten@23: repository.delete(last_element); torsten@23: return "Gelöscht id" + last_element.getProbeId(); torsten@23: } torsten@8: torsten@23: @GET torsten@23: @Path("/new") torsten@23: @Produces("text/plain") torsten@23: public String create() { torsten@23: return "Neu"; torsten@23: } torsten@8: //@GET torsten@8: //@Produces("text/xml") torsten@8: //public List listAllMembers() { torsten@15: // // Us @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of torsten@8: // // this query torsten@8: // @SuppressWarnings("unchecked") torsten@8: // // We recommend centralizing inline queries such as this one into @NamedQuery annotations on torsten@8: // // the @Entity class torsten@8: // // as described in the named query blueprint: torsten@8: // // https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html torsten@8: // final List results = em.createQuery("select m from Member m order by m.name").getResultList(); torsten@8: // return results; torsten@8: //} torsten@8: torsten@8: //@GET torsten@8: //@Path("/{id:[0-9][0-9]*}") torsten@8: //@Produces("text/xml") torsten@8: //public Member lookupMemberById(@PathParam("id") long id) { torsten@8: // return em.find(Member.class, id); torsten@8: //} torsten@8: }