[Lada-commits] [PATCH 2 of 3] Added validator for ort objects
Wald Commits
scm-commit at wald.intevation.org
Tue May 5 14:23:15 CEST 2015
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1430828625 -7200
# Node ID 0086dc4ac72e68c85e8bd6605ef7a38e91ae3883
# Parent 55177afef263babbf762b4c317b25b3eceed8c11
Added validator for ort objects.
diff -r 55177afef263 -r 0086dc4ac72e src/main/java/de/intevation/lada/validation/OrtValidator.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/OrtValidator.java Tue May 05 14:23:45 2015 +0200
@@ -0,0 +1,41 @@
+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.LOrt;
+import de.intevation.lada.validation.annotation.ValidationConfig;
+import de.intevation.lada.validation.annotation.ValidationRule;
+import de.intevation.lada.validation.rules.Rule;
+
+ 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 LOrt)) {
+ 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;
+ }
+
+}
More information about the Lada-commits
mailing list