Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java @ 6262:ea6225010871
Set facet activity, have the correct facet order and added new facet to bed quality.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 11 Jun 2013 09:20:14 +0200 |
parents | 38d6ce2c7164 |
children | fe32a7f9655e |
comparison
equal
deleted
inserted
replaced
6261:83a04004969f | 6262:ea6225010871 |
---|---|
13 import java.util.List; | 13 import java.util.List; |
14 | 14 |
15 import org.apache.log4j.Logger; | 15 import org.apache.log4j.Logger; |
16 | 16 |
17 import org.dive4elements.artifactdatabase.state.Facet; | 17 import org.dive4elements.artifactdatabase.state.Facet; |
18 import org.dive4elements.artifactdatabase.state.FacetActivity; | |
19 import org.dive4elements.artifacts.Artifact; | |
18 import org.dive4elements.artifacts.CallContext; | 20 import org.dive4elements.artifacts.CallContext; |
19 import org.dive4elements.artifacts.CallMeta; | 21 import org.dive4elements.artifacts.CallMeta; |
20 import org.dive4elements.river.artifacts.D4EArtifact; | 22 import org.dive4elements.river.artifacts.D4EArtifact; |
21 import org.dive4elements.river.artifacts.access.BedQualityAccess; | 23 import org.dive4elements.river.artifacts.access.BedQualityAccess; |
22 import org.dive4elements.river.artifacts.model.CalculationResult; | 24 import org.dive4elements.river.artifacts.model.CalculationResult; |
30 import org.dive4elements.river.artifacts.model.minfo.BedParametersResult; | 32 import org.dive4elements.river.artifacts.model.minfo.BedParametersResult; |
31 import org.dive4elements.river.artifacts.model.minfo.BedPorosityFacet; | 33 import org.dive4elements.river.artifacts.model.minfo.BedPorosityFacet; |
32 import org.dive4elements.river.artifacts.model.minfo.BedQualityCalculation; | 34 import org.dive4elements.river.artifacts.model.minfo.BedQualityCalculation; |
33 import org.dive4elements.river.artifacts.model.minfo.BedQualityDiameterResult; | 35 import org.dive4elements.river.artifacts.model.minfo.BedQualityDiameterResult; |
34 import org.dive4elements.river.artifacts.model.minfo.BedQualityResult; | 36 import org.dive4elements.river.artifacts.model.minfo.BedQualityResult; |
37 import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterDataFacet; | |
35 import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterFacet; | 38 import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterFacet; |
36 import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterResult; | 39 import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterResult; |
37 import org.dive4elements.river.artifacts.resources.Resources; | 40 import org.dive4elements.river.artifacts.resources.Resources; |
38 import org.dive4elements.river.artifacts.states.DefaultState; | 41 import org.dive4elements.river.artifacts.states.DefaultState; |
39 | 42 |
57 public static final String I18N_FACET_BED_DIAMETER_DATA_TOPLAYER = "facet.bedquality.bed.diameter.data.toplayer"; | 60 public static final String I18N_FACET_BED_DIAMETER_DATA_TOPLAYER = "facet.bedquality.bed.diameter.data.toplayer"; |
58 public static final String I18N_FACET_BED_DIAMETER_DATA_SUBLAYER = "facet.bedquality.bed.diameter.data.sublayer"; | 61 public static final String I18N_FACET_BED_DIAMETER_DATA_SUBLAYER = "facet.bedquality.bed.diameter.data.sublayer"; |
59 public static final String I18N_FACET_BEDLOAD_DIAMETER_DATA = "facet.bedquality.bedload.diameter.data"; | 62 public static final String I18N_FACET_BEDLOAD_DIAMETER_DATA = "facet.bedquality.bedload.diameter.data"; |
60 public static final String I18N_FACET_BEDLOAD_DIAMETER = "facet.bedquality.bedload.diameter"; | 63 public static final String I18N_FACET_BEDLOAD_DIAMETER = "facet.bedquality.bedload.diameter"; |
61 | 64 |
65 static { | |
66 // Active/deactivate facets. | |
67 FacetActivity.Registry.getInstance().register( | |
68 "minfo", | |
69 new FacetActivity() { | |
70 @Override | |
71 public Boolean isInitialActive( | |
72 Artifact artifact, | |
73 Facet facet, | |
74 String output | |
75 ) { | |
76 String name = facet.getName(); | |
77 if (name.equals(BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER) || | |
78 name.equals(BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER) || | |
79 name.equals(BED_DIAMETER_DATA_TOP) || | |
80 name.equals(BED_DIAMETER_DATA_SUB) || | |
81 name.equals(BEDLOAD_DIAMETER_DATA)){ | |
82 return Boolean.FALSE; | |
83 } | |
84 else { | |
85 return null; | |
86 } | |
87 } | |
88 }); | |
89 } | |
90 | |
62 @Override | 91 @Override |
63 public Object computeAdvance(D4EArtifact artifact, String hash, | 92 public Object computeAdvance(D4EArtifact artifact, String hash, |
64 CallContext context, List<Facet> facets, Object old) { | 93 CallContext context, List<Facet> facets, Object old) { |
65 logger.debug("BedQualityState.computeAdvance"); | 94 logger.debug("BedQualityState.computeAdvance"); |
66 | 95 |
95 List<Facet> newFacets, | 124 List<Facet> newFacets, |
96 BedQualityAccess access, | 125 BedQualityAccess access, |
97 String stateId, | 126 String stateId, |
98 String hash) { | 127 String hash) { |
99 List<String> diameters = access.getBedDiameter(); | 128 List<String> diameters = access.getBedDiameter(); |
129 List<String> loadDiameters = access.getBedloadDiameter(); | |
100 List<DateRange> ranges = access.getDateRanges(); | 130 List<DateRange> ranges = access.getDateRanges(); |
101 for (int i = 0; i < ranges.size(); i++) { | 131 for (int i = 0; i < ranges.size(); i++) { |
102 DateRange range = ranges.get(i); | 132 DateRange range = ranges.get(i); |
103 for (String diameter: diameters) { | 133 for (String diameter: diameters) { |
104 int ndxTop = generateIndex(diameter, true); | 134 int ndxTop = generateIndex(diameter); |
105 int ndxSub = generateIndex(diameter, false); | 135 int ndxSub = generateIndex(diameter); |
136 ndxTop += 1; | |
137 ndxTop = ndxTop << 3; | |
138 ndxSub = ndxSub << 3; | |
139 ndxTop += i; | |
140 ndxSub += i; | |
106 String toplayer = | 141 String toplayer = |
107 Resources.getMsg( | 142 Resources.getMsg( |
108 context.getMeta(), I18N_TOPLAYER, I18N_TOPLAYER); | 143 context.getMeta(), I18N_TOPLAYER, I18N_TOPLAYER); |
109 String sublayer = | 144 String sublayer = |
110 Resources.getMsg( | 145 Resources.getMsg( |
134 range.getFrom(), range.getTo(), sublayer}), | 169 range.getFrom(), range.getTo(), sublayer}), |
135 ComputeType.ADVANCE, | 170 ComputeType.ADVANCE, |
136 stateId, | 171 stateId, |
137 hash)); | 172 hash)); |
138 } | 173 } |
139 } | 174 for (String loadDiameter: loadDiameters) { |
140 } | 175 int ndx = generateIndex(loadDiameter); |
141 | 176 ndx = ndx << 3; |
142 private int generateIndex(String diameter, boolean b) { | 177 ndx += i; |
178 newFacets.add(new BedloadDiameterDataFacet( | |
179 ndx, | |
180 BEDLOAD_DIAMETER_DATA, | |
181 Resources.getMsg( | |
182 context.getMeta(), | |
183 I18N_FACET_BEDLOAD_DIAMETER_DATA, | |
184 I18N_FACET_BEDLOAD_DIAMETER_DATA, | |
185 new Object[] { loadDiameter.toUpperCase(), | |
186 range.getFrom(), range.getTo()}), | |
187 ComputeType.ADVANCE, | |
188 stateId, | |
189 hash)); | |
190 } | |
191 } | |
192 } | |
193 | |
194 private int generateIndex(String diameter) { | |
143 int d = 0; | 195 int d = 0; |
144 if(diameter.equals("d10")) { | 196 if(diameter.equals("d10")) { |
145 d = 1; | 197 d = 1; |
146 } | 198 } |
147 else if (diameter.equals("d16")) { | 199 else if (diameter.equals("d16")) { |
187 d = 15; | 239 d = 15; |
188 } | 240 } |
189 else if (diameter.equals("dm")) { | 241 else if (diameter.equals("dm")) { |
190 d = 16; | 242 d = 16; |
191 } | 243 } |
192 int ndx = d; | 244 int ndx = d << 1; |
193 ndx = ndx << 1; | |
194 if (b) { | |
195 ndx += 1; | |
196 } | |
197 ndx = ndx << 3; | |
198 return ndx; | 245 return ndx; |
199 } | 246 } |
200 | 247 |
201 protected void generateFacets(CallContext context, List<Facet> newFacets, | 248 protected void generateFacets(CallContext context, List<Facet> newFacets, |
202 BedQualityResult[] results, String stateId, String hash) { | 249 BedQualityResult[] results, String stateId, String hash) { |
236 ComputeType.ADVANCE, | 283 ComputeType.ADVANCE, |
237 stateId, | 284 stateId, |
238 hash)); | 285 hash)); |
239 | 286 |
240 } | 287 } |
241 BedParametersResult[] bedParameters = result.getParameters(); | 288 if (bedDiameter.length > 0) { |
242 for (int j = 0; j < bedParameters.length; j++) { | 289 BedParametersResult[] bedParameters = result.getParameters(); |
243 newFacets.add(new BedPorosityFacet((idx << 8) + j, | 290 for (int j = 0; j < bedParameters.length; j++) { |
244 BED_QUALITY_POROSITY_TOPLAYER, | 291 newFacets.add(new BedPorosityFacet((idx << 8) + j, |
245 createPorosityTopLayerDescription( | 292 BED_QUALITY_POROSITY_TOPLAYER, |
246 meta, | 293 createPorosityTopLayerDescription( |
247 bedParameters[j], | 294 meta, |
248 range), | 295 bedParameters[j], |
249 ComputeType.ADVANCE, stateId, hash)); | 296 range), |
250 | 297 ComputeType.ADVANCE, stateId, hash)); |
251 newFacets.add(new BedPorosityFacet((idx << 8) + j, | 298 |
252 BED_QUALITY_POROSITY_SUBLAYER, | 299 newFacets.add(new BedPorosityFacet((idx << 8) + j, |
253 createPorositySubLayerDescription( | 300 BED_QUALITY_POROSITY_SUBLAYER, |
254 meta, | 301 createPorositySubLayerDescription( |
255 bedParameters[j], | 302 meta, |
256 range), | 303 bedParameters[j], |
257 ComputeType.ADVANCE, stateId, hash)); | 304 range), |
258 | 305 ComputeType.ADVANCE, stateId, hash)); |
259 newFacets.add(new BedDensityFacet((idx << 8) + j, | 306 |
260 BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER, | 307 newFacets.add(new BedDensityFacet((idx << 8) + j, |
261 createDensityTopLayerDescription( | 308 BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER, |
262 meta, | 309 createDensityTopLayerDescription( |
263 bedParameters[j], | 310 meta, |
264 range), | 311 bedParameters[j], |
265 ComputeType.ADVANCE, stateId, hash)); | 312 range), |
266 | 313 ComputeType.ADVANCE, stateId, hash)); |
267 newFacets.add(new BedDensityFacet((idx << 8) + j, | 314 |
268 BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER, | 315 newFacets.add(new BedDensityFacet((idx << 8) + j, |
269 createDensitySubLayerDescription( | 316 BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER, |
270 meta, | 317 createDensitySubLayerDescription( |
271 bedParameters[j], | 318 meta, |
272 range), | 319 bedParameters[j], |
273 ComputeType.ADVANCE, stateId, hash)); | 320 range), |
321 ComputeType.ADVANCE, stateId, hash)); | |
322 } | |
274 } | 323 } |
275 } | 324 } |
276 } | 325 } |
277 | 326 |
278 protected String createPorosityTopLayerDescription(CallMeta meta, | 327 protected String createPorosityTopLayerDescription(CallMeta meta, |