changeset 789:dea5ed4b7fa4

Set the previous status as active status.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 18 Nov 2015 15:38:47 +0100
parents 7133f6114920
children 4262acdd466d
files src/main/java/de/intevation/lada/rest/StatusService.java
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/StatusService.java	Wed Nov 18 15:38:18 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/StatusService.java	Wed Nov 18 15:38:47 2015 +0100
@@ -327,7 +327,22 @@
 
         Response response = defaultRepo.create(statusNew, "land");
         LStatusProtokoll created = (LStatusProtokoll)response.getData();
-        messung.setStatus(created.getId());
+        if (status.getStatusWert() == 0) {
+            QueryBuilder<LStatusProtokoll> lastFilter =
+                new QueryBuilder<LStatusProtokoll>(
+                        defaultRepo.entityManager("land"),
+                        LStatusProtokoll.class);
+
+            lastFilter.and("messungsId", status.getMessungsId());
+            lastFilter.orderBy("datum", false);
+            List<LStatusProtokoll> protos =
+                defaultRepo.filterPlain(lastFilter.getQuery(), "land");
+            messung.setStatus(protos.get(protos.size() - 3).getId());
+        }
+        else {
+            messung.setStatus(created.getId());
+        }
+
         defaultRepo.update(messung, "land");
 
         return authorization.filter(
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)