Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeState.java @ 6501:7cb247824ed1
Amtl. Linien: Added report if an official line was found in report.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 28 Jun 2013 14:11:58 +0200 |
parents | a07521dca5b5 |
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:
3927
diff
changeset
|
9 package org.dive4elements.river.artifacts.states; |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import java.util.List; |
6185
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
12 import java.util.Collections; |
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
13 import java.util.Comparator; |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import org.apache.log4j.Logger; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3927
diff
changeset
|
17 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3927
diff
changeset
|
18 import org.dive4elements.artifacts.CallContext; |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3927
diff
changeset
|
20 import org.dive4elements.artifacts.common.model.KVP; |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3927
diff
changeset
|
22 import org.dive4elements.river.model.DischargeZone; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3927
diff
changeset
|
23 import org.dive4elements.river.model.River; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3927
diff
changeset
|
24 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
25 import org.dive4elements.river.artifacts.D4EArtifact; |
5865
73da40528cf2
River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
26 import org.dive4elements.river.utils.RiverUtils; |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 public class DischargeState extends MultiIntArrayState { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
3759
e54f8dc222cf
Renamed input parameters of MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3087
diff
changeset
|
31 public static final String MAIN_CHANNEL = "main_channel"; |
e54f8dc222cf
Renamed input parameters of MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3087
diff
changeset
|
32 public static final String TOTAL_CHANNEL = "total_channel"; |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 private static final Logger logger = Logger.getLogger(DischargeState.class); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
3927
208a891c21b5
Partly fix issue871.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3759
diff
changeset
|
38 /** Let client display a matrix. */ |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 @Override |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 public String getUIProvider() { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 return "parameter-matrix"; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 /** |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 * This method fetches all DischargeZones for a given river (extracted from |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 * <i>artifact</i>) and returns a KVP[] where the key is the ID of the |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 * DischargeZone and the value is a string that consists of lower discharge |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 * and upper discharge. |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 * |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
51 * @param artifact Needs to be a D4EArtifact that provides river |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 * information. |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 * @param parameterName The name of a parameter. |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 * |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 * @return a KVP[]. |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 */ |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 @Override |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 protected KVP<Integer, String>[] getOptions( |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 Artifact artifact, |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 String parameterName |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 ) |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 throws IllegalArgumentException |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 if (!testParameterName(parameterName)) { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 throw new IllegalArgumentException( |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 "Invalid parameter for state: '" + parameterName + "'"); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 List<DischargeZone> zones = getDischargeZones(artifact); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 KVP[] kvp = new KVP[zones.size()]; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 |
6185
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
73 Collections.sort(zones, new Comparator<DischargeZone>() { |
6186
a07521dca5b5
Add an Override to the compare method
Andre Heinecke <aheinecke@intevation.de>
parents:
6185
diff
changeset
|
74 @Override |
6185
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
75 public int compare(DischargeZone a, DischargeZone b) { |
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
76 return a.getValue().compareTo(b.getValue()); |
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
77 } |
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
78 }); |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 |
6185
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
80 int i = 0; |
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
81 |
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
82 for (DischargeZone zone: zones) { |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 String lower = zone.getLowerDischarge(); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 String upper = zone.getUpperDischarge(); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 if (lower.equals(upper)) { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 kvp[i] = new KVP(zone.getId(), lower); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 else { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 kvp[i] = new KVP(zone.getId(), lower + " - " + upper); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 } |
6185
7573683925a3
Add sorting for discharge value
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
92 i++; |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 return kvp; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 |
2705
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
99 @Override |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
100 protected String getLabelFor( |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
101 CallContext cc, |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
102 String parameterName, |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
103 int value |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
104 ) throws IllegalArgumentException |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
105 { |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
106 if (!testParameterName(parameterName)) { |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
107 throw new IllegalArgumentException( |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
108 "Invalid parameter for state: '" + parameterName + "'"); |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
109 } |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
110 |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
111 DischargeZone zone = DischargeZone.getDischargeZoneById(value); |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
112 |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
113 if (zone == null) { |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
114 throw new IllegalArgumentException( |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
115 "Invalid id for DischargeZone: '" + value + "'"); |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
116 } |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
117 |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
118 String lo = zone.getLowerDischarge(); |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
119 String hi = zone.getUpperDischarge(); |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
120 |
3927
208a891c21b5
Partly fix issue871.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3759
diff
changeset
|
121 return hi != null && !lo.equals(hi) |
2705
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
122 ? lo + " - " + hi |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
123 : lo; |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
124 } |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
125 |
71f072d8b3d8
Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2696
diff
changeset
|
126 |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 /** |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 * This method might be used to test, if a parameter name is handled by this |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 * state. |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 * |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 * @param parameterName The name of a parameter. |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 * |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 * @return true, if parameterName is one of <i>MAIN_CHANNEL</i> or |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 * <i>TOTAL_CHANNEL</i>. Otherwise false. |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 */ |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 protected boolean testParameterName(String parameterName) { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 if (parameterName == null || parameterName.length() == 0) { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 return false; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 else if (parameterName.equals(MAIN_CHANNEL)) { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 return true; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 else if (parameterName.equals(TOTAL_CHANNEL)) { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 return true; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 else { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 return false; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 /** |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 * Returns all discharge zones for a given river. The river information is |
5865
73da40528cf2
River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
154 * extracted from <i>artifact</i> using RiverUtils.getRiver(). |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 * |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
156 * @param artifact Needs to be a D4EArtifact that stores a rivername. |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 * |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 * @return a list of DischargeZones. |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 * |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 * @throws IllegalArgumentException if no river information is provided by |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 * <i>artifact</i>. |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 */ |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 protected List<DischargeZone> getDischargeZones(Artifact artifact) |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 throws IllegalArgumentException |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 { |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
166 River river = RiverUtils.getRiver((D4EArtifact) artifact); |
2696
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 if (river == null) { |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 throw new IllegalArgumentException("No river found"); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 List<DischargeZone> zones = DischargeZone.getDischargeZones(river); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 logger.debug("Found " + zones.size() + " DischargeZones."); |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 return zones; |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 } |
1bc35de0b786
Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |