comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 5027:25c180fa6162

Use BWASTRParser to set official numbers on rivers.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 19 Feb 2013 16:41:00 +0100
parents 443c173f043a
children e6dc908297e8
comparison
equal deleted inserted replaced
5021:bf22086747bc 5027:25c180fa6162
295 parseSedimentYield(); 295 parseSedimentYield();
296 parseWaterlevels(); 296 parseWaterlevels();
297 parseWaterlevelDifferences(); 297 parseWaterlevelDifferences();
298 parseMeasurementStations(); 298 parseMeasurementStations();
299 parseSQRelation(); 299 parseSQRelation();
300 storeOfficialNumber();
300 } 301 }
301 302
302 public void parseFloodProtection() throws IOException { 303 public void parseFloodProtection() throws IOException {
303 if (Config.INSTANCE.skipFloodProtection()) { 304 if (Config.INSTANCE.skipFloodProtection()) {
304 log.info("skip parsing flood protection"); 305 log.info("skip parsing flood protection");
339 iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription()); 340 iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription());
340 floodProtection.add(iw); 341 floodProtection.add(iw);
341 } 342 }
342 } 343 }
343 344
345 public void storeOfficialNumber() {
346 if (Config.INSTANCE.skipBWASTR()) {
347 log.info("skip storing official number.");
348 return;
349 }
350 getPeer().setOfficialNumber(officialNumber);
351 }
344 352
345 public void parseBedHeight() throws IOException { 353 public void parseBedHeight() throws IOException {
346 File minfoDir = getMinfoDir(); 354 File minfoDir = getMinfoDir();
347 File bedHeightDir = new File(minfoDir, BED_HEIGHT_DIR); 355 File bedHeightDir = new File(minfoDir, BED_HEIGHT_DIR);
348 File singlesDir = new File(bedHeightDir, BED_HEIGHT_SINGLE_DIR); 356 File singlesDir = new File(bedHeightDir, BED_HEIGHT_SINGLE_DIR);
1445 public River getPeer() { 1453 public River getPeer() {
1446 if (peer == null) { 1454 if (peer == null) {
1447 Session session = ImporterSession.getInstance().getDatabaseSession(); 1455 Session session = ImporterSession.getInstance().getDatabaseSession();
1448 Query query = session.createQuery("from River where name=:name"); 1456 Query query = session.createQuery("from River where name=:name");
1449 1457
1450 Unit u = wstUnit.getPeer(); 1458 Unit u = null;
1459 if (wstUnit != null) {
1460 u = wstUnit.getPeer();
1461 }
1451 1462
1452 query.setString("name", name); 1463 query.setString("name", name);
1453 List<River> rivers = query.list(); 1464 List<River> rivers = query.list();
1454 if (rivers.isEmpty()) { 1465 if (rivers.isEmpty()) {
1455 log.info("Store new river '" + name + "'"); 1466 log.info("Store new river '" + name + "'");
1456 peer = new River(name, u); 1467 peer = new River(name, u);
1468 if (!Config.INSTANCE.skipBWASTR()) {
1469 peer.setOfficialNumber(officialNumber);
1470 }
1457 session.save(peer); 1471 session.save(peer);
1458 } 1472 }
1459 else { 1473 else {
1460 peer = rivers.get(0); 1474 peer = rivers.get(0);
1461 } 1475 }

http://dive4elements.wald.intevation.org