changeset 566:044810451b02

Updated messung validator.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 13 Mar 2015 16:51:07 +0100
parents f3f8b8a26afa
children e00c40b17a79
files src/main/java/de/intevation/lada/validation/MessungValidator.java
diffstat 1 files changed, 40 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/validation/MessungValidator.java	Fri Mar 13 16:50:20 2015 +0100
+++ b/src/main/java/de/intevation/lada/validation/MessungValidator.java	Fri Mar 13 16:51:07 2015 +0100
@@ -0,0 +1,40 @@
+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.LMessung;
+import de.intevation.lada.validation.annotation.ValidationConfig;
+import de.intevation.lada.validation.annotation.ValidationRule;
+import de.intevation.lada.validation.rules.Rule;
+
+@ValidationConfig(type="Messung")
+@ApplicationScoped
+public class MessungValidator implements Validator {
+
+    @Inject
+    @ValidationRule("Messung")
+    private Instance<Rule> rules;
+
+    @Override
+    public Violation validate(Object object) {
+        Violation violations = new Violation();
+        if (!(object instanceof LMessung)) {
+            violations.addError("messung", 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;
+    }
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)