# HG changeset patch # User Tom Gottfried # Date 1474646182 -7200 # Node ID 3c9616e5439ff90d01aa513d743960c20e7e9898 # Parent a7404bf577fd0168715dbafdd9bf0d133ab32c36 Remove wrong period check. The validity period can be e.g. from November till February, thus spanning over turn of the year and allowing a from value greater than to value (in terms of day of year). diff -r a7404bf577fd -r 3c9616e5439f db_schema/lada_schema.sql --- a/db_schema/lada_schema.sql Thu Sep 22 16:14:57 2016 +0200 +++ b/db_schema/lada_schema.sql Fri Sep 23 17:56:22 2016 +0200 @@ -583,13 +583,12 @@ teilintervall_von integer NOT NULL, teilintervall_bis integer NOT NULL, intervall_offset integer, - gueltig_von integer NOT NULL, - gueltig_bis integer NOT NULL, + gueltig_von integer NOT NULL CHECK(gueltig_von BETWEEN 0 AND 364), + gueltig_bis integer NOT NULL CHECK(gueltig_bis BETWEEN 0 AND 364), probe_nehmer_id integer, probe_kommentar character varying(80), letzte_aenderung timestamp without time zone DEFAULT now() NOT NULL, - CHECK (teilintervall_von <= teilintervall_bis), - CHECK (gueltig_von <= gueltig_bis) + CHECK (teilintervall_von <= teilintervall_bis) ); CREATE TRIGGER letzte_aenderung_messprogramm BEFORE UPDATE ON messprogramm FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung(); diff -r a7404bf577fd -r 3c9616e5439f src/main/java/de/intevation/lada/validation/rules/messprogramm/ValidFromTo.java --- a/src/main/java/de/intevation/lada/validation/rules/messprogramm/ValidFromTo.java Thu Sep 22 16:14:57 2016 +0200 +++ b/src/main/java/de/intevation/lada/validation/rules/messprogramm/ValidFromTo.java Fri Sep 23 17:56:22 2016 +0200 @@ -19,17 +19,27 @@ @ValidationRule("Messprogramm") public class ValidFromTo implements Rule { + private static final int DOY_MIN = 0; + + // Leap years should be handled in generation of Probe objects + private static final int DOY_MAX = 364; + @Override public Violation execute(Object object) { Messprogramm messprogramm = (Messprogramm)object; Violation violation = new Violation(); if (messprogramm.getGueltigVon() != null - && messprogramm.getGueltigBis() != null - && messprogramm.getGueltigVon() > messprogramm.getGueltigBis()) { - violation.addError("gueltigVon", 662); - violation.addError("gueltigBis", 662); - } + && (messprogramm.getGueltigVon() < DOY_MIN + || messprogramm.getGueltigVon() > DOY_MAX)) { + violation.addError("gueltigVon", 612); + } + + if (messprogramm.getGueltigBis() != null + && (messprogramm.getGueltigBis() < DOY_MIN + || messprogramm.getGueltigBis() > DOY_MAX)) { + violation.addError("gueltigBis", 612); + } return violation.hasErrors() ? violation