Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixationArtifactAccess.java @ 3207:babb0798d548
Removed dead code.
flys-artifacts/trunk@4826 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 28 Jun 2012 14:50:14 +0000 |
parents | e11dbf8baf69 |
children | 90c4ce100ce1 |
comparison
equal
deleted
inserted
replaced
3206:e11dbf8baf69 | 3207:babb0798d548 |
---|---|
15 import java.util.Date; | 15 import java.util.Date; |
16 | 16 |
17 import org.apache.log4j.Logger; | 17 import org.apache.log4j.Logger; |
18 | 18 |
19 public class FixationArtifactAccess | 19 public class FixationArtifactAccess |
20 extends Access | |
20 { | 21 { |
21 private static Logger log = Logger.getLogger(FixationArtifactAccess.class); | 22 private static Logger log = Logger.getLogger(FixationArtifactAccess.class); |
22 | |
23 protected FLYSArtifact artifact; | |
24 | 23 |
25 protected String river; | 24 protected String river; |
26 | 25 |
27 protected String calculationMode; | 26 protected String calculationMode; |
28 | 27 |
49 | 48 |
50 public FixationArtifactAccess() { | 49 public FixationArtifactAccess() { |
51 } | 50 } |
52 | 51 |
53 public FixationArtifactAccess(FLYSArtifact artifact) { | 52 public FixationArtifactAccess(FLYSArtifact artifact) { |
54 this.artifact = artifact; | 53 super(artifact); |
55 } | |
56 | |
57 public FLYSArtifact getArtifact() { | |
58 return artifact; | |
59 } | 54 } |
60 | 55 |
61 public String getRiver() { | 56 public String getRiver() { |
62 if (river == null) { | 57 if (river == null) { |
63 StateData sd = artifact.getData("river"); | 58 river = getString("river"); |
64 if (sd == null) { | |
65 log.warn("missing 'river' value"); | |
66 return null; | |
67 } | |
68 river = (String)sd.getValue(); | |
69 } | 59 } |
70 if (log.isDebugEnabled()) { | 60 if (log.isDebugEnabled()) { |
71 log.debug("river: '" + river + "'"); | 61 log.debug("river: '" + river + "'"); |
72 } | 62 } |
73 return river; | 63 return river; |
74 } | 64 } |
75 | 65 |
76 public String getCalculationMode() { | 66 public String getCalculationMode() { |
77 if (calculationMode == null) { | 67 if (calculationMode == null) { |
78 StateData sd = artifact.getData("calculation.mode"); | 68 calculationMode = getString("calculation.mode"); |
79 if (sd == null) { | |
80 log.warn("missing 'calculation.mode' value"); | |
81 return null; | |
82 } | |
83 calculationMode = (String)sd.getValue(); | |
84 } | 69 } |
85 | 70 |
86 if (log.isDebugEnabled()) { | 71 if (log.isDebugEnabled()) { |
87 log.debug("calculationMode: '" + calculationMode + "'"); | 72 log.debug("calculationMode: '" + calculationMode + "'"); |
88 } | 73 } |
90 } | 75 } |
91 | 76 |
92 public Double getFrom() { | 77 public Double getFrom() { |
93 | 78 |
94 if (from == null) { | 79 if (from == null) { |
95 StateData sd = artifact.getData("from"); | 80 from = getDouble("from"); |
96 if (sd == null) { | |
97 log.warn("missing 'from' value"); | |
98 return null; | |
99 } | |
100 try { | |
101 from = Double.valueOf((String)sd.getValue()); | |
102 } | |
103 catch (NumberFormatException nfe) { | |
104 log.warn("from '" + sd.getValue() + "' is not numeric."); | |
105 } | |
106 } | 81 } |
107 | 82 |
108 if (log.isDebugEnabled()) { | 83 if (log.isDebugEnabled()) { |
109 log.debug("from: '" + from + "'"); | 84 log.debug("from: '" + from + "'"); |
110 } | 85 } |
113 } | 88 } |
114 | 89 |
115 public Double getTo() { | 90 public Double getTo() { |
116 | 91 |
117 if (to == null) { | 92 if (to == null) { |
118 StateData sd = artifact.getData("to"); | 93 to = getDouble("to"); |
119 if (sd == null) { | |
120 log.warn("missing 'to' value"); | |
121 return null; | |
122 } | |
123 try { | |
124 to = Double.valueOf((String)sd.getValue()); | |
125 } | |
126 catch (NumberFormatException nfe) { | |
127 log.warn("to '" + sd.getValue() + "' is not numeric."); | |
128 } | |
129 } | 94 } |
130 | 95 |
131 if (log.isDebugEnabled()) { | 96 if (log.isDebugEnabled()) { |
132 log.debug("to: '" + to + "'"); | 97 log.debug("to: '" + to + "'"); |
133 } | 98 } |
136 } | 101 } |
137 | 102 |
138 public Double getStep() { | 103 public Double getStep() { |
139 | 104 |
140 if (step == null) { | 105 if (step == null) { |
141 StateData sd = artifact.getData("step"); | 106 step = getDouble("step"); |
142 if (sd == null) { | |
143 log.warn("missing 'step' value"); | |
144 return null; | |
145 } | |
146 try { | |
147 step = Double.valueOf((String)sd.getValue()); | |
148 } | |
149 catch (NumberFormatException nfe) { | |
150 log.warn("step '" + sd.getValue() + "' is not numeric."); | |
151 } | |
152 } | 107 } |
153 | 108 |
154 if (log.isDebugEnabled()) { | 109 if (log.isDebugEnabled()) { |
155 log.debug("step: '" + step + "'"); | 110 log.debug("step: '" + step + "'"); |
156 } | 111 } |
159 } | 114 } |
160 | 115 |
161 public Long getStart() { | 116 public Long getStart() { |
162 | 117 |
163 if (start == null) { | 118 if (start == null) { |
164 StateData sd = artifact.getData("start"); | 119 start = getLong("start"); |
165 if (sd == null) { | |
166 log.warn("missing 'start' value"); | |
167 return null; | |
168 } | |
169 try { | |
170 start = Long.valueOf((String)sd.getValue()); | |
171 } | |
172 catch (NumberFormatException nfe) { | |
173 log.warn("start '" + sd.getValue() + "' is not an integer."); | |
174 } | |
175 } | 120 } |
176 | 121 |
177 if (log.isDebugEnabled()) { | 122 if (log.isDebugEnabled()) { |
178 log.debug("start: '" + start + "'"); | 123 log.debug("start: '" + start + "'"); |
179 } | 124 } |
182 } | 127 } |
183 | 128 |
184 public Long getEnd() { | 129 public Long getEnd() { |
185 | 130 |
186 if (end == null) { | 131 if (end == null) { |
187 StateData sd = artifact.getData("end"); | 132 end = getLong("end"); |
188 if (sd == null) { | |
189 log.warn("missing 'end' value"); | |
190 return null; | |
191 } | |
192 try { | |
193 end = Long.valueOf((String)sd.getValue()); | |
194 } | |
195 catch (NumberFormatException nfe) { | |
196 log.warn("end '" + sd.getValue() + "' is not an integer."); | |
197 } | |
198 } | 133 } |
199 | 134 |
200 if (log.isDebugEnabled()) { | 135 if (log.isDebugEnabled()) { |
201 log.debug("end: '" + end + "'"); | 136 log.debug("end: '" + end + "'"); |
202 } | 137 } |
205 } | 140 } |
206 | 141 |
207 public Integer getQSectorStart() { | 142 public Integer getQSectorStart() { |
208 | 143 |
209 if (qSectorStart == null) { | 144 if (qSectorStart == null) { |
210 StateData sd = artifact.getData("q1"); | 145 qSectorStart = getInteger("q1"); |
211 if (sd == null) { | |
212 log.warn("missing 'q1' value"); | |
213 return null; | |
214 } | |
215 try { | |
216 qSectorStart = Integer.valueOf((String)sd.getValue()); | |
217 } | |
218 catch (NumberFormatException nfe) { | |
219 log.warn("q1 '" + sd.getValue() + "' is not an integer."); | |
220 } | |
221 } | 146 } |
222 | 147 |
223 return qSectorStart; | 148 return qSectorStart; |
224 } | 149 } |
225 | 150 |
226 public Integer getQSectorEnd() { | 151 public Integer getQSectorEnd() { |
227 | 152 |
228 if (qSectorEnd == null) { | 153 if (qSectorEnd == null) { |
229 StateData sd = artifact.getData("q2"); | 154 qSectorEnd = getInteger("q2"); |
230 if (sd == null) { | |
231 log.warn("missing 'q2' value"); | |
232 return null; | |
233 } | |
234 try { | |
235 qSectorEnd = Integer.valueOf((String)sd.getValue()); | |
236 } | |
237 catch (NumberFormatException nfe) { | |
238 log.warn("q2 '" + sd.getValue() + "' is not an integer."); | |
239 } | |
240 } | 155 } |
241 | 156 |
242 return qSectorEnd; | 157 return qSectorEnd; |
243 } | 158 } |
244 | 159 |
245 public int [] getEvents() { | 160 public int [] getEvents() { |
246 if (events == null) { | 161 if (events == null) { |
247 StateData sd = artifact.getData("events"); | 162 events = getIntArray("events"); |
248 if (sd == null) { | |
249 log.warn("missing 'events' value"); | |
250 return null; | |
251 } | |
252 events = FLYSUtils.intArrayFromString((String)sd.getValue()); | |
253 } | 163 } |
254 return events; | 164 return events; |
255 } | 165 } |
256 | 166 |
257 public DateRange getReferencePeriod() { | 167 public DateRange getReferencePeriod() { |
282 return referencePeriod; | 192 return referencePeriod; |
283 } | 193 } |
284 | 194 |
285 public DateRange [] getAnalysisPeriods() { | 195 public DateRange [] getAnalysisPeriods() { |
286 if (analysisPeriods == null) { | 196 if (analysisPeriods == null) { |
287 StateData sd = artifact.getData("ana_data"); | 197 analysisPeriods = getDateRange("ana_date"); |
288 | |
289 if (sd == null) { | |
290 log.warn("missing 'ana_data'"); | |
291 return null; | |
292 } | |
293 | |
294 String data = (String)sd.getValue(); | |
295 String[] pairs = data.split("\\s*;\\s*"); | |
296 | |
297 ArrayList<DateRange> aPs = new ArrayList<DateRange>(pairs.length); | |
298 | |
299 for (int i = 0; i < pairs.length; i++) { | |
300 String[] fromTo = pairs[i].split("\\s*,\\s*"); | |
301 if (fromTo.length >= 2) { | |
302 try { | |
303 Date from = new Date(Long.parseLong(fromTo[0])); | |
304 Date to = new Date(Long.parseLong(fromTo[1])); | |
305 DateRange aP = new DateRange(from, to); | |
306 if (!aPs.contains(aP)) { | |
307 aPs.add(aP); | |
308 } | |
309 } | |
310 catch (NumberFormatException nfe) { | |
311 log.warn("ana_data contains no long values.", nfe); | |
312 } | |
313 } | |
314 } | |
315 | |
316 analysisPeriods = aPs.toArray(new DateRange[aPs.size()]); | |
317 } | |
318 | |
319 if (log.isDebugEnabled()) { | |
320 for (int i = 0; i < analysisPeriods.length; ++i) { | |
321 DateRange ap = analysisPeriods[i]; | |
322 log.debug("analysis period " + | |
323 ap.getFrom() + " - " + ap.getTo()); | |
324 } | |
325 } | 198 } |
326 | 199 |
327 return analysisPeriods; | 200 return analysisPeriods; |
328 } | 201 } |
329 | 202 |
330 public Boolean getPreprocessing() { | 203 public Boolean getPreprocessing() { |
331 if (preprocessing == null) { | 204 if (preprocessing == null) { |
332 StateData sd = artifact.getData("preprocessing"); | 205 preprocessing = getBoolean("preprocessing"); |
333 if (sd == null) { | |
334 log.warn("missing 'preprocessing'"); | |
335 return null; | |
336 } | |
337 preprocessing = Boolean.valueOf((String)sd.getValue()); | |
338 } | 206 } |
339 return preprocessing; | 207 return preprocessing; |
340 } | 208 } |
341 | 209 |
342 public String getFunction() { | 210 public String getFunction() { |
343 if (function == null) { | 211 if (function == null) { |
344 StateData sd = artifact.getData("function"); | 212 function = getString("function"); |
345 if (sd == null) { | |
346 log.warn("missing 'function'"); | |
347 return null; | |
348 } | |
349 function = (String)sd.getValue(); | |
350 } | 213 } |
351 if (log.isDebugEnabled()) { | 214 if (log.isDebugEnabled()) { |
352 log.debug("function: " + function); | 215 log.debug("function: " + function); |
353 } | 216 } |
354 return function; | 217 return function; |
355 } | 218 } |
356 | 219 |
357 public double [] getQs() { | 220 public double [] getQs() { |
358 if (qs == null) { | 221 if (qs == null) { |
359 StateData sd = artifact.getData("qs"); | 222 qs = getDoubleArray("qs"); |
360 if (sd == null) { | 223 } |
361 log.warn("missing 'qs'"); | 224 |
362 return null; | 225 if (log.isDebugEnabled() && qs != null) { |
363 } | |
364 String [] parts = ((String)sd.getValue()).split("[\\s;]"); | |
365 TDoubleArrayList list = new TDoubleArrayList(parts.length); | |
366 for (String part: parts) { | |
367 try { | |
368 list.add(Double.parseDouble(part)); | |
369 } | |
370 catch (NumberFormatException nfe) { | |
371 log.warn("'" + part + "' is not numeric."); | |
372 } | |
373 } | |
374 qs = list.toNativeArray(); | |
375 } | |
376 if (log.isDebugEnabled()) { | |
377 log.debug("qs: " + Arrays.toString(qs)); | 226 log.debug("qs: " + Arrays.toString(qs)); |
378 } | 227 } |
379 return qs; | 228 return qs; |
380 } | 229 } |
381 } | 230 } |