Mercurial > dive4elements > river
comparison flys-aft/src/main/java/de/intevation/aft/DischargeTable.java @ 4097:83c72bc07591
Load all discharge tables from AFT and FLYS of a gauge which needs updating.
flys-aft/trunk@3618 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 06 Jan 2012 18:32:08 +0000 |
parents | 7bddd4601707 |
children | 006e99437fb9 |
comparison
equal
deleted
inserted
replaced
4096:82f5266f881b | 4097:83c72bc07591 |
---|---|
1 package de.intevation.aft; | 1 package de.intevation.aft; |
2 | 2 |
3 import java.util.List; | 3 import java.util.List; |
4 import java.util.Date; | |
4 import java.util.ArrayList; | 5 import java.util.ArrayList; |
5 | 6 |
6 import java.sql.SQLException; | 7 import java.sql.SQLException; |
7 import java.sql.ResultSet; | 8 import java.sql.ResultSet; |
8 | 9 |
137 .setDouble("w", wq.getW()) | 138 .setDouble("w", wq.getW()) |
138 .setDouble("q", wq.getQ()) | 139 .setDouble("q", wq.getQ()) |
139 .execute(); | 140 .execute(); |
140 } | 141 } |
141 } | 142 } |
143 | |
144 public static List<DischargeTable> loadFlysDischargeTables( | |
145 SyncContext context, | |
146 int gaugeId | |
147 ) | |
148 throws SQLException | |
149 { | |
150 List<DischargeTable> dts = new ArrayList<DischargeTable>(); | |
151 | |
152 ResultSet rs = context | |
153 .getFlysStatements() | |
154 .getStatement("select.gauge.discharge.tables") | |
155 .clearParameters() | |
156 .setInt("gauge_id", gaugeId) | |
157 .executeQuery(); | |
158 | |
159 while (rs.next()) { | |
160 int id = rs.getInt("id"); | |
161 String description = rs.getString("description"); | |
162 Date startTime = rs.getDate("start_time"); | |
163 Date stopTime = rs.getDate("stop_time"); | |
164 TimeInterval ti = startTime == null | |
165 ? null | |
166 : new TimeInterval(startTime, stopTime); | |
167 DischargeTable dt = new DischargeTable( | |
168 id, gaugeId, ti, description); | |
169 dts.add(dt); | |
170 } | |
171 rs.close(); | |
172 | |
173 return dts; | |
174 } | |
175 | |
176 public static List<DischargeTable> loadAftDischargeTables( | |
177 SyncContext context, | |
178 Long officialNumber | |
179 ) | |
180 throws SQLException | |
181 { | |
182 return loadAftDischargeTables(context, officialNumber, 0); | |
183 } | |
184 | |
185 public static List<DischargeTable> loadAftDischargeTables( | |
186 SyncContext context, | |
187 Long officialNumber, | |
188 int flysGaugeId | |
189 ) | |
190 throws SQLException | |
191 { | |
192 List<DischargeTable> dts = new ArrayList<DischargeTable>(); | |
193 | |
194 ResultSet rs = context | |
195 .getAftStatements() | |
196 .getStatement("select.abflusstafel") | |
197 .clearParameters() | |
198 .setString("number", "%" + officialNumber) | |
199 .executeQuery(); | |
200 | |
201 while (rs.next()) { | |
202 int dtId = rs.getInt("ABFLUSSTAFEL_NR"); | |
203 Date from = rs.getDate("GUELTIG_VON"); | |
204 Date to = rs.getDate("GUELTIG_BIS"); | |
205 String description = rs.getString("ABFLUSSTAFEL_BEZ"); | |
206 if (description == null) { | |
207 description = String.valueOf(officialNumber); | |
208 } | |
209 | |
210 double datumValue = rs.getDouble("PEGELNULLPUNKT"); | |
211 Double datum = rs.wasNull() ? null : datumValue; | |
212 | |
213 TimeInterval timeInterval = from == null | |
214 ? null | |
215 : new TimeInterval(from, to); | |
216 | |
217 DischargeTable dt = new DischargeTable( | |
218 dtId, | |
219 flysGaugeId, | |
220 timeInterval, | |
221 description); | |
222 dts.add(dt); | |
223 } | |
224 rs.close(); | |
225 | |
226 return dts; | |
227 } | |
142 } | 228 } |
143 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 229 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |