Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/SedimentLoadYearSelect.java @ 5701:56897ceb5589
Avoid NPE.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 11:53:48 +0200 |
parents | fd020ac6f6cd |
children |
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 |
5695
fd020ac6f6cd
Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5694
diff
changeset
|
13 /** State in which to fetch years for sedminent load calculation. */ |
4220
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 public class SedimentLoadYearSelect |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 extends DefaultState |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 { |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 /** 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
|
18 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
|
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 /** |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 * 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
|
23 */ |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 public SedimentLoadYearSelect() { |
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 |
5695
fd020ac6f6cd
Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5694
diff
changeset
|
27 |
fd020ac6f6cd
Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5694
diff
changeset
|
28 /** Year Select Widget. */ |
4220
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 @Override |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 protected String getUIProvider() { |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 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
|
32 } |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 |
5694
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
34 |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
35 @Override |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
36 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
|
37 throws IllegalArgumentException |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
38 { |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
39 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
|
40 |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
41 // Second year should be later than first. |
5701
56897ceb5589
Avoid NPE.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5695
diff
changeset
|
42 if (access.getPeriod() != null && access.getPeriod()[1] < access.getPeriod()[0]) |
5694
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
43 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
|
44 |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
45 return true; |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
46 } |
4220
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 } |
5695
fd020ac6f6cd
Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5694
diff
changeset
|
48 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |