[Lada-commits] [PATCH 2 of 2] merged

Wald Commits scm-commit at wald.intevation.org
Fri Oct 28 10:54:29 CEST 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1477644864 -7200
# Node ID a3d47e0e30a21e8e4564701e838654337fc7e39a
# Parent  430bbc8166d6d4ef106b1e902fbce7b571dd998b
# Parent  2f42a7607bbdbc5731c3c16e91d90a9575f12858
merged.

diff -r 430bbc8166d6 -r a3d47e0e30a2 db_schema/stammdaten_schema.sql
--- a/db_schema/stammdaten_schema.sql	Fri Oct 28 10:53:40 2016 +0200
+++ b/db_schema/stammdaten_schema.sql	Fri Oct 28 10:54:24 2016 +0200
@@ -556,7 +556,6 @@
     wert_id integer REFERENCES status_wert NOT NULL,
     UNIQUE(stufe_id, wert_id)
 );
--- 'zurückgesetzt' is left out here deliberately!
 INSERT INTO status_kombi VALUES (1, 1, 0);
 INSERT INTO status_kombi VALUES (2, 1, 1);
 INSERT INTO status_kombi VALUES (3, 1, 2);
@@ -570,6 +569,9 @@
 INSERT INTO status_kombi VALUES (11, 3, 2);
 INSERT INTO status_kombi VALUES (12, 3, 3);
 INSERT INTO status_kombi VALUES (13, 3, 4);
+INSERT INTO status_kombi VALUES (14, 1, 8);
+INSERT INTO status_kombi VALUES (15, 2, 8);
+INSERT INTO status_kombi VALUES (16, 3, 8);
 
 
 CREATE TABLE status_reihenfolge (
@@ -602,9 +604,12 @@
            INSERT INTO status_reihenfolge (von_id, zu_id)
                   VALUES (kombi_from.id, kombi_to.id);
 
-        ELSEIF s_to = s_from + 1 AND w_from <> 0 AND w_from <> 4 THEN
+        ELSEIF s_to = s_from + 1
+               AND w_from <> 0 AND w_from <> 4
+               AND w_from <> 8 AND w_to <> 8 THEN
            -- Going to the next 'stufe' all available status_kombi are allowed
-           -- in case current wert is not 'nicht vergeben' or 'Rückfrage'
+           -- in case current wert is not 'nicht vergeben', 'Rückfrage' or
+           -- 'zurückgesetzt' and we are not trying to set 'zurückgesetzt'
            INSERT INTO status_reihenfolge (von_id, zu_id)
                   VALUES (kombi_from.id, kombi_to.id);
 
@@ -614,6 +619,16 @@
            INSERT INTO status_reihenfolge (von_id, zu_id)
                   VALUES (kombi_from.id, kombi_to.id);
 
+        ELSEIF w_to = 8 AND s_from = s_to THEN
+           -- 'zurückgesetzt' can only be set on the same 'stufe'
+           INSERT INTO status_reihenfolge (von_id, zu_id)
+                  VALUES (kombi_from.id, kombi_to.id);
+
+        ELSEIF w_from = 8 AND s_to = s_from - 1 THEN
+           -- after 'zurückgesetzt' always follows the next lower 'stufe'
+           INSERT INTO status_reihenfolge (von_id, zu_id)
+                  VALUES (kombi_from.id, kombi_to.id);
+
         END IF;
     END LOOP;
 END LOOP;
diff -r 430bbc8166d6 -r a3d47e0e30a2 src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java
--- a/src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java	Fri Oct 28 10:53:40 2016 +0200
+++ b/src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java	Fri Oct 28 10:54:24 2016 +0200
@@ -17,7 +17,7 @@
     LafRawData.Probe currentProbe;
     LafRawData.Messung currentMessung;
     Map<String, List<ReportItem>> errors;
-    List<ReportItem> currentErrors;
+    ArrayList<ReportItem> currentErrors;
 
     private boolean hasDatenbasis = false;
     private boolean hasMessprogramm = false;
@@ -94,8 +94,9 @@
                 identifier = identifier == null
                     ? "not identified"
                     : identifier;
-                errors.put(identifier, currentErrors);
+                errors.put(identifier, (ArrayList)currentErrors.clone());
             }
+
             currentErrors.clear();
             currentProbe = null;
             hasDatenbasis = false;
@@ -134,7 +135,7 @@
                 ? currentProbe.getAttributes().get("HAUPTPROBENNUMMER")
                 : identifier;
             identifier = identifier == null ? "not identified" : identifier;
-            errors.put(identifier, currentErrors);
+            errors.put(identifier, (ArrayList)currentErrors.clone());
         }
         currentErrors.clear();
         currentProbe = null;
@@ -1475,7 +1476,7 @@
             err.setKey(ctx.getChild(0).toString());
             err.setValue(value);
             err.setCode(670);
-            currentErrors.add(err);;
+            currentErrors.add(err);
             return;
         }
         // TODO: Add to "ursprungsort"
diff -r 430bbc8166d6 -r a3d47e0e30a2 src/main/java/de/intevation/lada/rest/StatusService.java
--- a/src/main/java/de/intevation/lada/rest/StatusService.java	Fri Oct 28 10:53:40 2016 +0200
+++ b/src/main/java/de/intevation/lada/rest/StatusService.java	Fri Oct 28 10:54:24 2016 +0200
@@ -247,26 +247,20 @@
             status.setStatusKombi(1);
         }
         else {
+            Violation violation = validator.validate(status);
+            if (violation.hasErrors()) {
+                Response response = new Response(false, 604, status);
+                response.setErrors(violation.getErrors());
+                response.setWarnings(violation.getWarnings());
+                return response;
+            }
+
             StatusProtokoll oldStatus = defaultRepo.getByIdPlain(
                 StatusProtokoll.class, messung.getStatus(), "land");
 
             StatusKombi oldKombi = defaultRepo.getByIdPlain(StatusKombi.class, oldStatus.getStatusKombi(), "stamm");
             StatusKombi newKombi = defaultRepo.getByIdPlain(StatusKombi.class, status.getStatusKombi(), "stamm");
 
-            // Check if changing to the requested status_kombi is allowed.
-            QueryBuilder<StatusReihenfolge> builder = new QueryBuilder<StatusReihenfolge>(defaultRepo.entityManager("stamm"), StatusReihenfolge.class);
-            builder.and("vonId", oldStatus.getStatusKombi());
-            List<StatusReihenfolge> reachable = defaultRepo.filterPlain(builder.getQuery(), "stamm");
-            boolean allowed = false;
-            for (int i = 0; i < reachable.size(); i++) {
-                if (reachable.get(i).getZuId() == status.getStatusKombi()) {
-                    allowed = true;
-                }
-            }
-            if (!allowed) {
-                return new Response(false, 604, null);
-            }
-
             // Check if the user is allowed to change to the requested
             // status_kombi
             // 1. The old 'status_wert' is 'rückfrage'


More information about the Lada-commits mailing list