changeset 1250:75692dc7077f

Make transformed coordinates available for validation.
author Tom Gottfried <tom@intevation.de>
date Fri, 16 Dec 2016 16:20:19 +0100
parents f094aca05cf2
children 3d0d401b9d9a
files src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java src/main/java/de/intevation/lada/rest/stamm/OrtService.java
diffstat 2 files changed, 28 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java	Fri Dec 16 16:18:37 2016 +0100
+++ b/src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java	Fri Dec 16 16:20:19 2016 +0100
@@ -842,6 +842,16 @@
             }
         }
 
+        ortFactory.transformCoordinates(ort);
+        if (hasKoord && !hasGem) {
+            ortFactory.findVerwaltungseinheit(ort);
+        }
+        if (ortFactory.hasErrors()) {
+            // Add to warnings because Probe object might be imported
+            currentWarnings.addAll(ortFactory.getErrors());
+            return null;
+        }
+
         Violation violation = ortValidator.validate(ort);
         for (Entry<String, List<Integer>> warn :
                  violation.getWarnings().entrySet()) {
@@ -862,17 +872,6 @@
             return null;
         }
 
-        ortFactory.transformCoordinates(ort);
-        if (hasKoord && !hasGem) {
-            logger.debug("find Verwaltungseinheit");
-            ortFactory.findVerwaltungseinheit(ort);
-        }
-        if (ortFactory.hasErrors()) {
-            // Add to warnings because Probe object might be imported
-            currentWarnings.addAll(ortFactory.getErrors());
-            return null;
-        }
-
         repository.create(ort, "stamm");
         return ort;
     }
--- a/src/main/java/de/intevation/lada/rest/stamm/OrtService.java	Fri Dec 16 16:18:37 2016 +0100
+++ b/src/main/java/de/intevation/lada/rest/stamm/OrtService.java	Fri Dec 16 16:20:19 2016 +0100
@@ -271,14 +271,6 @@
             return new Response(false, 699, ort);
         }
 
-        Violation violation = validator.validate(ort);
-        if (violation.hasErrors()) {
-            Response response = new Response(false, 604, ort);
-            response.setErrors(violation.getErrors());
-            response.setWarnings(violation.getWarnings());
-            return response;
-        }
-
         ortFactory.transformCoordinates(ort);
         if (ortFactory.hasErrors()) {
             Violation factoryErrs = new Violation();
@@ -289,6 +281,15 @@
             response.setErrors(factoryErrs.getErrors());
             return response;
         }
+
+        Violation violation = validator.validate(ort);
+        if (violation.hasErrors()) {
+            Response response = new Response(false, 604, ort);
+            response.setErrors(violation.getErrors());
+            response.setWarnings(violation.getWarnings());
+            return response;
+        }
+
         Response response = repository.create(ort, "stamm");
         if(violation.hasWarnings()) {
             response.setWarnings(violation.getWarnings());
@@ -341,14 +342,6 @@
             return new Response(false, 699, ort);
         }
 
-        Violation violation = validator.validate(ort);
-        if (violation.hasErrors()) {
-            Response response = new Response(false, 604, ort);
-            response.setErrors(violation.getErrors());
-            response.setWarnings(violation.getWarnings());
-            return response;
-        }
-
         ortFactory.transformCoordinates(ort);
         if (ortFactory.hasErrors()) {
             Violation factoryErrs = new Violation();
@@ -359,6 +352,15 @@
             response.setErrors(factoryErrs.getErrors());
             return response;
         }
+
+        Violation violation = validator.validate(ort);
+        if (violation.hasErrors()) {
+            Response response = new Response(false, 604, ort);
+            response.setErrors(violation.getErrors());
+            response.setWarnings(violation.getWarnings());
+            return response;
+        }
+
         Response response = repository.update(ort, "stamm");
         if(violation.hasWarnings()) {
             response.setWarnings(violation.getWarnings());
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)