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