Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadYearSelect.java @ 6665:b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Therefore, adjusted the factory to take the units name. Unfortunately,
names in db do not match values of data items. Thus do manual replacing.
In Facet and Calculate, take the chosen unit via access and to the string
replacement.
In Facet, do not transform data (we assume it comes in unit as labeled in
the db), and removed the possibility of m3/a-data of unknown yields in a
t/a diagram and vice versa.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 25 Jul 2013 15:08:13 +0200 |
parents | a0078e5e3b39 |
children | e4606eae8ea5 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5701
diff
changeset
|
9 package org.dive4elements.river.artifacts.states.minfo; |
4220
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 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
|
12 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5701
diff
changeset
|
13 import org.dive4elements.artifacts.Artifact; |
5694
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
14 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
15 import org.dive4elements.river.artifacts.D4EArtifact; |
5694
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
16 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5701
diff
changeset
|
17 import org.dive4elements.river.artifacts.access.SedimentLoadAccess; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5701
diff
changeset
|
18 import org.dive4elements.river.artifacts.states.DefaultState; |
4220
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 |
5695
fd020ac6f6cd
Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5694
diff
changeset
|
21 /** 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
|
22 public class SedimentLoadYearSelect |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 extends DefaultState |
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 /** 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
|
26 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
|
27 |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 |
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 * 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
|
31 */ |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 public SedimentLoadYearSelect() { |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 } |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 |
5695
fd020ac6f6cd
Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5694
diff
changeset
|
35 |
fd020ac6f6cd
Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5694
diff
changeset
|
36 /** Year Select Widget. */ |
4220
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 @Override |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 protected String getUIProvider() { |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 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
|
40 } |
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 |
5694
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
42 |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
43 @Override |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
44 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
|
45 throws IllegalArgumentException |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
46 { |
6101
a0078e5e3b39
Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
47 SedimentLoadAccess access = new SedimentLoadAccess((D4EArtifact) artifact); |
5694
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
48 |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
49 // Second year should be later than first. |
5701
56897ceb5589
Avoid NPE.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5695
diff
changeset
|
50 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
|
51 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
|
52 |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
53 return true; |
8508ee487893
SedimentLoadYearSelect: Add validation to have second year later than first.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4220
diff
changeset
|
54 } |
4220
a30647abf009
Added config and states for sediment load calculation in MINFO module.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 } |
5695
fd020ac6f6cd
Doc and vimline.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5694
diff
changeset
|
56 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |