changeset 1228:22d2123e1d2a

Validate new Ort imported via LAF.
author Tom Gottfried <tom@intevation.de>
date Fri, 09 Dec 2016 16:55:32 +0100
parents a0968660a4c5
children 1965e26ef8b5
files src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java	Fri Dec 09 16:34:44 2016 +0100
+++ b/src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java	Fri Dec 09 16:55:32 2016 +0100
@@ -78,6 +78,10 @@
     private Validator messungValidator;
 
     @Inject
+    @ValidationConfig(type="Ort")
+    private Validator ortValidator;
+
+    @Inject
     @IdentifierConfig(type="Probe")
     private Identifier probeIdentifier;
 
@@ -837,6 +841,26 @@
                 ort.setOzId(zusatz.getOzsId());
             }
         }
+
+        Violation violation = ortValidator.validate(ort);
+        for (Entry<String, List<Integer>> warn :
+                 violation.getWarnings().entrySet()) {
+            for (Integer code : warn.getValue()) {
+                currentWarnings.add(
+                    new ReportItem("validation", warn.getKey(), code));
+            }
+        }
+        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));
+                }
+            }
+            return null;
+        }
+
         ortFactory.transformCoordinates(ort);
         if (hasKoord && !hasGem) {
             logger.debug("find Verwaltungseinheit");
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)