annotate src/main/java/de/intevation/lada/rest/stamm/StatusKombiService.java @ 1041:f92c96efa976 schema-update

Organized imports and removed unused logger.
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 05 Sep 2016 10:17:32 +0200
parents 4d95cc7f0a43
children
rev   line source
1035
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 package de.intevation.lada.rest.stamm;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 import javax.enterprise.context.RequestScoped;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import javax.inject.Inject;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 import javax.ws.rs.GET;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 import javax.ws.rs.Path;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 import javax.ws.rs.PathParam;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 import javax.ws.rs.Produces;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 import javax.ws.rs.core.Context;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 import javax.ws.rs.core.HttpHeaders;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 import javax.ws.rs.core.MediaType;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 import javax.ws.rs.core.UriInfo;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 import de.intevation.lada.model.stammdaten.StatusKombi;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 import de.intevation.lada.util.annotation.RepositoryConfig;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 import de.intevation.lada.util.data.Repository;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 import de.intevation.lada.util.data.RepositoryType;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 import de.intevation.lada.util.rest.Response;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 /**
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 * REST service for StatusKombi objects.
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 * <p>
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 * The services produce data in the application/json media type.
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 * A typical response holds information about the action performed and the data.
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 * <pre>
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 * <code>
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 * {
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 * "success": [boolean];
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 * "message": [string],
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 * "data":[{
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 * "id": [number],
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 * "stufeId": [number],
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 * "wertId": [number]
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 * }],
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 * "errors": [object],
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 * "warnings": [object],
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 * "readonly": [boolean],
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 * "totalCount": [number]
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 * }
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 * </code>
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 * </pre>
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 *
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 */
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 @Path("rest/statuskombi")
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 @RequestScoped
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 public class StatusKombiService {
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 /**
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 * The data repository granting read access.
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 */
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 @Inject
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 @RepositoryConfig(type=RepositoryType.RO)
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 private Repository repository;
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 /**
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 * Get all StatusKombi objects.
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 * <p>
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 * Example: http://example.com/statuskombi
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 *
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 * @return Response object containing all StatusStufe objects.
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 */
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 @GET
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 @Path("/")
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 @Produces(MediaType.APPLICATION_JSON)
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 public Response get(
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 @Context HttpHeaders headers,
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 @Context UriInfo info
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 ) {
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 return repository.getAll(StatusKombi.class, "stamm");
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 }
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 /**
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 * Get a single StatusStufe object by id.
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 * <p>
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 * The id is appended to the URL as a path parameter.
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 * <p>
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 * Example: http://example.com/statusstufe/{id}
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 *
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 * @return Response object containing a single StatusStufe.
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 */
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 @GET
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 @Path("/{id}")
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 @Produces(MediaType.APPLICATION_JSON)
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 public Response getById(
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 @Context HttpHeaders headers,
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 @PathParam("id") String id
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 ) {
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 return repository.getById(
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 StatusKombi.class,
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 Integer.valueOf(id),
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 "stamm");
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 }
4d95cc7f0a43 Updated status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)