[Lada-commits] [PATCH 05 of 10] Added validator for probe objects
Wald Commits
scm-commit at wald.intevation.org
Tue Feb 24 14:57:47 CET 2015
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1424771807 -3600
# Node ID f44c9e59f08c174a688b7a9039dfd63af49a89e2
# Parent bf387959b75e85b7ecdb464f89673e31e20e038e
Added validator for probe objects.
diff -r bf387959b75e -r f44c9e59f08c src/main/java/de/intevation/lada/validation/ProbeValidator.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/ProbeValidator.java Tue Feb 24 10:56:47 2015 +0100
@@ -0,0 +1,35 @@
+package de.intevation.lada.validation;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+import de.intevation.lada.validation.annotation.ValidationRule;
+import de.intevation.lada.validation.annotation.ValidationConfig;
+import de.intevation.lada.validation.rules.Rule;
+
+ at ValidationConfig(type="Probe")
+ at ApplicationScoped
+public class ProbeValidator implements Validator {
+
+ @Inject
+ @ValidationRule("Probe")
+ private Instance<Rule> rules;
+
+ @Override
+ public Violation validate(Object object) {
+ Violation violations = new Violation();
+ 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