changeset 494:88d5b02ff0c1

Importer: Import the "HW-Schutzanlagen", too. flys-backend/trunk@1845 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 06 May 2011 15:15:04 +0000
parents b35c5dc0f8b7
children a92da0b3e8e7
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java
diffstat 2 files changed, 64 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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	<sascha.teichmann@intevation.de>
 
-   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	<sascha.teichmann@intevation.de>
+
+	Make import of historical discharge tables work.
 
 	* doc/schema/postgresql.sql: Added forgotten column 'description'.
 
--- 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<ImportWst> floodWater;
 
+    protected List<ImportWst> floodProtection;
+
     protected ImportWst wst;
 
     protected River peer;
 
     public ImportRiver() {
-        extraWsts     = new ArrayList<ImportWst>();
-        fixations     = new ArrayList<ImportWst>();
-        officialLines = new ArrayList<ImportWst>();
-        floodWater    = new ArrayList<ImportWst>();
+        extraWsts       = new ArrayList<ImportWst>();
+        fixations       = new ArrayList<ImportWst>();
+        officialLines   = new ArrayList<ImportWst>();
+        floodWater      = new ArrayList<ImportWst>();
+        floodProtection = new ArrayList<ImportWst>();
     }
 
     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) {

http://dive4elements.wald.intevation.org