Mercurial > dive4elements > river
comparison flys-aft/src/main/java/de/intevation/aft/River.java @ 4088:52cde7fe742a
Fetch discharge table infos from AFT.
flys-aft/trunk@3573 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 03 Jan 2012 11:36:07 +0000 |
parents | aad1886ea226 |
children | d556e29592f5 |
comparison
equal
deleted
inserted
replaced
4087:aad1886ea226 | 4088:52cde7fe742a |
---|---|
2 | 2 |
3 import java.util.List; | 3 import java.util.List; |
4 import java.util.ArrayList; | 4 import java.util.ArrayList; |
5 import java.util.HashMap; | 5 import java.util.HashMap; |
6 import java.util.Map; | 6 import java.util.Map; |
7 import java.util.Date; | |
7 | 8 |
8 import java.sql.ResultSet; | 9 import java.sql.ResultSet; |
9 import java.sql.SQLException; | 10 import java.sql.SQLException; |
10 | 11 |
11 import org.apache.log4j.Logger; | 12 import org.apache.log4j.Logger; |
161 insertStmnt.execute(); | 162 insertStmnt.execute(); |
162 | 163 |
163 log.info("FLYS: Created gauge '" + gauge.getAftName() + | 164 log.info("FLYS: Created gauge '" + gauge.getAftName() + |
164 "' with id " + gaugeId + "."); | 165 "' with id " + gaugeId + "."); |
165 | 166 |
167 gauge.setFlysId(gaugeId); | |
168 createDischargeTables(context, officialNumber, gauge); | |
169 | |
166 flysStatements.commitTransaction(); | 170 flysStatements.commitTransaction(); |
167 } | 171 } |
168 catch (SQLException sqle) { | 172 catch (SQLException sqle) { |
169 flysStatements.rollbackTransaction(); | 173 flysStatements.rollbackTransaction(); |
170 throw sqle; | 174 throw sqle; |
175 } | 179 } |
176 } | 180 } |
177 } | 181 } |
178 } | 182 } |
179 | 183 |
184 protected void createDischargeTables( | |
185 SyncContext context, | |
186 Long officialNumber, | |
187 DIPSGauge gauge | |
188 ) | |
189 throws SQLException | |
190 { | |
191 log.info("create discharge tables"); | |
192 | |
193 boolean debug = log.isDebugEnabled(); | |
194 | |
195 ConnectedStatements flysStatements = context.getFlysStatements(); | |
196 ConnectedStatements aftStatements = context.getAftStatements(); | |
197 | |
198 ResultSet rs = null; | |
199 try { | |
200 rs = aftStatements.getStatement("select.abflusstafel") | |
201 .clearParameters() | |
202 .setString("number", "%" + officialNumber). | |
203 executeQuery(); | |
204 | |
205 while (rs.next()) { | |
206 int dtId = rs.getInt("ABFLUSSTAFEL_NR"); | |
207 Date from = rs.getDate("GUELTIG_VON"); | |
208 Date to = rs.getDate("GUELTIG_BIS"); | |
209 | |
210 double datumValue = rs.getDouble("PEGELNULLPUNKT"); | |
211 Double datum = rs.wasNull() ? null : datumValue; | |
212 | |
213 if (debug) { | |
214 log.debug("id: " + dtId); | |
215 log.debug("valid from: " + from); | |
216 log.debug("valid to: " + to); | |
217 log.debug("datum: " + datum); | |
218 } | |
219 } | |
220 } | |
221 finally { | |
222 if (rs != null) { | |
223 rs.close(); | |
224 } | |
225 } | |
226 } | |
227 | |
180 public String toString() { | 228 public String toString() { |
181 return "[River: name=" + name + ", " + super.toString() + "]"; | 229 return "[River: name=" + name + ", " + super.toString() + "]"; |
182 } | 230 } |
183 | 231 |
184 } | 232 } |