Mercurial > lada > lada-server
annotate src/main/java/de/intevation/lada/rest/StatusService.java @ 943:0f6773f74b62
change 'similar to' to 'IN' Conditions in filter queries
author | Michael Stanko <mstanko@bfs.de> |
---|---|
date | Thu, 12 May 2016 11:18:29 +0200 |
parents | dfb0d6f2b140 |
children | 0a80f4a87c67 |
rev | line source |
---|---|
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 * |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 */ |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 package de.intevation.lada.rest; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 |
840 | 10 import java.sql.Timestamp; |
11 import java.util.Date; | |
787
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
12 import java.util.List; |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
13 |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 import javax.enterprise.context.RequestScoped; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import javax.inject.Inject; |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
16 import javax.servlet.http.HttpServletRequest; |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 import javax.ws.rs.DELETE; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import javax.ws.rs.GET; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 import javax.ws.rs.POST; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 import javax.ws.rs.PUT; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 import javax.ws.rs.Path; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 import javax.ws.rs.PathParam; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 import javax.ws.rs.Produces; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 import javax.ws.rs.core.Context; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 import javax.ws.rs.core.HttpHeaders; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 import javax.ws.rs.core.MediaType; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 import javax.ws.rs.core.MultivaluedMap; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 import javax.ws.rs.core.UriInfo; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 |
787
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
30 import org.apache.log4j.Logger; |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
31 |
595
746e03da9fad
Use timestamp locker in REST services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
582
diff
changeset
|
32 import de.intevation.lada.lock.LockConfig; |
746e03da9fad
Use timestamp locker in REST services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
582
diff
changeset
|
33 import de.intevation.lada.lock.LockType; |
746e03da9fad
Use timestamp locker in REST services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
582
diff
changeset
|
34 import de.intevation.lada.lock.ObjectLocker; |
747
214508fd95e7
Set the new created status protocol at messung.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
745
diff
changeset
|
35 import de.intevation.lada.model.land.LMessung; |
839
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
36 import de.intevation.lada.model.land.LProbe; |
745
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
37 import de.intevation.lada.model.land.LStatusProtokoll; |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 import de.intevation.lada.util.annotation.AuthorizationConfig; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 import de.intevation.lada.util.annotation.RepositoryConfig; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 import de.intevation.lada.util.auth.Authorization; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 import de.intevation.lada.util.auth.AuthorizationType; |
774
2719c9602f2c
Search the next StatusStufe and create a new copy of a Status in on PUT.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
747
diff
changeset
|
42 import de.intevation.lada.util.auth.UserInfo; |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 import de.intevation.lada.util.data.QueryBuilder; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 import de.intevation.lada.util.data.Repository; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 import de.intevation.lada.util.data.RepositoryType; |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
46 import de.intevation.lada.util.rest.RequestMethod; |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 import de.intevation.lada.util.rest.Response; |
787
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
48 import de.intevation.lada.validation.Validator; |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
49 import de.intevation.lada.validation.Violation; |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
50 import de.intevation.lada.validation.annotation.ValidationConfig; |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
52 /** |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
53 * REST service for Status objects. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
54 * <p> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
55 * The services produce data in the application/json media type. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
56 * All HTTP methods use the authorization module to determine if the user is |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
57 * allowed to perform the requested action. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
58 * A typical response holds information about the action performed and the data. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
59 * <pre> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
60 * <code> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
61 * { |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
62 * "success": [boolean]; |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
63 * "message": [string], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
64 * "data":[{ |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
65 * "id": [number], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
66 * "erzeuger": [string], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
67 * "messungsId": [number], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
68 * "status": [number], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
69 * "owner": [boolean], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
70 * "readonly": [boolean], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
71 * "treeModified": [timestamp], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
72 * "parentModified": [timestamp], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
73 * "sdatum": [timestamp], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
74 * "skommentar": [string] |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
75 * }], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
76 * "errors": [object], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
77 * "warnings": [object], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
78 * "readonly": [boolean], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
79 * "totalCount": [number] |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
80 * } |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
81 * </code> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
82 * </pre> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
83 * |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
84 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
85 */ |
827
5bdd1631a451
!!!CAUTION!!! changed services path!
Raimund Renkert <raimund.renkert@intevation.de>
parents:
802
diff
changeset
|
86 @Path("rest/status") |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 @RequestScoped |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 public class StatusService { |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 |
787
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
90 @Inject |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
91 private Logger logger = Logger.getLogger(StatusService.class); |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
92 |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
93 /** |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
94 * The data repository granting read/write access. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
95 */ |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 @Inject |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 @RepositoryConfig(type=RepositoryType.RW) |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 private Repository defaultRepo; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
100 /** |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
101 * The object lock mechanism. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
102 */ |
595
746e03da9fad
Use timestamp locker in REST services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
582
diff
changeset
|
103 @Inject |
746e03da9fad
Use timestamp locker in REST services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
582
diff
changeset
|
104 @LockConfig(type=LockType.TIMESTAMP) |
746e03da9fad
Use timestamp locker in REST services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
582
diff
changeset
|
105 private ObjectLocker lock; |
746e03da9fad
Use timestamp locker in REST services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
582
diff
changeset
|
106 |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
107 /** |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
108 * The authorization module. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
109 */ |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 @Inject |
722
c81881dac97e
Switch to shibboleth authorization in all REST-services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
711
diff
changeset
|
111 @AuthorizationConfig(type=AuthorizationType.HEADER) |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 private Authorization authorization; |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 |
787
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
114 @Inject |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
115 @ValidationConfig(type="Status") |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
116 private Validator validator; |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
117 |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 /** |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
119 * Get all Status objects. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
120 * <p> |
821
487c6d8c9d7b
No authorization is given if all objects are requested.
Tom Gottfried <tom@intevation.de>
parents:
820
diff
changeset
|
121 * The requested objects have to be filtered using an URL parameter named |
711
3ec358698b4d
Code style and documentation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
628
diff
changeset
|
122 * messungsId. |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
123 * <p> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
124 * Example: http://example.com/status?messungsId=[ID] |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 * |
821
487c6d8c9d7b
No authorization is given if all objects are requested.
Tom Gottfried <tom@intevation.de>
parents:
820
diff
changeset
|
126 * @return Response object containing filtered Status objects. |
487c6d8c9d7b
No authorization is given if all objects are requested.
Tom Gottfried <tom@intevation.de>
parents:
820
diff
changeset
|
127 * Status-Code 699 if parameter is missing or requested objects are |
487c6d8c9d7b
No authorization is given if all objects are requested.
Tom Gottfried <tom@intevation.de>
parents:
820
diff
changeset
|
128 * not authorized. |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 */ |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 @GET |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 @Path("/") |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 @Produces(MediaType.APPLICATION_JSON) |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 public Response get( |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 @Context HttpHeaders headers, |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
135 @Context UriInfo info, |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
136 @Context HttpServletRequest request |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 ) { |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 MultivaluedMap<String, String> params = info.getQueryParameters(); |
556
4017d2c8dd24
Renamed all 'messungId' url parameters to 'messungsId'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
488
diff
changeset
|
139 if (params.isEmpty() || !params.containsKey("messungsId")) { |
802
b04e55896104
Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
789
diff
changeset
|
140 return new Response(false, 699, null); |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 } |
556
4017d2c8dd24
Renamed all 'messungId' url parameters to 'messungsId'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
488
diff
changeset
|
142 String messungId = params.getFirst("messungsId"); |
802
b04e55896104
Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
789
diff
changeset
|
143 int id; |
b04e55896104
Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
789
diff
changeset
|
144 try { |
b04e55896104
Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
789
diff
changeset
|
145 id = Integer.valueOf(messungId); |
b04e55896104
Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
789
diff
changeset
|
146 } |
b04e55896104
Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
789
diff
changeset
|
147 catch(NumberFormatException nfe) { |
b04e55896104
Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
789
diff
changeset
|
148 return new Response(false, 698, null); |
b04e55896104
Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
789
diff
changeset
|
149 } |
b04e55896104
Authorize messwert, kommentar and status.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
789
diff
changeset
|
150 |
745
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
151 QueryBuilder<LStatusProtokoll> builder = |
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
152 new QueryBuilder<LStatusProtokoll>( |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 defaultRepo.entityManager("land"), |
745
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
154 LStatusProtokoll.class); |
860
7c6b7c08d31d
Allow GET for status objects with messungsId.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
840
diff
changeset
|
155 builder.and("messungsId", id); |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
156 return authorization.filter( |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
157 request, |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
158 defaultRepo.filter(builder.getQuery(), "land"), |
745
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
159 LStatusProtokoll.class); |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 } |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 /** |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
163 * Get a single Status object by id. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
164 * <p> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
165 * The id is appended to the URL as a path parameter. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
166 * <p> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
167 * Example: http://example.com/status/{id} |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 * |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
169 * @return Response object containing a single Status. |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 */ |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 @GET |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 @Path("/{id}") |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 @Produces(MediaType.APPLICATION_JSON) |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 public Response getById( |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 @Context HttpHeaders headers, |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
176 @Context HttpServletRequest request, |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 @PathParam("id") String id |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 ) { |
787
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
179 Response response = defaultRepo.getById( |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
180 LStatusProtokoll.class, |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
181 Integer.valueOf(id), |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
182 "land"); |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
183 LStatusProtokoll status = (LStatusProtokoll)response.getData(); |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
184 Violation violation = validator.validate(status); |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
185 if (violation.hasErrors() || violation.hasWarnings()) { |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
186 response.setErrors(violation.getErrors()); |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
187 response.setWarnings(violation.getWarnings()); |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
188 } |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
189 |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
190 return authorization.filter( |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
191 request, |
787
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
192 response, |
745
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
193 LStatusProtokoll.class); |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 } |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
196 /** |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
197 * Create a Status object. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
198 * <p> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
199 * The new object is embedded in the post data as JSON formatted string. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
200 * <p> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
201 * <pre> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
202 * <code> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
203 * { |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
204 * "owner": [boolean], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
205 * "messungsId": [number], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
206 * "erzeuger": [string], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
207 * "status": [number], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
208 * "skommentar": [string], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
209 * "treeModified":null, |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
210 * "parentModified":null, |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
211 * "sdatum": [date] |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
212 * } |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
213 * </code> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
214 * </pre> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
215 * |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
216 * @return A response object containing the created Status. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
217 */ |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
218 @POST |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
219 @Path("/") |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
220 @Produces(MediaType.APPLICATION_JSON) |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
221 public Response create( |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
222 @Context HttpHeaders headers, |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
223 @Context HttpServletRequest request, |
745
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
224 LStatusProtokoll status |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
225 ) { |
883
2e264556f186
Avoid NPE by rejecting invalid requests.
Tom Gottfried <tom@intevation.de>
parents:
882
diff
changeset
|
226 if (status.getMessungsId() == null |
2e264556f186
Avoid NPE by rejecting invalid requests.
Tom Gottfried <tom@intevation.de>
parents:
882
diff
changeset
|
227 || status.getErzeuger() == null |
2e264556f186
Avoid NPE by rejecting invalid requests.
Tom Gottfried <tom@intevation.de>
parents:
882
diff
changeset
|
228 || status.getStatusWert() == null |
2e264556f186
Avoid NPE by rejecting invalid requests.
Tom Gottfried <tom@intevation.de>
parents:
882
diff
changeset
|
229 ) { |
2e264556f186
Avoid NPE by rejecting invalid requests.
Tom Gottfried <tom@intevation.de>
parents:
882
diff
changeset
|
230 return new Response(false, 631, null); |
2e264556f186
Avoid NPE by rejecting invalid requests.
Tom Gottfried <tom@intevation.de>
parents:
882
diff
changeset
|
231 } |
2e264556f186
Avoid NPE by rejecting invalid requests.
Tom Gottfried <tom@intevation.de>
parents:
882
diff
changeset
|
232 |
774
2719c9602f2c
Search the next StatusStufe and create a new copy of a Status in on PUT.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
747
diff
changeset
|
233 UserInfo userInfo = authorization.getInfo(request); |
2719c9602f2c
Search the next StatusStufe and create a new copy of a Status in on PUT.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
747
diff
changeset
|
234 LMessung messung = defaultRepo.getByIdPlain( |
2719c9602f2c
Search the next StatusStufe and create a new copy of a Status in on PUT.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
747
diff
changeset
|
235 LMessung.class, status.getMessungsId(), "land"); |
881
501ccddaeaca
Use lock mechanism for messung objects on status POST.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
874
diff
changeset
|
236 if (lock.isLocked(messung)) { |
501ccddaeaca
Use lock mechanism for messung objects on status POST.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
874
diff
changeset
|
237 return new Response(false, 697, null); |
501ccddaeaca
Use lock mechanism for messung objects on status POST.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
874
diff
changeset
|
238 } |
921
83a7ef8d4f69
Use authorization in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
887
diff
changeset
|
239 |
83a7ef8d4f69
Use authorization in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
887
diff
changeset
|
240 Response r = authorization.filter( |
83a7ef8d4f69
Use authorization in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
887
diff
changeset
|
241 request, |
83a7ef8d4f69
Use authorization in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
887
diff
changeset
|
242 new Response(true, 200, messung), |
83a7ef8d4f69
Use authorization in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
887
diff
changeset
|
243 LMessung.class); |
83a7ef8d4f69
Use authorization in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
887
diff
changeset
|
244 LMessung filteredMessung = (LMessung)r.getData(); |
83a7ef8d4f69
Use authorization in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
887
diff
changeset
|
245 if (filteredMessung.getStatusEdit() == false) { |
83a7ef8d4f69
Use authorization in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
887
diff
changeset
|
246 return new Response(false, 699, null); |
83a7ef8d4f69
Use authorization in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
887
diff
changeset
|
247 } |
774
2719c9602f2c
Search the next StatusStufe and create a new copy of a Status in on PUT.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
747
diff
changeset
|
248 boolean next = false; |
2719c9602f2c
Search the next StatusStufe and create a new copy of a Status in on PUT.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
747
diff
changeset
|
249 boolean change = false; |
778
574391f1d88f
Fixed status and messung services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
777
diff
changeset
|
250 if (messung.getStatus() == null) { |
774
2719c9602f2c
Search the next StatusStufe and create a new copy of a Status in on PUT.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
747
diff
changeset
|
251 status.setStatusStufe(1); |
2719c9602f2c
Search the next StatusStufe and create a new copy of a Status in on PUT.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
747
diff
changeset
|
252 } |
2719c9602f2c
Search the next StatusStufe and create a new copy of a Status in on PUT.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
747
diff
changeset
|
253 else { |
778
574391f1d88f
Fixed status and messung services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
777
diff
changeset
|
254 LStatusProtokoll currentStatus = defaultRepo.getByIdPlain( |
574391f1d88f
Fixed status and messung services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
777
diff
changeset
|
255 LStatusProtokoll.class, messung.getStatus(), "land"); |
839
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
256 |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
257 if (currentStatus.getStatusWert() == 4) { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
258 LProbe probe = defaultRepo.getByIdPlain( |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
259 LProbe.class, |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
260 messung.getProbeId(), |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
261 "land"); |
884
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
262 if (status.getStatusWert() == 4 |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
263 && userInfo.getMessstellen().contains( |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
264 currentStatus.getErzeuger()) |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
265 && status.getErzeuger().equals( |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
266 currentStatus.getErzeuger()) |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
267 ) { |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
268 // 'edit' currentStatus |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
269 status.setStatusStufe(currentStatus.getStatusStufe()); |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
270 } |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
271 else if ( |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
272 userInfo.getFunktionenForMst(probe.getMstId()) |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
273 .contains(1) |
fa7278bd8d73
Allow 'editing' of status 'Rückfrage'
Tom Gottfried <tom@intevation.de>
parents:
883
diff
changeset
|
274 && probe.getMstId().equals(status.getErzeuger()) |
839
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
275 ) { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
276 status.setStatusStufe(1); |
778
574391f1d88f
Fixed status and messung services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
777
diff
changeset
|
277 } |
839
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
278 else { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
279 return new Response(false, 699, null); |
778
574391f1d88f
Fixed status and messung services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
777
diff
changeset
|
280 } |
574391f1d88f
Fixed status and messung services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
777
diff
changeset
|
281 } |
839
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
282 else { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
283 for (int i = 0; |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
284 i < userInfo.getFunktionenForMst(status.getErzeuger()).size(); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
285 i++ |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
286 ) { |
877
06d1cace9141
Use equals() to compare int-values of Integer objects.
Tom Gottfried <tom@intevation.de>
parents:
874
diff
changeset
|
287 if (userInfo.getFunktionenForMst(status.getErzeuger()) |
06d1cace9141
Use equals() to compare int-values of Integer objects.
Tom Gottfried <tom@intevation.de>
parents:
874
diff
changeset
|
288 .get(i).equals(currentStatus.getStatusStufe() + 1) |
06d1cace9141
Use equals() to compare int-values of Integer objects.
Tom Gottfried <tom@intevation.de>
parents:
874
diff
changeset
|
289 && currentStatus.getStatusWert() != 0 |
839
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
290 ) { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
291 next = true; |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
292 } |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
293 else if (userInfo.getFunktionenForMst( |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
294 status.getErzeuger()).get(i) == |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
295 currentStatus.getStatusStufe() |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
296 ) { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
297 change = true; |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
298 } |
822
c3cf7cbb65ed
Update "fertig" flag on status changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
821
diff
changeset
|
299 } |
839
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
300 if (change && |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
301 status.getStatusWert() == 4 && |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
302 status.getStatusStufe() > 1 |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
303 ) { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
304 status.setStatusStufe(currentStatus.getStatusStufe()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
305 } |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
306 else if (change && status.getStatusWert() == 8) { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
307 return authorization.filter( |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
308 request, |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
309 resetStatus(status, currentStatus, messung), |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
310 LStatusProtokoll.class); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
311 } |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
312 else if (change && status.getStatusWert() != 0) { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
313 status.setStatusStufe(currentStatus.getStatusStufe()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
314 } |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
315 else if (next && |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
316 (status.getStatusWert() > 0 && |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
317 status.getStatusWert() <= 4 || |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
318 status.getStatusWert() == 7)) { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
319 status.setStatusStufe(currentStatus.getStatusStufe() + 1); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
320 } |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
321 else { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
322 return new Response(false, 699, null); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
323 } |
887
305f138982eb
Move auto-setting 'fertig' to correct block.
Tom Gottfried <tom@intevation.de>
parents:
885
diff
changeset
|
324 } |
885
e09c41d8eef3
There are only two clear-cut cases where 'fertig' should be set.
Tom Gottfried <tom@intevation.de>
parents:
884
diff
changeset
|
325 |
887
305f138982eb
Move auto-setting 'fertig' to correct block.
Tom Gottfried <tom@intevation.de>
parents:
885
diff
changeset
|
326 // auto-set 'fertig'-flag |
305f138982eb
Move auto-setting 'fertig' to correct block.
Tom Gottfried <tom@intevation.de>
parents:
885
diff
changeset
|
327 if (status.getStatusStufe() == 1) { |
305f138982eb
Move auto-setting 'fertig' to correct block.
Tom Gottfried <tom@intevation.de>
parents:
885
diff
changeset
|
328 messung.setFertig(true); |
305f138982eb
Move auto-setting 'fertig' to correct block.
Tom Gottfried <tom@intevation.de>
parents:
885
diff
changeset
|
329 } |
305f138982eb
Move auto-setting 'fertig' to correct block.
Tom Gottfried <tom@intevation.de>
parents:
885
diff
changeset
|
330 else if (status.getStatusWert() == 4) { |
305f138982eb
Move auto-setting 'fertig' to correct block.
Tom Gottfried <tom@intevation.de>
parents:
885
diff
changeset
|
331 messung.setFertig(false); |
778
574391f1d88f
Fixed status and messung services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
777
diff
changeset
|
332 } |
774
2719c9602f2c
Search the next StatusStufe and create a new copy of a Status in on PUT.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
747
diff
changeset
|
333 } |
787
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
334 Violation violation = validator.validate(status); |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
335 if (violation.hasErrors()) { |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
336 Response response = new Response(false, 604, status); |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
337 response.setErrors(violation.getErrors()); |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
338 response.setWarnings(violation.getWarnings()); |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
339 return response; |
7033810468d9
Validate status objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
778
diff
changeset
|
340 } |
747
214508fd95e7
Set the new created status protocol at messung.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
745
diff
changeset
|
341 Response response = defaultRepo.create(status, "land"); |
214508fd95e7
Set the new created status protocol at messung.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
745
diff
changeset
|
342 LStatusProtokoll created = (LStatusProtokoll)response.getData(); |
214508fd95e7
Set the new created status protocol at messung.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
745
diff
changeset
|
343 messung.setStatus(created.getId()); |
214508fd95e7
Set the new created status protocol at messung.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
745
diff
changeset
|
344 defaultRepo.update(messung, "land"); |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
345 /* Persist the new object*/ |
601
ddab1ecb2898
Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
595
diff
changeset
|
346 return authorization.filter( |
ddab1ecb2898
Use the authorization filter in all REST operations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
595
diff
changeset
|
347 request, |
747
214508fd95e7
Set the new created status protocol at messung.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
745
diff
changeset
|
348 response, |
745
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
349 LStatusProtokoll.class); |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
350 } |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
351 |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
352 /** |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
353 * Update an existing Status object. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
354 * <p> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
355 * The object to update should come as JSON formatted string. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
356 * <pre> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
357 * <code> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
358 * { |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
359 * "id": [number], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
360 * "owner": [boolean], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
361 * "messungsId": [number], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
362 * "erzeuger": [string], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
363 * "status": [number], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
364 * "skommentar": [string], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
365 * "treeModified": [timestamp], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
366 * "parentModified": [timestamp], |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
367 * "sdatum": [date] |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
368 * } |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
369 * </code> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
370 * </pre> |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
371 * |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
372 * @return Response object containing the updated Status object. |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
373 */ |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
374 @PUT |
557
61ce3ce0100e
Allow /{id} in urls on PUT requests.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
556
diff
changeset
|
375 @Path("/{id}") |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
376 @Produces(MediaType.APPLICATION_JSON) |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
377 public Response update( |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
378 @Context HttpHeaders headers, |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
379 @Context HttpServletRequest request, |
745
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
380 LStatusProtokoll status |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
381 ) { |
840 | 382 return new Response(false, 699, null); |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
383 } |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
384 |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
385 /** |
628
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
386 * Delete an existing Status object by id. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
387 * <p> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
388 * The id is appended to the URL as a path parameter. |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
389 * <p> |
21a49dc9984d
Code documentation.
Raimund Renkert <rrenkert@intevation.de>
parents:
601
diff
changeset
|
390 * Example: http://example.com/status/{id} |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
391 * |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
392 * @return Response object. |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
393 */ |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
394 @DELETE |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
395 @Path("/{id}") |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
396 @Produces(MediaType.APPLICATION_JSON) |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
397 public Response delete( |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
398 @Context HttpHeaders headers, |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
399 @Context HttpServletRequest request, |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
400 @PathParam("id") String id |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
401 ) { |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
402 /* Get the object by id*/ |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
403 Response object = |
745
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
404 defaultRepo.getById(LStatusProtokoll.class, Integer.valueOf(id), "land"); |
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
405 LStatusProtokoll obj = (LStatusProtokoll)object.getData(); |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
406 if (!authorization.isAuthorized( |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
407 request, |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
408 obj, |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
409 RequestMethod.DELETE, |
745
e2a78d5afaaa
Updated model and services for the new status workflow.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
722
diff
changeset
|
410 LStatusProtokoll.class) |
582
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
411 ) { |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
412 return new Response(false, 699, null); |
a04658486ede
Use authentication info for authorization of requested objects.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
557
diff
changeset
|
413 } |
595
746e03da9fad
Use timestamp locker in REST services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
582
diff
changeset
|
414 if (lock.isLocked(obj)) { |
746e03da9fad
Use timestamp locker in REST services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
582
diff
changeset
|
415 return new Response(false, 697, null); |
746e03da9fad
Use timestamp locker in REST services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
582
diff
changeset
|
416 } |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
417 /* Delete the object*/ |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
418 return defaultRepo.delete(obj, "land"); |
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
419 } |
839
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
420 |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
421 private Response resetStatus( |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
422 LStatusProtokoll status, |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
423 LStatusProtokoll currentStatus, |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
424 LMessung messung |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
425 ) { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
426 // Create a new Status with value = 8. |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
427 LStatusProtokoll statusNew = new LStatusProtokoll(); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
428 statusNew.setDatum(new Timestamp(new Date().getTime())); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
429 statusNew.setErzeuger(status.getErzeuger()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
430 statusNew.setMessungsId(status.getMessungsId()); |
940
dfb0d6f2b140
Avoid NPE in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
921
diff
changeset
|
431 if (status.getStatusStufe() == null) { |
dfb0d6f2b140
Avoid NPE in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
921
diff
changeset
|
432 statusNew.setStatusStufe(currentStatus.getStatusStufe()); |
dfb0d6f2b140
Avoid NPE in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
921
diff
changeset
|
433 } |
dfb0d6f2b140
Avoid NPE in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
921
diff
changeset
|
434 else { |
dfb0d6f2b140
Avoid NPE in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
921
diff
changeset
|
435 statusNew.setStatusStufe(status.getStatusStufe()); |
dfb0d6f2b140
Avoid NPE in status service.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
921
diff
changeset
|
436 } |
839
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
437 statusNew.setStatusWert(8); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
438 statusNew.setText("Reset"); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
439 |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
440 defaultRepo.create(statusNew, "land"); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
441 |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
442 Response retValue; |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
443 if (currentStatus.getStatusStufe() == 1) { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
444 LStatusProtokoll nV = new LStatusProtokoll(); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
445 nV.setDatum(new Timestamp(new Date().getTime())); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
446 nV.setErzeuger(status.getErzeuger()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
447 nV.setMessungsId(status.getMessungsId()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
448 nV.setStatusStufe(1); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
449 nV.setStatusWert(0); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
450 nV.setText(""); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
451 retValue = defaultRepo.create(nV, "land"); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
452 messung.setStatus(((LStatusProtokoll)retValue.getData()).getId()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
453 } |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
454 else { |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
455 QueryBuilder<LStatusProtokoll> lastFilter = |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
456 new QueryBuilder<LStatusProtokoll>( |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
457 defaultRepo.entityManager("land"), |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
458 LStatusProtokoll.class); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
459 lastFilter.and("messungsId", status.getMessungsId()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
460 lastFilter.and("statusStufe", status.getStatusStufe() - 1); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
461 lastFilter.orderBy("datum", true); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
462 List<LStatusProtokoll> proto = |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
463 defaultRepo.filterPlain(lastFilter.getQuery(), "land"); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
464 LStatusProtokoll copy = new LStatusProtokoll(); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
465 LStatusProtokoll orig = proto.get(proto.size() - 1); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
466 copy.setDatum(new Timestamp(new Date().getTime())); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
467 copy.setErzeuger(orig.getErzeuger()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
468 copy.setMessungsId(orig.getMessungsId()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
469 copy.setStatusStufe(orig.getStatusStufe()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
470 copy.setStatusWert(orig.getStatusWert()); |
863
e701e2df6516
Set empty text as comment in copied status.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
860
diff
changeset
|
471 copy.setText(""); |
839
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
472 retValue = defaultRepo.create(copy, "land"); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
473 LStatusProtokoll createdCopy = (LStatusProtokoll)retValue.getData(); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
474 messung.setStatus(createdCopy.getId()); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
475 } |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
476 defaultRepo.update(messung, "land"); |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
477 return retValue; |
2203e5d76071
Updated statusworkflow and use new value 'zurückgesetzt'.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
823
diff
changeset
|
478 } |
488
c1b0f4217488
Added status services.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
479 } |