changeset 534:23130e40e5b7

Added interfaces classes and annotations used for validation.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 24 Feb 2015 10:52:14 +0100
parents ce6964c27410
children 1d4d6112ffee
files src/main/java/de/intevation/lada/validation/Validator.java src/main/java/de/intevation/lada/validation/Violation.java src/main/java/de/intevation/lada/validation/annotation/ValidationConfig.java src/main/java/de/intevation/lada/validation/annotation/ValidationRule.java src/main/java/de/intevation/lada/validation/rules/Rule.java
diffstat 5 files changed, 158 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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 <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public interface Validator {
+
+    public Violation validate(Object object);
+}
--- /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 <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public class Violation {
+
+    private Map<String, Integer> warnings;
+
+    private Map<String, Integer> errors;
+
+    public Violation() {
+        this.warnings = new HashMap<String, Integer>();
+        this.errors = new HashMap<String, Integer>();
+    }
+
+    public Map<String, Integer> getWarnings() {
+        return this.warnings;
+    }
+
+    public Map<String, Integer> 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<String, Integer> warnings) {
+        this.warnings.putAll(warnings);
+    }
+
+    public void addErrors(Map<String, Integer> errors) {
+        this.errors.putAll(errors);
+    }
+
+    public boolean hasWarnings() {
+        return this.warnings.size() > 0;
+    }
+
+    public boolean hasErrors() {
+        return this.errors.size() > 0;
+    }
+}
--- /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 <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target({
+    ElementType.TYPE,
+    ElementType.FIELD,
+    ElementType.METHOD,
+    ElementType.PARAMETER})
+public @interface ValidationConfig {
+    String type() default "";
+}
--- /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 <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target({
+    ElementType.TYPE,
+    ElementType.FIELD,
+    ElementType.METHOD,
+    ElementType.PARAMETER})
+public @interface ValidationRule {
+    String value() default "";
+}
--- /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 <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public interface Rule {
+
+    public Violation execute(Object object);
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)