changeset 542:8215619b208e

Added more rules for probe validation.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 24 Feb 2015 14:58:20 +0100
parents 2cff9c6c4a9e
children 7a0e3d49ae33
files src/main/java/de/intevation/lada/validation/rules/probe/HasUmwelt.java src/main/java/de/intevation/lada/validation/rules/probe/TimeProbeentnahmeBegin.java
diffstat 2 files changed, 64 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/rules/probe/HasUmwelt.java	Tue Feb 24 14:58:20 2015 +0100
@@ -0,0 +1,22 @@
+package de.intevation.lada.validation.rules.probe;
+
+import de.intevation.lada.model.land.LProbe;
+import de.intevation.lada.validation.Violation;
+import de.intevation.lada.validation.annotation.ValidationRule;
+import de.intevation.lada.validation.rules.Rule;
+
+@ValidationRule("Probe")
+public class HasUmwelt implements Rule {
+
+    @Override
+    public Violation execute(Object object) {
+        LProbe probe = (LProbe)object;
+        if (probe.getUmwId() == null ||
+            probe.getUmwId().equals("")) {
+            Violation violation = new Violation();
+            violation.addWarning("uwb", 631);
+            return violation;
+        }
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/rules/probe/TimeProbeentnahmeBegin.java	Tue Feb 24 14:58:20 2015 +0100
@@ -0,0 +1,42 @@
+package de.intevation.lada.validation.rules.probe;
+
+import java.sql.Timestamp;
+import java.util.Date;
+
+import de.intevation.lada.model.land.LProbe;
+import de.intevation.lada.validation.Violation;
+import de.intevation.lada.validation.annotation.ValidationRule;
+import de.intevation.lada.validation.rules.Rule;
+
+@ValidationRule("Probe")
+public class TimeProbeentnahmeBegin implements Rule {
+
+    @Override
+    public Violation execute(Object object) {
+        LProbe probe = (LProbe)object;
+        Timestamp begin = probe.getProbeentnahmeBeginn();
+        Timestamp end = probe.getProbeentnahmeEnde();
+        if (begin == null && end == null) {
+            return null;
+        }
+        if (begin == null && end != null) {
+            Violation violation = new Violation();
+            violation.addWarning("probeentnahmeBegin", 662);
+            return violation;
+        }
+        if (begin.after(new Date())) {
+            Violation violation = new Violation();
+            violation.addWarning("probeentnahmeBegin", 661);
+            return violation;
+        }
+        if (end == null) {
+            return null;
+        }
+        if (begin.after(end)) {
+            Violation violation = new Violation();
+            violation.addWarning("probeentnahmeBegin", 662);
+            return violation;
+        }
+        return null;
+    }
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)