comparison src/main/java/de/intevation/rest/LProbeRESTService.java @ 15:624611a29348

Provide GET method to load a list of proben.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 18 Apr 2013 17:03:06 +0200
parents 1016bcc08bb3
children 4ed66a87c0c4
comparison
equal deleted inserted replaced
14:de959fc71eda 15:624611a29348
1 package de.intevation.rest; 1 package de.intevation.rest;
2
3 import java.util.List;
2 4
3 import javax.enterprise.context.RequestScoped; 5 import javax.enterprise.context.RequestScoped;
4 import javax.inject.Inject; 6 import javax.inject.Inject;
5 import javax.persistence.EntityManager;
6 import javax.ws.rs.GET; 7 import javax.ws.rs.GET;
7 import javax.ws.rs.Path; 8 import javax.ws.rs.Path;
8 import javax.ws.rs.Produces; 9 import javax.ws.rs.Produces;
10
11 import de.intevation.data.LProbeRepository;
12 import de.intevation.model.LProbe;
9 13
10 /** 14 /**
11 * JAX-RS Example 15 * JAX-RS Example
12 * 16 *
13 * This class produces a RESTful service to read the contents of the members table. 17 * This class produces a RESTful service to read the contents of the members table.
15 19
16 @Path("/proben") 20 @Path("/proben")
17 @RequestScoped 21 @RequestScoped
18 public class LProbeRESTService { 22 public class LProbeRESTService {
19 23
20 //@Inject 24 @Inject
21 //private EntityManager em; 25 private LProbeRepository repository;
26
27 @Inject
28 private Logger log;
22 29
23 @GET 30 @GET
24 @Produces("text/plain") 31 @Produces("text/plain")
25 public String listAllMembers() { 32 public String listAllMembers() {
33 final List<LProbe> result = repository.findAll();
34 System.out.println(result);
26 return "Probenliste"; 35 return "Probenliste";
27 } 36 }
28 37
29 @GET 38 @GET
30 @Path("/{id:[0-9][0-9]*}") 39 @Path("/{id:[0-9][0-9]*}")
34 } 43 }
35 44
36 //@GET 45 //@GET
37 //@Produces("text/xml") 46 //@Produces("text/xml")
38 //public List<Member> listAllMembers() { 47 //public List<Member> listAllMembers() {
39 // // Use @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of 48 // // Us @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of
40 // // this query 49 // // this query
41 // @SuppressWarnings("unchecked") 50 // @SuppressWarnings("unchecked")
42 // // We recommend centralizing inline queries such as this one into @NamedQuery annotations on 51 // // We recommend centralizing inline queries such as this one into @NamedQuery annotations on
43 // // the @Entity class 52 // // the @Entity class
44 // // as described in the named query blueprint: 53 // // as described in the named query blueprint:
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)