comparison src/main/java/de/intevation/lada/rest/stamm/OrtTypService.java @ 1271:ff12c3e3366a

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