comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java @ 3867:d8c99ff18db8

Refactor MINFO bed quality resultsets and facets. flys-artifacts/trunk@5498 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 17 Sep 2012 14:38:47 +0000
parents 5a8f8fd5310c
children a5f65e8983be
comparison
equal deleted inserted replaced
3866:2e83ed94c513 3867:d8c99ff18db8
12 import de.intevation.flys.artifacts.FLYSArtifact; 12 import de.intevation.flys.artifacts.FLYSArtifact;
13 import de.intevation.flys.artifacts.access.BedQualityAccess; 13 import de.intevation.flys.artifacts.access.BedQualityAccess;
14 import de.intevation.flys.artifacts.model.CalculationResult; 14 import de.intevation.flys.artifacts.model.CalculationResult;
15 import de.intevation.flys.artifacts.model.DateRange; 15 import de.intevation.flys.artifacts.model.DateRange;
16 import de.intevation.flys.artifacts.model.FacetTypes; 16 import de.intevation.flys.artifacts.model.FacetTypes;
17 import de.intevation.flys.artifacts.model.minfo.BedBedQualityResult;
18 import de.intevation.flys.artifacts.model.minfo.BedDensityFacet; 17 import de.intevation.flys.artifacts.model.minfo.BedDensityFacet;
19 import de.intevation.flys.artifacts.model.minfo.BedDiameterFacet; 18 import de.intevation.flys.artifacts.model.minfo.BedDiameterFacet;
20 import de.intevation.flys.artifacts.model.minfo.BedLoadBedQualityResult; 19 import de.intevation.flys.artifacts.model.minfo.BedDiameterResult;
20 import de.intevation.flys.artifacts.model.minfo.BedParametersResult;
21 import de.intevation.flys.artifacts.model.minfo.BedPorosityFacet; 21 import de.intevation.flys.artifacts.model.minfo.BedPorosityFacet;
22 import de.intevation.flys.artifacts.model.minfo.BedQualityCalculation; 22 import de.intevation.flys.artifacts.model.minfo.BedQualityCalculation;
23 import de.intevation.flys.artifacts.model.minfo.BedQualityDiameterResult;
23 import de.intevation.flys.artifacts.model.minfo.BedQualityResult; 24 import de.intevation.flys.artifacts.model.minfo.BedQualityResult;
24 import de.intevation.flys.artifacts.model.minfo.BedloadDiameterFacet; 25 import de.intevation.flys.artifacts.model.minfo.BedloadDiameterFacet;
26 import de.intevation.flys.artifacts.model.minfo.BedloadDiameterResult;
25 import de.intevation.flys.artifacts.resources.Resources; 27 import de.intevation.flys.artifacts.resources.Resources;
26 import de.intevation.flys.artifacts.states.DefaultState; 28 import de.intevation.flys.artifacts.states.DefaultState;
27 29
28 30
29 public class BedQualityState extends DefaultState implements FacetTypes { 31 public class BedQualityState extends DefaultState implements FacetTypes {
81 83
82 CallMeta meta = context.getMeta(); 84 CallMeta meta = context.getMeta();
83 85
84 for (int idx = 0; idx < results.length; idx++) { 86 for (int idx = 0; idx < results.length; idx++) {
85 BedQualityResult result = results[idx]; 87 BedQualityResult result = results[idx];
86 88 DateRange range = result.getDateRange();
87 if (result instanceof BedBedQualityResult) { 89 BedDiameterResult[] bedDiameter = result.getBedResults();
88 BedBedQualityResult data = (BedBedQualityResult) result; 90 for (int j = 0; j < bedDiameter.length; j++) {
89 newFacets.add(new BedPorosityFacet(idx, 91 newFacets.add(new BedDiameterFacet((idx << 8) + j,
92 BED_QUALITY_BED_DIAMETER_TOPLAYER,
93 createDiameterTopLayerDescription(
94 meta,
95 bedDiameter[j],
96 range),
97 ComputeType.ADVANCE, stateId, hash));
98
99 newFacets.add(new BedDiameterFacet((idx << 8) +j,
100 BED_QUALITY_BED_DIAMETER_SUBLAYER,
101 createDiameterSubLayerDescription(
102 meta,
103 bedDiameter[j],
104 range),
105 ComputeType.ADVANCE, stateId, hash));
106 }
107 BedloadDiameterResult[] bedloadDiameter = result.getBedloadResults();
108 for (int j = 0; j < bedloadDiameter.length; j++) {
109 newFacets.add(new BedloadDiameterFacet(
110 (idx << 8) + j,
111 BED_QUALITY_BEDLOAD_DIAMETER,
112 createDiameterDescription(
113 meta, bedloadDiameter[j]),
114 ComputeType.ADVANCE,
115 stateId,
116 hash));
117
118 }
119 BedParametersResult[] bedParameters = result.getParameters();
120 for (int j = 0; j < bedParameters.length; j++) {
121 newFacets.add(new BedPorosityFacet((idx << 8) + j,
90 BED_QUALITY_POROSITY_TOPLAYER, 122 BED_QUALITY_POROSITY_TOPLAYER,
91 createPorosityTopLayerDescription(meta, data), 123 createPorosityTopLayerDescription(
92 ComputeType.ADVANCE, stateId, hash)); 124 meta,
93 125 bedParameters[j],
94 newFacets.add(new BedPorosityFacet(idx, 126 range),
127 ComputeType.ADVANCE, stateId, hash));
128
129 newFacets.add(new BedPorosityFacet((idx << 8) + j,
95 BED_QUALITY_POROSITY_SUBLAYER, 130 BED_QUALITY_POROSITY_SUBLAYER,
96 createPorositySubLayerDescription(meta, data), 131 createPorositySubLayerDescription(
97 ComputeType.ADVANCE, stateId, hash)); 132 meta,
98 133 bedParameters[j],
99 newFacets.add(new BedDensityFacet(idx, 134 range),
135 ComputeType.ADVANCE, stateId, hash));
136
137 newFacets.add(new BedDensityFacet((idx << 8) + j,
100 BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER, 138 BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER,
101 createDensityTopLayerDescription(meta, data), 139 createDensityTopLayerDescription(
102 ComputeType.ADVANCE, stateId, hash)); 140 meta,
103 141 bedParameters[j],
104 newFacets.add(new BedDensityFacet(idx, 142 range),
143 ComputeType.ADVANCE, stateId, hash));
144
145 newFacets.add(new BedDensityFacet((idx << 8) + j,
105 BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER, 146 BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER,
106 createDensitySubLayerDescription(meta, data), 147 createDensitySubLayerDescription(
107 ComputeType.ADVANCE, stateId, hash)); 148 meta,
108 149 bedParameters[j],
109 newFacets.add(new BedloadDiameterFacet(idx, 150 range),
110 BED_QUALITY_BED_DIAMETER_TOPLAYER, 151 ComputeType.ADVANCE, stateId, hash));
111 createDiameterTopLayerDescription(meta, data),
112 ComputeType.ADVANCE, stateId, hash));
113
114 newFacets.add(new BedloadDiameterFacet(idx,
115 BED_QUALITY_BED_DIAMETER_SUBLAYER,
116 createDiameterSubLayerDescription(meta, data),
117 ComputeType.ADVANCE, stateId, hash));
118 }
119 else if (result instanceof BedLoadBedQualityResult) {
120 newFacets.add(new BedDiameterFacet(idx,
121 BED_QUALITY_BEDLOAD_DIAMETER, createDiameterDescription(
122 meta, result), ComputeType.ADVANCE, stateId, hash));
123 }
124 else {
125 logger.warn("unknown result object: " + result.getClass());
126 } 152 }
127 } 153 }
128 } 154 }
129 155
130 protected String createPorosityTopLayerDescription(CallMeta meta, 156 protected String createPorosityTopLayerDescription(CallMeta meta,
131 BedBedQualityResult result) { 157 BedParametersResult result, DateRange range) {
132 DateRange range = result.getDateRange();
133 Date from = range != null ? range.getFrom() : new Date(); 158 Date from = range != null ? range.getFrom() : new Date();
134 Date to = range != null ? range.getTo() : new Date(); 159 Date to = range != null ? range.getTo() : new Date();
135 160
136 String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); 161 String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER);
137 return Resources.getMsg(meta, I18N_FACET_BED_POROSITY_TOPLAYER, 162 return Resources.getMsg(meta, I18N_FACET_BED_POROSITY_TOPLAYER,
138 I18N_FACET_BED_POROSITY_TOPLAYER, new Object[] { from, to, toplayer }); 163 I18N_FACET_BED_POROSITY_TOPLAYER, new Object[] { from, to, toplayer });
139 } 164 }
140 165
141 protected String createPorositySubLayerDescription(CallMeta meta, 166 protected String createPorositySubLayerDescription(CallMeta meta,
142 BedBedQualityResult result) { 167 BedParametersResult result, DateRange range) {
143 DateRange range = result.getDateRange();
144 Date from = range != null ? range.getFrom() : new Date(); 168 Date from = range != null ? range.getFrom() : new Date();
145 Date to = range != null ? range.getTo() : new Date(); 169 Date to = range != null ? range.getTo() : new Date();
146 170
147 String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); 171 String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER);
148 return Resources.getMsg(meta, I18N_FACET_BED_POROSITY_SUBLAYER, 172 return Resources.getMsg(meta, I18N_FACET_BED_POROSITY_SUBLAYER,
149 I18N_FACET_BED_POROSITY_SUBLAYER, new Object[] { from, to, sublayer }); 173 I18N_FACET_BED_POROSITY_SUBLAYER, new Object[] { from, to, sublayer });
150 } 174 }
151 175
152 protected String createDensityTopLayerDescription(CallMeta meta, 176 protected String createDensityTopLayerDescription(CallMeta meta,
153 BedBedQualityResult result) { 177 BedParametersResult result, DateRange range) {
154 DateRange range = result.getDateRange();
155 Date from = range != null ? range.getFrom() : new Date(); 178 Date from = range != null ? range.getFrom() : new Date();
156 Date to = range != null ? range.getTo() : new Date(); 179 Date to = range != null ? range.getTo() : new Date();
157 180
158 String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); 181 String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER);
159 return Resources.getMsg(meta, I18N_FACET_BED_DENSITY_TOPLAYER, 182 return Resources.getMsg(meta, I18N_FACET_BED_DENSITY_TOPLAYER,
160 I18N_FACET_BED_DENSITY_TOPLAYER, new Object[] { from, to, toplayer }); 183 I18N_FACET_BED_DENSITY_TOPLAYER, new Object[] { from, to, toplayer });
161 } 184 }
162 185
163 protected String createDensitySubLayerDescription(CallMeta meta, 186 protected String createDensitySubLayerDescription(CallMeta meta,
164 BedBedQualityResult result) { 187 BedParametersResult result, DateRange range) {
165 DateRange range = result.getDateRange();
166 Date from = range != null ? range.getFrom() : new Date(); 188 Date from = range != null ? range.getFrom() : new Date();
167 Date to = range != null ? range.getTo() : new Date(); 189 Date to = range != null ? range.getTo() : new Date();
168 190
169 String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); 191 String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER);
170 return Resources.getMsg(meta, I18N_FACET_BED_DENSITY_SUBLAYER, 192 return Resources.getMsg(meta, I18N_FACET_BED_DENSITY_SUBLAYER,
171 I18N_FACET_BED_DENSITY_SUBLAYER, new Object[] { from, to, sublayer }); 193 I18N_FACET_BED_DENSITY_SUBLAYER, new Object[] { from, to, sublayer });
172 } 194 }
173 195
174 protected String createDiameterTopLayerDescription(CallMeta meta, 196 protected String createDiameterTopLayerDescription(CallMeta meta,
175 BedBedQualityResult result) { 197 BedDiameterResult result, DateRange range) {
176 DateRange range = result.getDateRange();
177 Date from = range != null ? range.getFrom() : new Date(); 198 Date from = range != null ? range.getFrom() : new Date();
178 Date to = range != null ? range.getTo() : new Date(); 199 Date to = range != null ? range.getTo() : new Date();
179 200
180 String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER); 201 String toplayer = Resources.getMsg(meta, I18N_TOPLAYER, I18N_TOPLAYER);
181 202
183 I18N_FACET_BED_DIAMETER_TOPLAYER, new Object[] { result.getType(), 204 I18N_FACET_BED_DIAMETER_TOPLAYER, new Object[] { result.getType(),
184 from, to, toplayer }); 205 from, to, toplayer });
185 } 206 }
186 207
187 protected String createDiameterSubLayerDescription(CallMeta meta, 208 protected String createDiameterSubLayerDescription(CallMeta meta,
188 BedBedQualityResult result) { 209 BedDiameterResult result, DateRange range) {
189 DateRange range = result.getDateRange();
190 Date from = range != null ? range.getFrom() : new Date(); 210 Date from = range != null ? range.getFrom() : new Date();
191 Date to = range != null ? range.getTo() : new Date(); 211 Date to = range != null ? range.getTo() : new Date();
192 212
193 String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER); 213 String sublayer = Resources.getMsg(meta, I18N_SUBLAYER, I18N_SUBLAYER);
194 return Resources.getMsg(meta, I18N_FACET_BED_DIAMETER_SUBLAYER, 214 return Resources.getMsg(meta, I18N_FACET_BED_DIAMETER_SUBLAYER,
195 I18N_FACET_BED_DIAMETER_SUBLAYER, new Object[] { result.getType(), 215 I18N_FACET_BED_DIAMETER_SUBLAYER, new Object[] { result.getType(),
196 from, to, sublayer }); 216 from, to, sublayer });
197 } 217 }
198 218
199 protected String createDiameterDescription(CallMeta meta, 219 protected String createDiameterDescription(CallMeta meta,
200 BedQualityResult result) { 220 BedQualityDiameterResult result) {
201 return Resources.getMsg(meta, I18N_FACET_BEDLOAD_DIAMETER, 221 return Resources.getMsg(meta, I18N_FACET_BEDLOAD_DIAMETER,
202 I18N_FACET_BEDLOAD_DIAMETER, new Object[] { result.getType() }); 222 I18N_FACET_BEDLOAD_DIAMETER, new Object[] { result.getType() });
203 } 223 }
204 } 224 }
205 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 225 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org