[Lada-commits] [PATCH 10 of 10] Added more rules for probe validation

Wald Commits scm-commit at wald.intevation.org
Tue Feb 24 14:57:52 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1424786300 -3600
# Node ID 8215619b208e27ec7f682d0cb347f9b465bc5f91
# Parent  2cff9c6c4a9ea0ffe2ef66fd9210f825f82cc54d
Added more rules for probe validation.

diff -r 2cff9c6c4a9e -r 8215619b208e src/main/java/de/intevation/lada/validation/rules/probe/HasUmwelt.java
--- /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;
+
+ at 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;
+    }
+}
diff -r 2cff9c6c4a9e -r 8215619b208e src/main/java/de/intevation/lada/validation/rules/probe/TimeProbeentnahmeBegin.java
--- /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;
+
+ at 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;
+    }
+}


More information about the Lada-commits mailing list