diff src/main/java/de/intevation/lada/rest/stamm/OrtService.java @ 1250:75692dc7077f

Make transformed coordinates available for validation.
author Tom Gottfried <tom@intevation.de>
date Fri, 16 Dec 2016 16:20:19 +0100
parents e49c006b9076
children 9dfb52db6a0f
line wrap: on
line diff
--- 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)