Mercurial > lada > lada-server
changeset 1082:6499f2410c42
Fix validation of subintervall for yearly samples.
Validity and subintervall are actually redundant for yearly samples.
Giving a subintervall wider than validity will never result in
generation of samples because the start will never match validity.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 10 Oct 2016 17:23:39 +0200 |
parents | b782a10c5b28 |
children | 99c6c644773b |
files | db_schema/lada_schema.sql src/main/java/de/intevation/lada/validation/rules/messprogramm/SubIntervall.java |
diffstat | 2 files changed, 48 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/db_schema/lada_schema.sql Mon Oct 10 16:25:12 2016 +0200 +++ b/db_schema/lada_schema.sql Mon Oct 10 17:23:39 2016 +0200 @@ -589,8 +589,8 @@ probe_kommentar character varying(80), letzte_aenderung timestamp without time zone DEFAULT now() NOT NULL, CHECK (probenintervall = 'J' - AND teilintervall_von BETWEEN 1 AND 365 - AND teilintervall_bis BETWEEN 1 AND 365 + AND teilintervall_von BETWEEN gueltig_von AND gueltig_bis + AND teilintervall_bis BETWEEN gueltig_von AND gueltig_bis AND intervall_offset BETWEEN 0 AND 364 OR probenintervall = 'H' AND teilintervall_von BETWEEN 1 AND 184
--- a/src/main/java/de/intevation/lada/validation/rules/messprogramm/SubIntervall.java Mon Oct 10 16:25:12 2016 +0200 +++ b/src/main/java/de/intevation/lada/validation/rules/messprogramm/SubIntervall.java Mon Oct 10 17:23:39 2016 +0200 @@ -46,45 +46,64 @@ Integer teilVon = messprogramm.getTeilintervallVon(); Integer teilBis = messprogramm.getTeilintervallBis(); Integer offset = messprogramm.getIntervallOffset(); + Integer gueltigVon = messprogramm.getGueltigVon(); + Integer gueltigBis = messprogramm.getGueltigBis(); - // skip this validation if mandatory fields not given + // skip this validation if relevant mandatory fields not given if (probenintervall != null && teilVon != null && teilBis != null ) { - // lower limits are independent of intervall type - if (teilVon < 1) { - violation.addError("teilintervallVon", 612); + if ("J".equals(probenintervall)) { + if (gueltigVon != null && gueltigBis != null) { + if (teilVon < gueltigVon || teilVon > gueltigBis) { + violation.addError("teilintervallVon", 612); + } + if (teilBis < gueltigVon || teilBis > gueltigBis) { + violation.addError("teilintervallBis", 612); + } + if (offset != null + && offset > intervallMax.get("J") - 1) { + violation.addError("intervallOffset", 612); + } + } } - if (teilBis < 1) { - violation.addError("teilintervallBis", 612); - } - if (offset != null && offset < 0) { - violation.addError("intervallOffset", 612); - } + else { + // lower limits are independent of intervall type + if (teilVon < 1) { + violation.addError("teilintervallVon", 612); + } + if (teilBis < 1) { + violation.addError("teilintervallBis", 612); + } + if (offset != null && offset < 0) { + violation.addError("intervallOffset", 612); + } - // upper limits depend on (valid) intervall type - Set<String> probenintervallSet = intervallMax.keySet(); - if (!probenintervallSet.contains(probenintervall)) { - violation.addError("probenintervall", 612); - } else { - for (String intervallKey : probenintervallSet) { - if (intervallKey.equals(probenintervall)) { - if (teilVon > intervallMax.get(intervallKey)) { - violation.addError("teilintervallVon", 612); - } - if (teilBis > intervallMax.get(intervallKey)) { - violation.addError("teilintervallBis", 612); - } - if (offset != null - && offset > intervallMax.get(intervallKey) - 1) { - violation.addError("intervallOffset", 612); + // upper limits depend on (valid) intervall type + Set<String> probenintervallSet = intervallMax.keySet(); + if (!probenintervallSet.contains(probenintervall)) { + violation.addError("probenintervall", 612); + } else { + for (String intervallKey : probenintervallSet) { + if (intervallKey.equals(probenintervall)) { + if (teilVon > intervallMax.get(intervallKey)) { + violation.addError("teilintervallVon", 612); + } + if (teilBis > intervallMax.get(intervallKey)) { + violation.addError("teilintervallBis", 612); + } + if (offset != null + && offset + > intervallMax.get(intervallKey) - 1) { + violation.addError("intervallOffset", 612); + } } } } } - // lower limit has to be less than upper limit + // lower limit has to be less than or equal to upper limit if (teilVon > teilBis) { violation.addError("teilintervallVon", 662); violation.addError("teilintervallBis", 662);