annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadYearSelect.java @ 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 a30647abf009
children fd020ac6f6cd
rev   line source
4220
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states.minfo;
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import org.apache.log4j.Logger;
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
5694
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
5 import de.intevation.artifacts.Artifact;
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
6
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
7 import de.intevation.flys.artifacts.FLYSArtifact;
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
8
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
9 import de.intevation.flys.artifacts.access.SedimentLoadAccess;
4220
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import de.intevation.flys.artifacts.states.DefaultState;
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 public class SedimentLoadYearSelect
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 extends DefaultState
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 {
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 /** The logger used in this class. */
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 private static Logger logger = Logger.getLogger(SedimentLoadYearSelect.class);
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 /**
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 * The default constructor that initializes an empty State object.
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 */
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 public SedimentLoadYearSelect() {
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 }
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 @Override
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 protected String getUIProvider() {
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 return "minfo.sedimentload_year_select";
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 }
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30
5694
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
31
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
32 @Override
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
33 public boolean validate(Artifact artifact)
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
34 throws IllegalArgumentException
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
35 {
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
36 SedimentLoadAccess access = new SedimentLoadAccess((FLYSArtifact) artifact, null);
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
37
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
38 // Second year should be later than first.
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
39 if (access.getPeriod()[1] < access.getPeriod()[0])
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
40 throw new IllegalArgumentException("error_years_wrong");
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
41
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
42 return true;
8508ee487893 SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4220
diff changeset
43 }
4220
a30647abf009 Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 }

http://dive4elements.wald.intevation.org