Mercurial > dive4elements > river
changeset 5694:8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 10:55:08 +0200 |
parents | 28e3019a6b14 |
children | fd020ac6f6cd |
files | flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadYearSelect.java |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadYearSelect.java Mon Apr 15 10:35:24 2013 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadYearSelect.java Mon Apr 15 10:55:08 2013 +0200 @@ -2,6 +2,11 @@ import org.apache.log4j.Logger; +import de.intevation.artifacts.Artifact; + +import de.intevation.flys.artifacts.FLYSArtifact; + +import de.intevation.flys.artifacts.access.SedimentLoadAccess; import de.intevation.flys.artifacts.states.DefaultState; @@ -23,4 +28,17 @@ return "minfo.sedimentload_year_select"; } + + @Override + public boolean validate(Artifact artifact) + throws IllegalArgumentException + { + SedimentLoadAccess access = new SedimentLoadAccess((FLYSArtifact) artifact, null); + + // Second year should be later than first. + if (access.getPeriod()[1] < access.getPeriod()[0]) + throw new IllegalArgumentException("error_years_wrong"); + + return true; + } }