[Lada-commits] [PATCH 4 of 4] Fixed validation workflow in laf importer

Wald Commits scm-commit at wald.intevation.org
Wed Nov 16 15:59:31 CET 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1479308364 -3600
# Node ID 047a27138af6052425e740efb2d95d4560bf8e73
# Parent  312aaa5d069d5f7da07713fc2091169a068d37b8
Fixed validation workflow in laf importer.

diff -r 312aaa5d069d -r 047a27138af6 src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java
--- a/src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java	Wed Nov 16 15:58:30 2016 +0100
+++ b/src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java	Wed Nov 16 15:59:24 2016 +0100
@@ -153,18 +153,8 @@
             Probe old = (Probe)probeIdentifier.getExisting();
             // Matching probe was found in the db. Update it!
             if(i == Identified.UPDATE) {
-                Violation violation = probeValidator.validate(probe);
-                if (violation.hasErrors()) {
-                    for (Entry<String, List<Integer>> err : violation.getErrors().entrySet()) {
-                        for (Integer code : err.getValue()) {
-                            currentErrors.add(new ReportItem("validation", err.getKey(), code));
-                        }
-                    }
-                }
-                else {
-                    merger.merge(old, probe);
-                    newProbe = old;
-                }
+                merger.merge(old, probe);
+                newProbe = old;
             }
             // Probe was found but some data does not match
             else if(i == Identified.REJECT){
@@ -185,14 +175,7 @@
             // It is a brand new probe!
             else if(i == Identified.NEW){
                 Violation violation = probeValidator.validate(probe);
-                if (violation.hasErrors()) {
-                    for (Entry<String, List<Integer>> err : violation.getErrors().entrySet()) {
-                        for (Integer code : err.getValue()) {
-                            currentErrors.add(new ReportItem("validation", err.getKey(), code));
-                        }
-                    }
-                }
-                else {
+                if (!violation.hasErrors()) {
                     Response created = repository.create(probe, "land");
                     newProbe = ((Probe)created.getData());
                 }
@@ -257,6 +240,11 @@
             }
         }
         Violation violation = probeValidator.validate(newProbe);
+        for (Entry<String, List<Integer>> err : violation.getErrors().entrySet()) {
+            for (Integer code : err.getValue()) {
+                currentErrors.add(new ReportItem("validation", err.getKey(), code));
+            }
+        }
         for (Entry<String, List<Integer>> warn : violation.getWarnings().entrySet()) {
             for (Integer code : warn.getValue()) {
                 currentWarnings.add(new ReportItem("validation", warn.getKey(), code));


More information about the Lada-commits mailing list