Mercurial > dive4elements > river
diff flys-aft/src/main/java/de/intevation/aft/Rivers.java @ 4753:a310aceb2e51
Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 03 Jan 2013 14:19:45 +0100 |
parents | b20b710aa86f |
children | f939e1e6cfa4 |
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/aft/Rivers.java Thu Jan 03 11:43:16 2013 +0100 +++ b/flys-aft/src/main/java/de/intevation/aft/Rivers.java Thu Jan 03 14:19:45 2013 +0100 @@ -27,35 +27,44 @@ ConnectedStatements flysStatements = context.getFlysStatements(); ConnectedStatements aftStatements = context.getAftStatements(); - Map<String, Integer> flysRivers = new HashMap<String, Integer>(); + Map<String, River> flysRivers = new HashMap<String, River>(); ResultSet flysRs = flysStatements - .getStatement("select.river").executeQuery(); + .getStatement("select.rivers").executeQuery(); - while (flysRs.next()) { - Integer id = flysRs.getInt("id"); - String name = flysRs.getString("name").toLowerCase(); - flysRivers.put(name, id); + try { + while (flysRs.next()) { + int id = flysRs.getInt("id"); + String name = flysRs.getString("name"); + double from = flysRs.getDouble("min_km"); + double to = flysRs.getDouble("max_km"); + flysRivers.put(name.toLowerCase(), new River(id, name, from, to)); + } } - - flysRs.close(); + finally { + flysRs.close(); + } List<River> commonRivers = new ArrayList<River>(); ResultSet aftRs = aftStatements .getStatement("select.gewaesser").executeQuery(); - while (aftRs.next()) { - String name = aftRs.getString("NAME"); - Integer id1 = flysRivers.get(name.toLowerCase()); - if (id1 != null) { - int id2 = aftRs.getInt("GEWAESSER_NR"); - River river = new River(id1, id2, name); - commonRivers.add(river); + try { + while (aftRs.next()) { + String name = aftRs.getString("NAME"); + River river = flysRivers.get(name.toLowerCase()); + if (river != null) { + int id2 = aftRs.getInt("GEWAESSER_NR"); + river.setId2(id2); + commonRivers.add(river); + } } } + finally { + aftRs.close(); + } - aftRs.close(); boolean modified = false;