[Lada-commits] [PATCH 11 of 11] Updated messung validator
Wald Commits
scm-commit at wald.intevation.org
Fri Mar 13 16:50:50 CET 2015
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1426261867 -3600
# Node ID 044810451b028e37f31f3830aa44e0e8fd102336
# Parent f3f8b8a26afadd0dcb27084a2b439659740b2f78
Updated messung validator.
diff -r f3f8b8a26afa -r 044810451b02 src/main/java/de/intevation/lada/validation/MessungValidator.java
--- 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;
+
+ at ValidationConfig(type="Messung")
+ at 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;
+ }
+}
More information about the Lada-commits
mailing list