Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FlowVelocityState.java @ 4669:d0b9b77fff9f
Generate new facets to have raw and filtered data in flow velocity chart.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 13 Dec 2012 15:55:58 +0100 |
parents | bb267a0aa8c2 |
children | b195fede1c3b |
comparison
equal
deleted
inserted
replaced
4668:87c938d082d6 | 4669:d0b9b77fff9f |
---|---|
4 import java.util.List; | 4 import java.util.List; |
5 | 5 |
6 import org.apache.log4j.Logger; | 6 import org.apache.log4j.Logger; |
7 | 7 |
8 import de.intevation.artifactdatabase.state.Facet; | 8 import de.intevation.artifactdatabase.state.Facet; |
9 | 9 import de.intevation.artifactdatabase.state.FacetActivity; |
10 | |
11 import de.intevation.artifacts.Artifact; | |
10 import de.intevation.artifacts.CallContext; | 12 import de.intevation.artifacts.CallContext; |
11 | 13 |
12 import de.intevation.flys.artifacts.FLYSArtifact; | 14 import de.intevation.flys.artifacts.FLYSArtifact; |
13 import de.intevation.flys.artifacts.access.FlowVelocityAccess; | 15 import de.intevation.flys.artifacts.access.FlowVelocityAccess; |
14 import de.intevation.flys.artifacts.model.CalculationResult; | 16 import de.intevation.flys.artifacts.model.CalculationResult; |
15 import de.intevation.flys.artifacts.model.DataFacet; | 17 import de.intevation.flys.artifacts.model.DataFacet; |
16 import de.intevation.flys.artifacts.model.FacetTypes; | 18 import de.intevation.flys.artifacts.model.FacetTypes; |
17 import de.intevation.flys.artifacts.model.FlowVelocityCalculation; | 19 import de.intevation.flys.artifacts.model.FlowVelocityCalculation; |
18 import de.intevation.flys.artifacts.model.FlowVelocityData; | 20 import de.intevation.flys.artifacts.model.FlowVelocityData; |
19 import de.intevation.flys.artifacts.model.FlowVelocityFacet; | 21 import de.intevation.flys.artifacts.model.FlowVelocityFacet; |
22 import de.intevation.flys.artifacts.model.FlowVelocityFilterFacet; | |
20 import de.intevation.flys.artifacts.resources.Resources; | 23 import de.intevation.flys.artifacts.resources.Resources; |
21 | 24 |
22 | 25 |
23 /* State in which flow velocities can/will be calculated. */ | 26 /* State in which flow velocities can/will be calculated. */ |
24 public class FlowVelocityState extends DefaultState implements FacetTypes { | 27 public class FlowVelocityState extends DefaultState implements FacetTypes { |
31 public static final String I18N_TOTALCHANNEL_FACET = | 34 public static final String I18N_TOTALCHANNEL_FACET = |
32 "facet.flow_velocity.totalchannel"; | 35 "facet.flow_velocity.totalchannel"; |
33 | 36 |
34 public static final String I18N_TAU_FACET = | 37 public static final String I18N_TAU_FACET = |
35 "facet.flow_velocity.tauchannel"; | 38 "facet.flow_velocity.tauchannel"; |
39 | |
40 public static final String I18N_MAINCHANNEL_FACET_RAW = | |
41 "facet.flow_velocity.mainchannel.raw"; | |
42 | |
43 public static final String I18N_TOTALCHANNEL_FACET_RAW = | |
44 "facet.flow_velocity.totalchannel.raw"; | |
45 | |
46 public static final String I18N_TAU_FACET_RAW = | |
47 "facet.flow_velocity.tauchannel.raw"; | |
36 | 48 |
37 public static final String I18N_DISCHARGE_FACET = | 49 public static final String I18N_DISCHARGE_FACET = |
38 "facet.flow_velocity.discharge"; | 50 "facet.flow_velocity.discharge"; |
39 | 51 |
40 | 52 |
70 for (FlowVelocityData d: data) { | 82 for (FlowVelocityData d: data) { |
71 if (d.getType().equals("main")) { | 83 if (d.getType().equals("main")) { |
72 newFacets.add(new FlowVelocityFacet( | 84 newFacets.add(new FlowVelocityFacet( |
73 idx, | 85 idx, |
74 FLOW_VELOCITY_MAINCHANNEL, | 86 FLOW_VELOCITY_MAINCHANNEL, |
87 buildFacetName(artifact, context, d, I18N_MAINCHANNEL_FACET_RAW), | |
88 ComputeType.ADVANCE, | |
89 id, | |
90 hash | |
91 )); | |
92 | |
93 newFacets.add(new FlowVelocityFacet( | |
94 idx, | |
95 FLOW_VELOCITY_TAU, | |
96 buildFacetName(artifact, context, d, I18N_TAU_FACET_RAW), | |
97 ComputeType.ADVANCE, | |
98 id, | |
99 hash | |
100 )); | |
101 newFacets.add(new FlowVelocityFilterFacet( | |
102 idx, | |
103 FLOW_VELOCITY_MAINCHANNEL_FILTERED, | |
75 buildMainChannelName(artifact, context, d), | 104 buildMainChannelName(artifact, context, d), |
76 ComputeType.ADVANCE, | 105 ComputeType.ADVANCE, |
77 id, | 106 id, |
78 hash | 107 hash |
79 )); | 108 )); |
80 | 109 newFacets.add(new FlowVelocityFilterFacet( |
81 newFacets.add(new FlowVelocityFacet( | 110 idx, |
82 idx, | 111 FLOW_VELOCITY_TAU_FILTERED, |
83 FLOW_VELOCITY_TAU, | |
84 buildTauName(artifact, context, d), | 112 buildTauName(artifact, context, d), |
85 ComputeType.ADVANCE, | 113 ComputeType.ADVANCE, |
86 id, | 114 id, |
87 hash | 115 hash |
88 )); | 116 )); |
89 } | 117 } |
90 else if (d.getType().equals("total")) { | 118 else if (d.getType().equals("total")) { |
91 newFacets.add(new FlowVelocityFacet( | 119 newFacets.add(new FlowVelocityFacet( |
92 idx, | 120 idx, |
93 FLOW_VELOCITY_TOTALCHANNEL, | 121 FLOW_VELOCITY_TOTALCHANNEL, |
122 buildFacetName(artifact, context, d, I18N_TOTALCHANNEL_FACET_RAW), | |
123 ComputeType.ADVANCE, | |
124 id, | |
125 hash | |
126 )); | |
127 newFacets.add(new FlowVelocityFilterFacet( | |
128 idx, | |
129 FLOW_VELOCITY_TOTALCHANNEL_FILTERED, | |
94 buildTotalChannelName(artifact, context, d), | 130 buildTotalChannelName(artifact, context, d), |
95 ComputeType.ADVANCE, | 131 ComputeType.ADVANCE, |
96 id, | 132 id, |
97 hash | 133 hash |
98 )); | 134 )); |
135 | |
99 } | 136 } |
100 else if(d.getType().equals("main_total")) { | 137 else if(d.getType().equals("main_total")) { |
101 newFacets.add(new FlowVelocityFacet( | 138 newFacets.add(new FlowVelocityFacet( |
102 idx, | 139 idx, |
103 FLOW_VELOCITY_MAINCHANNEL, | 140 FLOW_VELOCITY_MAINCHANNEL, |
141 buildFacetName(artifact, context, d, I18N_MAINCHANNEL_FACET_RAW), | |
142 ComputeType.ADVANCE, | |
143 id, | |
144 hash | |
145 )); | |
146 newFacets.add(new FlowVelocityFacet( | |
147 idx, | |
148 FLOW_VELOCITY_TAU, | |
149 buildFacetName(artifact, context, d, I18N_TAU_FACET_RAW), | |
150 ComputeType.ADVANCE, | |
151 id, | |
152 hash | |
153 )); | |
154 newFacets.add(new FlowVelocityFacet( | |
155 idx, | |
156 FLOW_VELOCITY_TOTALCHANNEL, | |
157 buildFacetName(artifact, context, d, I18N_TOTALCHANNEL_FACET_RAW), | |
158 ComputeType.ADVANCE, | |
159 id, | |
160 hash | |
161 )); | |
162 newFacets.add(new FlowVelocityFilterFacet( | |
163 idx, | |
164 FLOW_VELOCITY_MAINCHANNEL_FILTERED, | |
104 buildMainChannelName(artifact, context, d), | 165 buildMainChannelName(artifact, context, d), |
105 ComputeType.ADVANCE, | 166 ComputeType.ADVANCE, |
106 id, | 167 id, |
107 hash | 168 hash |
108 )); | 169 )); |
109 newFacets.add(new FlowVelocityFacet( | 170 newFacets.add(new FlowVelocityFilterFacet( |
110 idx, | 171 idx, |
111 FLOW_VELOCITY_TAU, | 172 FLOW_VELOCITY_TAU_FILTERED, |
112 buildTauName(artifact, context, d), | 173 buildTauName(artifact, context, d), |
113 ComputeType.ADVANCE, | 174 ComputeType.ADVANCE, |
114 id, | 175 id, |
115 hash | 176 hash |
116 )); | 177 )); |
117 newFacets.add(new FlowVelocityFacet( | 178 newFacets.add(new FlowVelocityFilterFacet( |
118 idx, | 179 idx, |
119 FLOW_VELOCITY_TOTALCHANNEL, | 180 FLOW_VELOCITY_TOTALCHANNEL_FILTERED, |
120 buildTotalChannelName(artifact, context, d), | 181 buildTotalChannelName(artifact, context, d), |
121 ComputeType.ADVANCE, | 182 ComputeType.ADVANCE, |
122 id, | 183 id, |
123 hash | 184 hash |
124 )); | 185 )); |
200 CallContext cc, | 261 CallContext cc, |
201 FlowVelocityData data | 262 FlowVelocityData data |
202 ) { | 263 ) { |
203 return buildFacetName(flys, cc, data, I18N_TAU_FACET); | 264 return buildFacetName(flys, cc, data, I18N_TAU_FACET); |
204 } | 265 } |
266 | |
267 static { | |
268 // Active/deactivate facets. | |
269 FacetActivity.Registry.getInstance().register( | |
270 "minfo", | |
271 new FacetActivity() { | |
272 @Override | |
273 public Boolean isInitialActive( | |
274 Artifact artifact, | |
275 Facet facet, | |
276 String output | |
277 ) { | |
278 String name = facet.getName(); | |
279 if (name.equals(FLOW_VELOCITY_MAINCHANNEL) || | |
280 name.equals(FLOW_VELOCITY_TAU) || | |
281 name.equals(FLOW_VELOCITY_TOTALCHANNEL)) { | |
282 return Boolean.FALSE; | |
283 } | |
284 else { | |
285 return Boolean.TRUE; | |
286 } | |
287 } | |
288 }); | |
289 } | |
205 } | 290 } |
206 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 291 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |