Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java @ 8202:e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 12:58:17 +0200 |
parents | a1ceacf15d3a |
children | 522f72f43ae6 |
comparison
equal
deleted
inserted
replaced
8201:4b8c5a08de04 | 8202:e4606eae8ea5 |
---|---|
46 /** State of a WINFOArtifact to get differences of data of other artifacts. */ | 46 /** State of a WINFOArtifact to get differences of data of other artifacts. */ |
47 public class WDifferencesState | 47 public class WDifferencesState |
48 extends DefaultState | 48 extends DefaultState |
49 implements FacetTypes | 49 implements FacetTypes |
50 { | 50 { |
51 /** The logger that is used in this state. */ | 51 /** The log that is used in this state. */ |
52 private static Logger logger = Logger.getLogger(WDifferencesState.class); | 52 private static Logger log = Logger.getLogger(WDifferencesState.class); |
53 | 53 |
54 private static final String I18N_DIFFERENCES_FACET_NAME = | 54 private static final String I18N_DIFFERENCES_FACET_NAME = |
55 "facet.w_differences"; | 55 "facet.w_differences"; |
56 private static final String I18N_DIFFERENCES_FACET_NAME_RAW = | 56 private static final String I18N_DIFFERENCES_FACET_NAME_RAW = |
57 "facet.w_differences.raw"; | 57 "facet.w_differences.raw"; |
107 | 107 |
108 /** | 108 /** |
109 * Access the data (wkms) of an artifact, coded in mingle. | 109 * Access the data (wkms) of an artifact, coded in mingle. |
110 */ | 110 */ |
111 public WKms getWKms(String mingle, CallContext context) { | 111 public WKms getWKms(String mingle, CallContext context) { |
112 logger.debug("WDifferencesState.getWKms " + mingle); | 112 log.debug("WDifferencesState.getWKms " + mingle); |
113 String[] def = mingle.split(";"); | 113 String[] def = mingle.split(";"); |
114 String uuid = def[0]; | 114 String uuid = def[0]; |
115 String name = def[1]; | 115 String name = def[1]; |
116 int idx = Integer.parseInt(def[2]); | 116 int idx = Integer.parseInt(def[2]); |
117 | 117 |
118 if (name.startsWith("staticwkms")) { | 118 if (name.startsWith("staticwkms")) { |
119 StaticWKmsArtifact staticWKms = | 119 StaticWKmsArtifact staticWKms = |
120 (StaticWKmsArtifact) RiverUtils.getArtifact( | 120 (StaticWKmsArtifact) RiverUtils.getArtifact( |
121 uuid, | 121 uuid, |
122 context); | 122 context); |
123 logger.debug("WDifferencesState obtain data from StaticWKms"); | 123 log.debug("WDifferencesState obtain data from StaticWKms"); |
124 WKms wkms = staticWKms.getWKms(idx); | 124 WKms wkms = staticWKms.getWKms(idx); |
125 if (wkms == null) | 125 if (wkms == null) |
126 logger.error("No WKms from artifact."); | 126 log.error("No WKms from artifact."); |
127 return wkms; | 127 return wkms; |
128 } | 128 } |
129 | 129 |
130 D4EArtifact d4eArtifact = RiverUtils.getArtifact( | 130 D4EArtifact d4eArtifact = RiverUtils.getArtifact( |
131 uuid, | 131 uuid, |
132 context); | 132 context); |
133 | 133 |
134 if (d4eArtifact == null) { | 134 if (d4eArtifact == null) { |
135 logger.warn("One of the artifacts (1) for diff calculation could not be loaded"); | 135 log.warn("One of the artifacts (1) for diff calculation could not be loaded"); |
136 return null; | 136 return null; |
137 } | 137 } |
138 | 138 |
139 if (d4eArtifact instanceof WINFOArtifact) { | 139 if (d4eArtifact instanceof WINFOArtifact) { |
140 logger.debug("Get WKms from WINFOArtifact"); | 140 log.debug("Get WKms from WINFOArtifact"); |
141 WINFOArtifact flys = (WINFOArtifact) d4eArtifact; | 141 WINFOArtifact flys = (WINFOArtifact) d4eArtifact; |
142 | 142 |
143 WKms[] wkms = (WKms[]) flys.getWaterlevelData(context). | 143 WKms[] wkms = (WKms[]) flys.getWaterlevelData(context). |
144 getData(); | 144 getData(); |
145 if (wkms == null || wkms.length == 0) { | 145 if (wkms == null || wkms.length == 0) { |
146 logger.warn("no waterlevels in artifact"); | 146 log.warn("no waterlevels in artifact"); |
147 } | 147 } |
148 else if (wkms.length < idx+1) { | 148 else if (wkms.length < idx+1) { |
149 logger.warn("Not enough waterlevels in artifact."); | 149 log.warn("Not enough waterlevels in artifact."); |
150 return new WQKms(); | 150 return new WQKms(); |
151 } | 151 } |
152 return wkms[idx]; | 152 return wkms[idx]; |
153 } | 153 } |
154 else if (d4eArtifact instanceof MINFOArtifact) { | 154 else if (d4eArtifact instanceof MINFOArtifact) { |
155 logger.debug("Get WKms from MINFOArtifact"); | 155 log.debug("Get WKms from MINFOArtifact"); |
156 CalculationResult r = (CalculationResult) | 156 CalculationResult r = (CalculationResult) |
157 d4eArtifact.compute(context, ComputeType.ADVANCE, false); | 157 d4eArtifact.compute(context, ComputeType.ADVANCE, false); |
158 } | 158 } |
159 else if (d4eArtifact instanceof FixationArtifact) { | 159 else if (d4eArtifact instanceof FixationArtifact) { |
160 logger.debug ("Get WKms from FixationArtifact."); | 160 log.debug ("Get WKms from FixationArtifact."); |
161 CalculationResult r = (CalculationResult) | 161 CalculationResult r = (CalculationResult) |
162 d4eArtifact.compute(context, ComputeType.ADVANCE, false); | 162 d4eArtifact.compute(context, ComputeType.ADVANCE, false); |
163 FixRealizingResult frR = (FixRealizingResult) r.getData(); | 163 FixRealizingResult frR = (FixRealizingResult) r.getData(); |
164 return frR.getWQKms()[idx]; | 164 return frR.getWQKms()[idx]; |
165 } | 165 } |
166 | 166 |
167 logger.error("Do not know how to handle (getWKms) minuend/subtrahend"); | 167 log.error("Do not know how to handle (getWKms) minuend/subtrahend"); |
168 return null; | 168 return null; |
169 } | 169 } |
170 | 170 |
171 | 171 |
172 /** | 172 /** |
191 | 191 |
192 // Load the Artifacts/facets that we want to subtract and display. | 192 // Load the Artifacts/facets that we want to subtract and display. |
193 // Expected format is: | 193 // Expected format is: |
194 // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....] | 194 // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....] |
195 String diffids = winfo.getDataAsString("diffids"); | 195 String diffids = winfo.getDataAsString("diffids"); |
196 logger.debug("WDifferencesState has: " + diffids); | 196 log.debug("WDifferencesState has: " + diffids); |
197 String datas[] = diffids.split("#"); | 197 String datas[] = diffids.split("#"); |
198 | 198 |
199 // Validate the Data-Strings. | 199 // Validate the Data-Strings. |
200 for (String s: datas) { | 200 for (String s: datas) { |
201 if (!WaterlevelSelectState.isValueValid(s)) { | 201 if (!WaterlevelSelectState.isValueValid(s)) { |
227 facetName = minName + " - " + subName; | 227 facetName = minName + " - " + subName; |
228 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuendWKms, | 228 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuendWKms, |
229 subtrahendWKms); | 229 subtrahendWKms); |
230 wkms.setName(facetName); | 230 wkms.setName(facetName); |
231 wkmss.add(wkms); | 231 wkmss.add(wkms); |
232 logger.debug("WKMSSubtraction happened"); | 232 log.debug("WKMSSubtraction happened"); |
233 } | 233 } |
234 if (facets != null) { | 234 if (facets != null) { |
235 facets.add(new DifferenceCurveFacet( | 235 facets.add(new DifferenceCurveFacet( |
236 i/2, | 236 i/2, |
237 W_DIFFERENCES, | 237 W_DIFFERENCES, |
257 } | 257 } |
258 | 258 |
259 if (facets != null) { | 259 if (facets != null) { |
260 facets.add(new DataFacet(CSV, "CSV data")); | 260 facets.add(new DataFacet(CSV, "CSV data")); |
261 facets.add(new DataFacet(PDF, "PDF data")); | 261 facets.add(new DataFacet(PDF, "PDF data")); |
262 logger.debug("Adding facets in WDifferencesState."); | 262 log.debug("Adding facets in WDifferencesState."); |
263 } | 263 } |
264 else { | 264 else { |
265 logger.debug("Not adding facets in WDifferencesState."); | 265 log.debug("Not adding facets in WDifferencesState."); |
266 } | 266 } |
267 | 267 |
268 // TODO Evaluate whether null is okay as reports. | 268 // TODO Evaluate whether null is okay as reports. |
269 WKms[] diffs = wkmss.toArray(new WKms[wkmss.size()]); | 269 WKms[] diffs = wkmss.toArray(new WKms[wkmss.size()]); |
270 CalculationResult result = new CalculationResult(diffs, null); | 270 CalculationResult result = new CalculationResult(diffs, null); |