Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/rest/SUmweltService.java @ 45:a5ee8d69c0b4
Renamed existing rest services and make use of the generic repository.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 24 May 2013 11:53:46 +0200 |
parents | src/main/java/de/intevation/lada/rest/SUmweltRESTService.java@0dd63fcc9581 |
children | 5abec5413d65 |
comparison
equal
deleted
inserted
replaced
44:2d89a04d5ad9 | 45:a5ee8d69c0b4 |
---|---|
1 package de.intevation.lada.rest; | |
2 | |
3 import java.util.List; | |
4 import java.util.logging.Logger; | |
5 | |
6 import javax.enterprise.context.RequestScoped; | |
7 import javax.inject.Inject; | |
8 import javax.ws.rs.GET; | |
9 import javax.ws.rs.Path; | |
10 import javax.ws.rs.PathParam; | |
11 import javax.ws.rs.Produces; | |
12 | |
13 import de.intevation.lada.data.Repository; | |
14 import de.intevation.lada.model.SUmwelt; | |
15 import javax.inject.Named; | |
16 | |
17 /** | |
18 * This class produces a RESTful service to read the contents of s_umwelt table. | |
19 * | |
20 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> | |
21 */ | |
22 @Path("/uwb") | |
23 @RequestScoped | |
24 public class SUmweltService { | |
25 | |
26 /** | |
27 * The Repository for SUmwelt. | |
28 */ | |
29 @Inject @Named | |
30 private Repository repository; | |
31 | |
32 /** | |
33 * The logger for this class. | |
34 */ | |
35 @Inject | |
36 private Logger log; | |
37 | |
38 /** | |
39 * Request all SUmwelt objects. | |
40 * | |
41 * @return JSON Object via Rest service | |
42 */ | |
43 @GET | |
44 @Produces("text/json") | |
45 public List<SUmwelt> findAll() { | |
46 List<SUmwelt> result = repository.findAll(SUmwelt.class); | |
47 return result; | |
48 } | |
49 | |
50 /** | |
51 * Request a SUmwelt object via its id. | |
52 * | |
53 * @param id The SUmwelt id | |
54 * @return JSON Object via REST service. | |
55 */ | |
56 @GET | |
57 @Path("/{id:[0-9][0-9]*}") | |
58 @Produces("text/json") | |
59 public SUmwelt loadById(@PathParam("id") String id) { | |
60 return repository.findById(SUmwelt.class, id); | |
61 } | |
62 } |