Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/FixAnalysisAccess.java @ 3446:5325040d35e3
Adjusted i18n.
flys-artifacts/trunk@5109 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 23 Jul 2012 15:12:25 +0000 |
parents | 21c1d1d25919 |
children | 8160e62bbb3a |
rev | line source |
---|---|
3408
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.access; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifactdatabase.data.StateData; |
3411
0ef83077c93f
FixA: Renamed FixCalculation to FixAnalysisCalculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3408
diff
changeset
|
4 |
3408
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.flys.artifacts.FLYSArtifact; |
3411
0ef83077c93f
FixA: Renamed FixCalculation to FixAnalysisCalculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3408
diff
changeset
|
6 |
3408
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.flys.artifacts.model.DateRange; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import java.util.Arrays; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import java.util.Date; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import org.apache.log4j.Logger; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 public class FixAnalysisAccess |
3418
21c1d1d25919
FixA: Moved common parameter access to common base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3411
diff
changeset
|
15 extends FixAccess |
3408
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 private static Logger log = Logger.getLogger(FixAnalysisAccess.class); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 protected DateRange referencePeriod; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 protected DateRange [] analysisPeriods; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 protected double [] qs; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 public FixAnalysisAccess() { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 public FixAnalysisAccess(FLYSArtifact artifact) { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 super(artifact); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 public DateRange getReferencePeriod() { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 if (referencePeriod == null) { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 StateData refStart = artifact.getData("ref_start"); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 StateData refEnd = artifact.getData("ref_end"); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 if (refStart == null || refEnd == null) { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 log.warn("missing 'ref_start' or 'ref_start' value"); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 return null; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 try { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 long rs = Long.parseLong((String)refStart.getValue()); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 long re = Long.parseLong((String)refEnd .getValue()); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 if (rs > re) { long t = rs; rs = re; re = t; } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 Date from = new Date(rs); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 Date to = new Date(re); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 referencePeriod = new DateRange(from, to); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 catch (NumberFormatException nfe) { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 log.warn("ref_start or ref_end is not an integer."); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 return referencePeriod; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 public DateRange [] getAnalysisPeriods() { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 if (analysisPeriods == null) { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 analysisPeriods = getDateRange("ana_data"); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 return analysisPeriods; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 /** |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 * @return DateRange object ranging from eldest to youngest date |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 * of analysis and reference periods. |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 */ |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 public DateRange getDateRange() { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 DateRange refP = getReferencePeriod(); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 Date from = refP.getFrom(); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 Date to = refP.getTo(); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 DateRange[] rs = getAnalysisPeriods(); |
3418
21c1d1d25919
FixA: Moved common parameter access to common base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3411
diff
changeset
|
78 for (DateRange r: rs) { |
21c1d1d25919
FixA: Moved common parameter access to common base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3411
diff
changeset
|
79 if (r.getFrom().before(from)) { |
3408
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 from = r.getFrom(); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 } |
3418
21c1d1d25919
FixA: Moved common parameter access to common base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3411
diff
changeset
|
82 if (r.getTo().after(to)) { |
3408
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 to = r.getTo(); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 return new DateRange(from, to); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 public double [] getQs() { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 if (qs == null) { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 qs = getDoubleArray("qs"); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 if (log.isDebugEnabled() && qs != null) { |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 log.debug("qs: " + Arrays.toString(qs)); |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 return qs; |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 } |
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |