# HG changeset patch # User Felix Wolfsteller # Date 1366016108 -7200 # Node ID 8508ee487893b1619012abd3ac8bfb521c38b7a7 # Parent 28e3019a6b14860a1751708a0dcda25713b8f056 SedimentLoadYearSelect: Add validation to have second year later than first. diff -r 28e3019a6b14 -r 8508ee487893 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadYearSelect.java --- 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; + } }