# HG changeset patch # User Sascha L. Teichmann # Date 1304694904 0 # Node ID 88d5b02ff0c1e28883b425ff8c55ab623282b5c3 # Parent b35c5dc0f8b70d5ad6b3a2ae81a09eeb5a0d6ea2 Importer: Import the "HW-Schutzanlagen", too. flys-backend/trunk@1845 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r b35c5dc0f8b7 -r 88d5b02ff0c1 flys-backend/ChangeLog --- a/flys-backend/ChangeLog Fri May 06 10:27:32 2011 +0000 +++ b/flys-backend/ChangeLog Fri May 06 15:15:04 2011 +0000 @@ -1,6 +1,11 @@ 2011-05-05 Sascha L. Teichmann - Make import of historical discharge tables work. + * src/main/java/de/intevation/flys/importer/ImportRiver.java: + Import the "HW-Schutzanlagen", too. + +2011-05-05 Sascha L. Teichmann + + Make import of historical discharge tables work. * doc/schema/postgresql.sql: Added forgotten column 'description'. diff -r b35c5dc0f8b7 -r 88d5b02ff0c1 flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Fri May 06 10:27:32 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Fri May 06 15:15:04 2011 +0000 @@ -35,6 +35,9 @@ public static final String FLOOD_WATER = "HW-Marken"; + public static final String FLOOD_PROTECTION = + "HW-Schutzanlagen"; + protected String name; protected File wstFile; @@ -53,15 +56,18 @@ protected List floodWater; + protected List floodProtection; + protected ImportWst wst; protected River peer; public ImportRiver() { - extraWsts = new ArrayList(); - fixations = new ArrayList(); - officialLines = new ArrayList(); - floodWater = new ArrayList(); + extraWsts = new ArrayList(); + fixations = new ArrayList(); + officialLines = new ArrayList(); + floodWater = new ArrayList(); + floodProtection = new ArrayList(); } public ImportRiver(String name, File wstFile, File bbInfoFile) { @@ -111,6 +117,44 @@ parseFixations(); parseOfficialLines(); parseFloodWater(); + parseFloodProtection(); + } + + public void parseFloodProtection() throws IOException { + log.info("Parse flood protection wst file"); + + File riverDir = wstFile.getParentFile().getParentFile(); + + File dir = FileTools.repair(new File(riverDir, FLOOD_PROTECTION)); + + if (!dir.isDirectory() || !dir.canRead()) { + log.info("no directory '" + dir + "' found"); + return; + } + + File [] files = dir.listFiles(); + + if (files == null) { + log.warn("cannot read '" + dir + "'"); + return; + } + + for (File file: files) { + if (!file.isFile() || !file.canRead()) { + continue; + } + String name = file.getName().toLowerCase(); + if (!(name.endsWith(".zus") || name.endsWith(".wst"))) { + continue; + } + log.info("found file '" + file.getName() + "'"); + WstParser wstParser = new WstParser(); + wstParser.parse(file); + ImportWst iw = wstParser.getWst(); + iw.setKind(5); + iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription()); + floodProtection.add(iw); + } } public void parseFloodWater() throws IOException { @@ -300,6 +344,7 @@ storeFixations(); storeOfficialLines(); storeFloodWater(); + storeFloodProtection(); } public void storeWst() { @@ -343,6 +388,15 @@ } } + public void storeFloodProtection() { + log.info("store flood protection wsts"); + River river = getPeer(); + for (ImportWst wst: floodProtection) { + log.debug("name: " + wst.getDescription()); + wst.storeDependencies(river); + } + } + public void storeAnnotations() { River river = getPeer(); for (ImportAnnotation annotation: annotations) {