9267
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
|
2 * Software engineering by Intevation GmbH |
|
3 * |
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
|
6 * documentation coming with Dive4Elements River for details. |
|
7 */ |
|
8 |
|
9 package org.dive4elements.river.artifacts.bundu.bezugswst; |
|
10 |
|
11 import org.apache.log4j.Logger; |
|
12 import org.dive4elements.river.artifacts.D4EArtifact; |
|
13 import org.dive4elements.river.artifacts.access.FixAnalysisAccess; |
|
14 |
|
15 public class BunduAccess extends FixAnalysisAccess { |
|
16 |
|
17 private static Logger log = Logger.getLogger(BunduAccess.class); |
|
18 |
|
19 // Alles, was in super steht, auskommentiert. TODO: endgültig löschen, nachdem ich es etwas verstanden habe |
|
20 |
|
21 // protected DateRange referencePeriod; |
|
22 // protected DateRange[] analysisPeriods; |
|
23 // |
|
24 // protected double[] qs; |
|
25 |
|
26 public BunduAccess(final D4EArtifact artifact) { |
|
27 super(artifact); |
|
28 } |
|
29 |
|
30 public boolean isAutoSelect() { |
|
31 final String fixChoice = this.artifact.getDataAsString("fix_choice"); |
9366
|
32 if (fixChoice != null && fixChoice.equals("state.bundu.wst.fix.auto")) { |
9267
|
33 return true; |
|
34 } |
|
35 return false; |
|
36 } |
|
37 |
|
38 public Integer getBezugsJahr() { |
|
39 return this.artifact.getDataAsInteger("singleyear"); |
|
40 } |
|
41 |
|
42 public int[] getEventsTemp() { |
|
43 return getIntArray("events_temp"); |
|
44 } |
|
45 |
9277
|
46 public int getQSeriesLength() { |
|
47 return this.artifact.getDataAsInteger("year_input_q_series"); |
|
48 } |
|
49 |
9323
|
50 public int getStartYear() { |
9396
|
51 return this.getBezugsJahr() - this.getQSeriesLength() + 1; |
9323
|
52 } |
|
53 |
|
54 public Integer getUd() { |
|
55 if (getUd_Q_mode().equals("UD")) |
|
56 return getInteger("bundu.wst.ud_value"); |
|
57 else |
|
58 return null; |
|
59 } |
|
60 |
|
61 @Override |
|
62 public double[] getQs() { |
|
63 if (getUd_Q_mode().equals("Q")) |
|
64 return super.getQs(); |
|
65 else |
|
66 return null; |
|
67 } |
|
68 |
|
69 private String getUd_Q_mode() { |
|
70 return getString("bundu.wst.mode"); |
|
71 } |
|
72 |
|
73 public Double getMissingVolFrom() { |
|
74 if (isCalculateMissingValue()) |
|
75 return getDouble("ld_from_part"); |
|
76 else |
|
77 return null; |
|
78 } |
|
79 |
|
80 public Double getMissingVolTo() { |
|
81 if (isCalculateMissingValue()) |
|
82 return getDouble("ld_to_part"); |
|
83 else |
|
84 return null; |
|
85 } |
|
86 |
|
87 private boolean isCalculateMissingValue() { // probably public |
|
88 return getBoolean("missing_volume"); |
|
89 } |
|
90 |
9267
|
91 // /** Access the reference date period, return null in case of 'errors'. */ |
|
92 // public DateRange getReferencePeriod() { |
|
93 // if (this.referencePeriod == null) { |
|
94 // final StateData refStart = artifact.getData("ref_start"); |
|
95 // final StateData refEnd = artifact.getData("ref_end"); |
|
96 // |
|
97 // if (refStart == null || refEnd == null) { |
|
98 // log.warn("missing 'ref_start' or 'ref_start' value"); |
|
99 // return null; |
|
100 // } |
|
101 // |
|
102 // try { |
|
103 // long rs = Long.parseLong((String) refStart.getValue()); |
|
104 // long re = Long.parseLong((String) refEnd.getValue()); |
|
105 // |
|
106 // if (rs > re) { |
|
107 // final long t = rs; |
|
108 // rs = re; |
|
109 // re = t; |
|
110 // } |
|
111 // |
|
112 // final Date from = new Date(rs); |
|
113 // final Date to = new Date(re); |
|
114 // this.referencePeriod = new DateRange(from, to); |
|
115 // } |
|
116 // catch (final NumberFormatException nfe) { |
|
117 // log.warn("ref_start or ref_end is not an integer."); |
|
118 // } |
|
119 // } |
|
120 // |
|
121 // return this.referencePeriod; |
|
122 // } |
|
123 |
|
124 // @Override |
|
125 // public DateRange[] getAnalysisPeriods() { |
|
126 // if (this.analysisPeriods == null) { |
|
127 // this.analysisPeriods = getDateRange("ana_data"); |
|
128 // } |
|
129 // |
|
130 // return this.analysisPeriods; |
|
131 // } |
|
132 |
|
133 /** |
|
134 * @return DateRange object ranging from eldest to youngest date |
|
135 * of analysis and reference periods. |
|
136 */ |
|
137 // @Override |
|
138 // public DateRange getDateRange() { |
|
139 // final DateRange refP = getReferencePeriod(); |
|
140 // |
|
141 // if (refP == null) { |
|
142 // return null; |
|
143 // } |
|
144 // |
|
145 // Date from = refP.getFrom(); |
|
146 // Date to = refP.getTo(); |
|
147 // |
|
148 // final DateRange[] rs = getAnalysisPeriods(); |
|
149 // for (final DateRange r : rs) { |
|
150 // if (r.getFrom().before(from)) { |
|
151 // from = r.getFrom(); |
|
152 // } |
|
153 // if (r.getTo().after(to)) { |
|
154 // to = r.getTo(); |
|
155 // } |
|
156 // } |
|
157 // |
|
158 // return new DateRange(from, to); |
|
159 // } |
|
160 |
|
161 // @Override |
|
162 // public double[] getQs() { |
|
163 // if (this.qs == null) { |
|
164 // this.qs = getDoubleArray("qs"); |
|
165 // } |
|
166 // |
|
167 // if (log.isDebugEnabled() && this.qs != null) { |
|
168 // log.debug("qs: " + Arrays.toString(this.qs)); |
|
169 // } |
|
170 // return this.qs; |
|
171 // } |
|
172 } |
|
173 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |