[Lada-commits] [PATCH 1 of 3] Fixed status and messung services

Wald Commits scm-commit at wald.intevation.org
Fri Nov 13 13:42:22 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1447418425 -3600
# Node ID 574391f1d88f355d9b32a4509263222f9856cfba
# Parent  e3f4f3585ccea51749b49f9b8632cfd9692a2ef2
Fixed status and messung services.

diff -r e3f4f3585cce -r 574391f1d88f src/main/java/de/intevation/lada/rest/StatusService.java
--- a/src/main/java/de/intevation/lada/rest/StatusService.java	Thu Nov 12 13:28:08 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/StatusService.java	Fri Nov 13 13:40:25 2015 +0100
@@ -196,31 +196,36 @@
         UserInfo userInfo = authorization.getInfo(request);
         LMessung messung = defaultRepo.getByIdPlain(
             LMessung.class, status.getMessungsId(), "land");
-        LStatusProtokoll currentStatus = defaultRepo.getByIdPlain(
-            LStatusProtokoll.class, messung.getStatus(), "land");
         boolean next = false;
         boolean change = false;
-        for (int i = 0; i < userInfo.getFunktionen().size(); i++) {
-            if (userInfo.getFunktionen().get(i) > currentStatus.getStatusStufe()) {
-                next = true;
-                change = false;
-                break;
-            }
-            else if (userInfo.getFunktionen().get(i) == currentStatus.getStatusStufe()) {
-                change = true;
-            }
-        }
-        if ((change || next) && status.getStatusWert() == 4) {
+        if (messung.getStatus() == null) {
             status.setStatusStufe(1);
         }
-        else if (change) {
-            status.setStatusStufe(currentStatus.getStatusStufe());
-        }
-        else if (next) {
-            status.setStatusStufe(currentStatus.getStatusStufe() + 1);
-        }
         else {
-            return new Response(false, 699, null);
+            LStatusProtokoll currentStatus = defaultRepo.getByIdPlain(
+                LStatusProtokoll.class, messung.getStatus(), "land");
+            for (int i = 0; i < userInfo.getFunktionen().size(); i++) {
+                if (userInfo.getFunktionen().get(i) > currentStatus.getStatusStufe()) {
+                    next = true;
+                    change = false;
+                    break;
+                }
+                else if (userInfo.getFunktionen().get(i) == currentStatus.getStatusStufe()) {
+                    change = true;
+                }
+            }
+            if ((change || next) && status.getStatusWert() == 4) {
+                status.setStatusStufe(1);
+            }
+            else if (change) {
+                status.setStatusStufe(currentStatus.getStatusStufe());
+            }
+            else if (next) {
+                status.setStatusStufe(currentStatus.getStatusStufe() + 1);
+            }
+            else {
+                return new Response(false, 699, null);
+            }
         }
         Response response = defaultRepo.create(status, "land");
         LStatusProtokoll created = (LStatusProtokoll)response.getData();
@@ -263,20 +268,9 @@
         @Context HttpServletRequest request,
         LStatusProtokoll status
     ) {
-        if (!authorization.isAuthorized(
-                request,
-                status,
-                RequestMethod.PUT,
-                LStatusProtokoll.class)
-        ) {
-            return new Response(false, 699, null);
-        }
         if (lock.isLocked(status)) {
             return new Response(false, 697, null);
         }
-        if (status.getStatusWert() == 0) {
-            return new Response(false, 699, null);
-        }
 
         UserInfo userInfo = authorization.getInfo(request);
         if (!userInfo.getMessstellen().contains(status.getErzeuger())) {
diff -r e3f4f3585cce -r 574391f1d88f src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java
--- a/src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java	Thu Nov 12 13:28:08 2015 +0100
+++ b/src/main/java/de/intevation/lada/rest/stamm/StatusWertService.java	Fri Nov 13 13:40:25 2015 +0100
@@ -134,6 +134,9 @@
         List<StatusWert> list = new ArrayList<StatusWert>();
         LMessung messung =
             defaultRepo.getByIdPlain(LMessung.class, messungsId, "land");
+        if (messung.getStatus() == null) {
+            return defaultRepo.getAllPlain(StatusWert.class, "stamm");
+        }
         StatusProtokoll status = defaultRepo.getByIdPlain(
             StatusProtokoll.class,
             messung.getStatus(),


More information about the Lada-commits mailing list