# HG changeset patch # User Raimund Renkert # Date 1424771534 -3600 # Node ID 23130e40e5b7d73942ef7b93f801882ca074ed36 # Parent ce6964c274105fdc399e03c393e4330517ae8729 Added interfaces classes and annotations used for validation. diff -r ce6964c27410 -r 23130e40e5b7 src/main/java/de/intevation/lada/validation/Validator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/validation/Validator.java Tue Feb 24 10:52:14 2015 +0100 @@ -0,0 +1,18 @@ +/* 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; + + +/** + * + * @author Raimund Renkert + */ +public interface Validator { + + public Violation validate(Object object); +} diff -r ce6964c27410 -r 23130e40e5b7 src/main/java/de/intevation/lada/validation/Violation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/validation/Violation.java Tue Feb 24 10:52:14 2015 +0100 @@ -0,0 +1,59 @@ +/* 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 java.util.HashMap; +import java.util.Map; + +/** + * + * @author Raimund Renkert + */ +public class Violation { + + private Map warnings; + + private Map errors; + + public Violation() { + this.warnings = new HashMap(); + this.errors = new HashMap(); + } + + public Map getWarnings() { + return this.warnings; + } + + public Map getErrors() { + return this.errors; + } + + public void addWarning(String key, Integer value) { + this.warnings.put(key, value); + } + + public void addError(String key, Integer value) { + this.errors.put(key, value); + } + + public void addWarnings(Map warnings) { + this.warnings.putAll(warnings); + } + + public void addErrors(Map errors) { + this.errors.putAll(errors); + } + + public boolean hasWarnings() { + return this.warnings.size() > 0; + } + + public boolean hasErrors() { + return this.errors.size() > 0; + } +} diff -r ce6964c27410 -r 23130e40e5b7 src/main/java/de/intevation/lada/validation/annotation/ValidationConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/validation/annotation/ValidationConfig.java Tue Feb 24 10:52:14 2015 +0100 @@ -0,0 +1,31 @@ +/* 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.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + + +/** + * + * @author Raimund Renkert + */ +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ + ElementType.TYPE, + ElementType.FIELD, + ElementType.METHOD, + ElementType.PARAMETER}) +public @interface ValidationConfig { + String type() default ""; +} diff -r ce6964c27410 -r 23130e40e5b7 src/main/java/de/intevation/lada/validation/annotation/ValidationRule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/validation/annotation/ValidationRule.java Tue Feb 24 10:52:14 2015 +0100 @@ -0,0 +1,31 @@ +/* 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.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + + +/** + * + * @author Raimund Renkert + */ +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ + ElementType.TYPE, + ElementType.FIELD, + ElementType.METHOD, + ElementType.PARAMETER}) +public @interface ValidationRule { + String value() default ""; +} diff -r ce6964c27410 -r 23130e40e5b7 src/main/java/de/intevation/lada/validation/rules/Rule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/validation/rules/Rule.java Tue Feb 24 10:52:14 2015 +0100 @@ -0,0 +1,19 @@ +/* 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; + +import de.intevation.lada.validation.Violation; + +/** + * + * @author Raimund Renkert + */ +public interface Rule { + + public Violation execute(Object object); +}