# HG changeset patch # User Tom Gottfried # Date 1473329023 -7200 # Node ID 61b94641cf995b5ad9007e7196a7eb03128ac139 # Parent a796e68da1cfc9b200fbf659afae76a2eba53609 A period with end before start is not meaningful. This is true for the subintervall, too. diff -r a796e68da1cf -r 61b94641cf99 db_schema/lada_schema.sql --- a/db_schema/lada_schema.sql Wed Sep 07 18:17:48 2016 +0200 +++ b/db_schema/lada_schema.sql Thu Sep 08 12:03:43 2016 +0200 @@ -588,6 +588,7 @@ 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) ); CREATE TRIGGER letzte_aenderung_messprogramm BEFORE UPDATE ON messprogramm FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung(); diff -r a796e68da1cf -r 61b94641cf99 src/main/java/de/intevation/lada/validation/rules/messprogramm/SubIntervall.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/validation/rules/messprogramm/SubIntervall.java Thu Sep 08 12:03:43 2016 +0200 @@ -0,0 +1,37 @@ +/* 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.messprogramm; + +import de.intevation.lada.model.land.Messprogramm; +import de.intevation.lada.validation.Violation; +import de.intevation.lada.validation.annotation.ValidationRule; +import de.intevation.lada.validation.rules.Rule; + +/** + * Validation rule for Messprogramm. + * Validates if the subintervall period is meaningful. + */ +@ValidationRule("Messprogramm") +public class SubIntervall implements Rule { + + @Override + public Violation execute(Object object) { + Messprogramm messprogramm = (Messprogramm)object; + Violation violation = new Violation(); + + if (messprogramm.getTeilintervallVon() + > messprogramm.getTeilintervallBis()) { + violation.addError("teilintervallVon", 662); + violation.addError("teilintervallBis", 662); + } + + return violation.hasErrors() + ? violation + :null; + } +}