Mercurial > lada > lada-server
annotate src/main/java/de/intevation/lada/rest/stamm/MessstelleService.java @ 1028:1c41c7b8f7c2 schema-update
Updated server application to new database model. THIS IS STILL WIP!!!
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 08 Jul 2016 15:32:36 +0200 |
parents | 5bdd1631a451 |
children |
rev | line source |
---|---|
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 * |
630
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 */ |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 package de.intevation.lada.rest.stamm; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import javax.enterprise.context.RequestScoped; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import javax.inject.Inject; |
584
6de05718ac8d
Filter messstellen, netzbetreiber and verwaltungseinheiten.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
505
diff
changeset
|
12 import javax.servlet.http.HttpServletRequest; |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import javax.ws.rs.GET; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 import javax.ws.rs.Path; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import javax.ws.rs.PathParam; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 import javax.ws.rs.Produces; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 import javax.ws.rs.core.Context; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import javax.ws.rs.core.HttpHeaders; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 import javax.ws.rs.core.MediaType; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 import javax.ws.rs.core.UriInfo; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 |
1028
1c41c7b8f7c2
Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents:
827
diff
changeset
|
22 import de.intevation.lada.model.stammdaten.MessStelle; |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.lada.util.annotation.AuthorizationConfig; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.lada.util.annotation.RepositoryConfig; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.lada.util.auth.Authorization; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.lada.util.auth.AuthorizationType; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 import de.intevation.lada.util.data.Repository; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 import de.intevation.lada.util.data.RepositoryType; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 import de.intevation.lada.util.rest.Response; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 |
630
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
31 /** |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
32 * REST service for MessStelle objects. |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
33 * <p> |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
34 * The services produce data in the application/json media type. |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
35 * A typical response holds information about the action performed and the data. |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
36 * <pre> |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
37 * <code> |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
38 * { |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
39 * "success": [boolean]; |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
40 * "message": [string], |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
41 * "data":[{ |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
42 * "id": [string], |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
43 * "amtskennung": [string], |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
44 * "beschreibung": [string], |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
45 * "messStelle": [string], |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
46 * "mstTyp": [string], |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
47 * "netzbetreiberId": [string] |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
48 * }], |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
49 * "errors": [object], |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
50 * "warnings": [object], |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
51 * "readonly": [boolean], |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
52 * "totalCount": [number] |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
53 * } |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
54 * </code> |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
55 * </pre> |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
56 * |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
57 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
58 */ |
827
5bdd1631a451
!!!CAUTION!!! changed services path!
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
59 @Path("rest/messstelle") |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 @RequestScoped |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 public class MessstelleService { |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 |
630
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
63 /** |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
64 * The data repository granting read access. |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
65 */ |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 @Inject |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 @RepositoryConfig(type=RepositoryType.RO) |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 private Repository defaultRepo; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 |
630
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
70 /** |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
71 * The authorization module. |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
72 */ |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 @Inject |
722
c81881dac97e
Switch to shibboleth authorization in all REST-services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
668
diff
changeset
|
74 @AuthorizationConfig(type=AuthorizationType.HEADER) |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 private Authorization authorization; |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 /** |
630
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
78 * Get all MessStelle objects. |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
79 * <p> |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
80 * Example: http://example.com/messstelle |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 * |
630
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
82 * @return Response object containing all MessStelle objects. |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 */ |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 @GET |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 @Path("/") |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 @Produces(MediaType.APPLICATION_JSON) |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 public Response get( |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 @Context HttpHeaders headers, |
584
6de05718ac8d
Filter messstellen, netzbetreiber and verwaltungseinheiten.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
505
diff
changeset
|
89 @Context HttpServletRequest request, |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 @Context UriInfo info |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 ) { |
668
db1c69416eb6
Removed filtering of messstellen.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
630
diff
changeset
|
92 return defaultRepo.getAll(MessStelle.class, "stamm"); |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 } |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 /** |
630
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
96 * Get a single MessStelle object by id. |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
97 * <p> |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
98 * The id is appended to the URL as a path parameter. |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
99 * <p> |
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
100 * Example: http://example.com/messstelle/{id} |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 * |
630
44d7ff0461f2
Code documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
584
diff
changeset
|
102 * @return Response object containing a single MessStelle. |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 */ |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 @GET |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 @Path("/{id}") |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 @Produces(MediaType.APPLICATION_JSON) |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 public Response getById( |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 @Context HttpHeaders headers, |
584
6de05718ac8d
Filter messstellen, netzbetreiber and verwaltungseinheiten.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
505
diff
changeset
|
109 @Context HttpServletRequest request, |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 @PathParam("id") String id |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 ) { |
668
db1c69416eb6
Removed filtering of messstellen.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
630
diff
changeset
|
112 return defaultRepo.getById(MessStelle.class, id, "stamm"); |
505
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 } |
c813b4c1775f
Added messtellen services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 } |