[Lada-commits] [PATCH 4 of 8] Rename validation of Ortszuordnung

Wald Commits scm-commit at wald.intevation.org
Fri Dec 9 16:58:40 CET 2016


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1481294055 -3600
# Node ID 73ad827faa8106c89d5d85df525fc80db4d0d608
# Parent  9b8b18c00804be298c14396f3e35cea0f2f4392f
Rename validation of Ortszuordnung.

diff -r 9b8b18c00804 -r 73ad827faa81 src/main/java/de/intevation/lada/rest/OrtService.java
--- a/src/main/java/de/intevation/lada/rest/OrtService.java	Fri Dec 09 14:57:17 2016 +0100
+++ b/src/main/java/de/intevation/lada/rest/OrtService.java	Fri Dec 09 15:34:15 2016 +0100
@@ -108,7 +108,7 @@
     private Authorization authorization;
 
     @Inject
-    @ValidationConfig(type="Ort")
+    @ValidationConfig(type="Ortszuordnung")
     private Validator validator;
 
     /**
diff -r 9b8b18c00804 -r 73ad827faa81 src/main/java/de/intevation/lada/validation/OrtValidator.java
--- a/src/main/java/de/intevation/lada/validation/OrtValidator.java	Fri Dec 09 14:57:17 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details.
- */
-package de.intevation.lada.validation;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Instance;
-import javax.inject.Inject;
-
-import de.intevation.lada.model.land.Ortszuordnung;
-import de.intevation.lada.validation.annotation.ValidationConfig;
-import de.intevation.lada.validation.annotation.ValidationRule;
-import de.intevation.lada.validation.rules.Rule;
-
-/**
- * Validation for ort objects.
- *
- * Instantiates the set of rules for ort objects and uses these rules to
- * validate the object.
- *
- * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
- */
- at ValidationConfig(type="Ort")
- at ApplicationScoped
-public class OrtValidator implements Validator {
-
-    @Inject
-    @ValidationRule("Ort")
-    private Instance<Rule> rules;
-
-    @Override
-    public Violation validate(Object object) {
-        Violation violations = new Violation();
-        if (!(object instanceof Ortszuordnung)) {
-            violations.addError("ort", 602);
-            return violations;
-        }
-        for(Rule rule: rules) {
-            Violation result = rule.execute(object);
-            if (result != null) {
-                if (result.hasWarnings()) {
-                    violations.addWarnings(result.getWarnings());
-                }
-                if (result.hasErrors()) {
-                    violations.addErrors(result.getErrors());
-                }
-            }
-        }
-        return violations;
-    }
-
-}
diff -r 9b8b18c00804 -r 73ad827faa81 src/main/java/de/intevation/lada/validation/OrtszuordnungValidator.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/OrtszuordnungValidator.java	Fri Dec 09 15:34:15 2016 +0100
@@ -0,0 +1,56 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.validation;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+import de.intevation.lada.model.land.Ortszuordnung;
+import de.intevation.lada.validation.annotation.ValidationConfig;
+import de.intevation.lada.validation.annotation.ValidationRule;
+import de.intevation.lada.validation.rules.Rule;
+
+/**
+ * Validation for ort objects.
+ *
+ * Instantiates the set of rules for ort objects and uses these rules to
+ * validate the object.
+ *
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+ at ValidationConfig(type="Ortszuordnung")
+ at ApplicationScoped
+public class OrtszuordnungValidator implements Validator {
+
+    @Inject
+    @ValidationRule("Ortszuordnung")
+    private Instance<Rule> rules;
+
+    @Override
+    public Violation validate(Object object) {
+        Violation violations = new Violation();
+        if (!(object instanceof Ortszuordnung)) {
+            violations.addError("ortszuordnung", 602);
+            return violations;
+        }
+        for(Rule rule: rules) {
+            Violation result = rule.execute(object);
+            if (result != null) {
+                if (result.hasWarnings()) {
+                    violations.addWarnings(result.getWarnings());
+                }
+                if (result.hasErrors()) {
+                    violations.addErrors(result.getErrors());
+                }
+            }
+        }
+        return violations;
+    }
+
+}
diff -r 9b8b18c00804 -r 73ad827faa81 src/main/java/de/intevation/lada/validation/rules/ort/CoordinatesInVE.java
--- a/src/main/java/de/intevation/lada/validation/rules/ort/CoordinatesInVE.java	Fri Dec 09 14:57:17 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details.
- */
-package de.intevation.lada.validation.rules.ort;
-
-import java.util.List;
-
-import javax.inject.Inject;
-
-import com.vividsolutions.jts.geom.Point;
-
-import de.intevation.lada.model.land.Ortszuordnung;
-import de.intevation.lada.model.stammdaten.Ort;
-import de.intevation.lada.model.stammdaten.Verwaltungseinheit;
-import de.intevation.lada.model.stammdaten.Verwaltungsgrenze;
-import de.intevation.lada.util.annotation.RepositoryConfig;
-import de.intevation.lada.util.data.QueryBuilder;
-import de.intevation.lada.util.data.Repository;
-import de.intevation.lada.util.data.RepositoryType;
-import de.intevation.lada.validation.Violation;
-import de.intevation.lada.validation.annotation.ValidationRule;
-import de.intevation.lada.validation.rules.Rule;
-
-/**
- * Validation rule for ort.
- * Validates if the coordinates are in the specified "Verwaltungseinheit".
- *
- * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
- */
- at ValidationRule("Ort")
-public class CoordinatesInVE implements Rule {
-
-    @Inject
-    @RepositoryConfig(type=RepositoryType.RO)
-    private Repository repository;
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Violation execute(Object object) {
-        Ortszuordnung oz = (Ortszuordnung)object;
-        if (!"E".equals(oz.getOrtszuordnungTyp())) {
-            return null;
-        }
-
-        Ort ort = repository.getByIdPlain(Ort.class, oz.getOrtId(), "stamm");
-        String gemId = ort.getGemId();
-        if (gemId == null) {
-            Violation violation = new Violation();
-            violation.addWarning("gemId", 631);
-            return violation;
-        }
-
-        QueryBuilder<Verwaltungsgrenze> vg =
-            new QueryBuilder<Verwaltungsgrenze>(
-                repository.entityManager("stamm"), Verwaltungsgrenze.class);
-        vg.and("gemId", gemId);
-        List<Verwaltungsgrenze> vgs = repository.filterPlain(
-            vg.getQuery(), "stamm");
-        if (vgs == null || vgs.isEmpty()) {
-            Violation violation = new Violation();
-            violation.addWarning("verwaltungsgrenze", 600);
-            return violation;
-        }
-
-        Point p = ort.getGeom();
-        boolean hit = false;
-        for (Verwaltungsgrenze singlevg : vgs) {
-            if(singlevg.getShape().contains(p)) {
-                hit = true;
-            }
-        }
-        if (!hit) {
-            Violation violation = new Violation();
-            violation.addWarning("verwaltungsgrenze", 651);
-            return violation;
-        }
-        return null;
-    }
-
-}
diff -r 9b8b18c00804 -r 73ad827faa81 src/main/java/de/intevation/lada/validation/rules/ort/EntnahmeortToVE.java
--- a/src/main/java/de/intevation/lada/validation/rules/ort/EntnahmeortToVE.java	Fri Dec 09 14:57:17 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details.
- */
-package de.intevation.lada.validation.rules.ort;
-
-import de.intevation.lada.validation.Violation;
-import de.intevation.lada.validation.annotation.ValidationRule;
-import de.intevation.lada.validation.rules.Rule;
-
- at ValidationRule("Ort")
-public class EntnahmeortToVE implements Rule {
-
-    @Override
-    public Violation execute(Object object) {
-        // TODO
-        return null;
-    }
-
-}
diff -r 9b8b18c00804 -r 73ad827faa81 src/main/java/de/intevation/lada/validation/rules/ort/HasEntnahmeOrt.java
--- a/src/main/java/de/intevation/lada/validation/rules/ort/HasEntnahmeOrt.java	Fri Dec 09 14:57:17 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU GPL (v>=3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out
- * the documentation coming with IMIS-Labordaten-Application for details.
- */
-package de.intevation.lada.validation.rules.ort;
-
-import java.util.List;
-
-import javax.inject.Inject;
-
-import de.intevation.lada.model.land.Ortszuordnung;
-import de.intevation.lada.util.annotation.RepositoryConfig;
-import de.intevation.lada.util.data.QueryBuilder;
-import de.intevation.lada.util.data.Repository;
-import de.intevation.lada.util.data.RepositoryType;
-import de.intevation.lada.validation.Violation;
-import de.intevation.lada.validation.annotation.ValidationRule;
-import de.intevation.lada.validation.rules.Rule;
-
- at ValidationRule("Ort")
-public class HasEntnahmeOrt implements Rule {
-
-    @Inject
-    @RepositoryConfig(type=RepositoryType.RO)
-    private Repository repository;
-
-    @Override
-    public Violation execute(Object object) {
-        Ortszuordnung ort = (Ortszuordnung)object;
-        if (!"E".equals(ort.getOrtszuordnungTyp())) {
-            return null;
-        }
-
-        QueryBuilder<Ortszuordnung> builder = new QueryBuilder<Ortszuordnung>(
-            repository.entityManager("land"),
-            Ortszuordnung.class);
-        builder.and("probeId", ort.getProbeId());
-        List<Ortszuordnung> orte = repository.filterPlain(
-            builder.getQuery(),
-            "land");
-        for (Ortszuordnung o : orte) {
-            if ("E".equals(o.getOrtszuordnungTyp()) &&
-                !o.getId().equals(ort.getId())
-            ) {
-                Violation violation = new Violation();
-                violation.addError("ortszuordnungsTyp", 611);
-                return violation;
-            }
-        }
-
-        return null;
-    }
-}
diff -r 9b8b18c00804 -r 73ad827faa81 src/main/java/de/intevation/lada/validation/rules/ortszuordnung/CoordinatesInVE.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/rules/ortszuordnung/CoordinatesInVE.java	Fri Dec 09 15:34:15 2016 +0100
@@ -0,0 +1,84 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.validation.rules.ort;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import com.vividsolutions.jts.geom.Point;
+
+import de.intevation.lada.model.land.Ortszuordnung;
+import de.intevation.lada.model.stammdaten.Ort;
+import de.intevation.lada.model.stammdaten.Verwaltungseinheit;
+import de.intevation.lada.model.stammdaten.Verwaltungsgrenze;
+import de.intevation.lada.util.annotation.RepositoryConfig;
+import de.intevation.lada.util.data.QueryBuilder;
+import de.intevation.lada.util.data.Repository;
+import de.intevation.lada.util.data.RepositoryType;
+import de.intevation.lada.validation.Violation;
+import de.intevation.lada.validation.annotation.ValidationRule;
+import de.intevation.lada.validation.rules.Rule;
+
+/**
+ * Validation rule for ort.
+ * Validates if the coordinates are in the specified "Verwaltungseinheit".
+ *
+ * @author <a href="mailto:rrenkert at intevation.de">Raimund Renkert</a>
+ */
+ at ValidationRule("Ortszuordnung")
+public class CoordinatesInVE implements Rule {
+
+    @Inject
+    @RepositoryConfig(type=RepositoryType.RO)
+    private Repository repository;
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Violation execute(Object object) {
+        Ortszuordnung oz = (Ortszuordnung)object;
+        if (!"E".equals(oz.getOrtszuordnungTyp())) {
+            return null;
+        }
+
+        Ort ort = repository.getByIdPlain(Ort.class, oz.getOrtId(), "stamm");
+        String gemId = ort.getGemId();
+        if (gemId == null) {
+            Violation violation = new Violation();
+            violation.addWarning("gemId", 631);
+            return violation;
+        }
+
+        QueryBuilder<Verwaltungsgrenze> vg =
+            new QueryBuilder<Verwaltungsgrenze>(
+                repository.entityManager("stamm"), Verwaltungsgrenze.class);
+        vg.and("gemId", gemId);
+        List<Verwaltungsgrenze> vgs = repository.filterPlain(
+            vg.getQuery(), "stamm");
+        if (vgs == null || vgs.isEmpty()) {
+            Violation violation = new Violation();
+            violation.addWarning("verwaltungsgrenze", 600);
+            return violation;
+        }
+
+        Point p = ort.getGeom();
+        boolean hit = false;
+        for (Verwaltungsgrenze singlevg : vgs) {
+            if(singlevg.getShape().contains(p)) {
+                hit = true;
+            }
+        }
+        if (!hit) {
+            Violation violation = new Violation();
+            violation.addWarning("verwaltungsgrenze", 651);
+            return violation;
+        }
+        return null;
+    }
+
+}
diff -r 9b8b18c00804 -r 73ad827faa81 src/main/java/de/intevation/lada/validation/rules/ortszuordnung/EntnahmeortToVE.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/rules/ortszuordnung/EntnahmeortToVE.java	Fri Dec 09 15:34:15 2016 +0100
@@ -0,0 +1,23 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.validation.rules.ort;
+
+import de.intevation.lada.validation.Violation;
+import de.intevation.lada.validation.annotation.ValidationRule;
+import de.intevation.lada.validation.rules.Rule;
+
+ at ValidationRule("Ortszuordnung")
+public class EntnahmeortToVE implements Rule {
+
+    @Override
+    public Violation execute(Object object) {
+        // TODO
+        return null;
+    }
+
+}
diff -r 9b8b18c00804 -r 73ad827faa81 src/main/java/de/intevation/lada/validation/rules/ortszuordnung/HasEntnahmeOrt.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/rules/ortszuordnung/HasEntnahmeOrt.java	Fri Dec 09 15:34:15 2016 +0100
@@ -0,0 +1,56 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.validation.rules.ort;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import de.intevation.lada.model.land.Ortszuordnung;
+import de.intevation.lada.util.annotation.RepositoryConfig;
+import de.intevation.lada.util.data.QueryBuilder;
+import de.intevation.lada.util.data.Repository;
+import de.intevation.lada.util.data.RepositoryType;
+import de.intevation.lada.validation.Violation;
+import de.intevation.lada.validation.annotation.ValidationRule;
+import de.intevation.lada.validation.rules.Rule;
+
+ at ValidationRule("Ortszuordnung")
+public class HasEntnahmeOrt implements Rule {
+
+    @Inject
+    @RepositoryConfig(type=RepositoryType.RO)
+    private Repository repository;
+
+    @Override
+    public Violation execute(Object object) {
+        Ortszuordnung ort = (Ortszuordnung)object;
+        if (!"E".equals(ort.getOrtszuordnungTyp())) {
+            return null;
+        }
+
+        QueryBuilder<Ortszuordnung> builder = new QueryBuilder<Ortszuordnung>(
+            repository.entityManager("land"),
+            Ortszuordnung.class);
+        builder.and("probeId", ort.getProbeId());
+        List<Ortszuordnung> orte = repository.filterPlain(
+            builder.getQuery(),
+            "land");
+        for (Ortszuordnung o : orte) {
+            if ("E".equals(o.getOrtszuordnungTyp()) &&
+                !o.getId().equals(ort.getId())
+            ) {
+                Violation violation = new Violation();
+                violation.addError("ortszuordnungsTyp", 611);
+                return violation;
+            }
+        }
+
+        return null;
+    }
+}


More information about the Lada-commits mailing list