changeset 482:3a99d0295006

Importer: Support parsing "zusaetzliche Laengsschnitte". flys-backend/trunk@1801 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 03 May 2011 11:32:11 +0000
parents 73052199f9f6
children f1fd9cab6a07
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java
diffstat 3 files changed, 75 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Mon May 02 15:58:58 2011 +0000
+++ b/flys-backend/ChangeLog	Tue May 03 11:32:11 2011 +0000
@@ -1,3 +1,11 @@
+2011-05-03	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/importer/ImportRiver.java:
+	  Parse the "zusaetzliche Laengsschnitte", too.
+
+	* src/main/java/de/intevation/flys/importer/ImportWst.java:
+	  Add getter/setter for column 'kind'.
+
 2011-05-02	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/importer/WstParser.java:
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Mon May 02 15:58:58 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Tue May 03 11:32:11 2011 +0000
@@ -1,6 +1,7 @@
 package de.intevation.flys.importer;
 
 import java.util.List;
+import java.util.ArrayList;
 
 import java.io.File;
 import java.io.IOException;
@@ -20,6 +21,9 @@
 
     public static final String PEGEL_GLT = "PEGEL.GLT";
 
+    public static final String EXTRA_LONGITUDINALS =
+        "Zus.L\u00e4ngsschnitte";
+
     protected String name;
 
     protected File   wstFile;
@@ -30,14 +34,18 @@
 
     protected List<ImportAnnotation> annotations;
 
+    protected List<ImportWst> extraWsts;
+
     protected ImportWst wst;
 
     protected River peer;
 
     public ImportRiver() {
+        extraWsts = new ArrayList<ImportWst>();
     }
 
     public ImportRiver(String name, File wstFile, File bbInfoFile) {
+        this();
         this.name       = name;
         this.wstFile    = wstFile;
         this.bbInfoFile = bbInfoFile;
@@ -79,6 +87,46 @@
         parseGauges();
         parseAnnotations();
         parseWst();
+        parseExtraWsts();
+    }
+
+    public void parseExtraWsts() throws IOException {
+        log.info("Parse extra longitudinal wst files");
+
+        File riverDir = wstFile.getParentFile().getParentFile();
+
+        File extraDir = FileTools.repair(
+            new File(riverDir, EXTRA_LONGITUDINALS));
+
+        if (!extraDir.isDirectory() || !extraDir.canRead()) {
+            log.info("no extra longitudinal wst file directory found");
+            return;
+        }
+
+        File [] files = extraDir.listFiles();
+
+        if (files == null) {
+            log.warn("cannot read extra longitudinal wst file directory");
+            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.debug("Found WST file: " + file);
+
+            WstParser wstParser = new WstParser();
+            wstParser.parse(file);
+            ImportWst iw = wstParser.getWst();
+            iw.setKind(1);
+            extraWsts.add(iw);
+        }
+
     }
 
     public void parseWst() throws IOException {
@@ -118,6 +166,7 @@
         storeAnnotations();
         storeGauges();
         storeWst();
+        storeExtraWsts();
     }
 
     public void storeWst() {
@@ -125,6 +174,15 @@
         wst.storeDependencies(river);
     }
 
+    public void storeExtraWsts() {
+        log.info("store extra wsts");
+        River river = getPeer();
+        for (ImportWst wst: extraWsts) {
+            log.debug("name: " + wst.getDescription());
+            wst.storeDependencies(river);
+        }
+    }
+
     public void storeAnnotations() {
         River river = getPeer();
         for (ImportAnnotation annotation: annotations) {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java	Mon May 02 15:58:58 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java	Tue May 03 11:32:11 2011 +0000
@@ -49,6 +49,15 @@
         return description;
     }
 
+    public Integer getKind() {
+        return kind;
+    }
+
+    public void setKind(Integer kind) {
+        this.kind = kind;
+    }
+
+
     public void setDescription(String description) {
         this.description = description;
     }

http://dive4elements.wald.intevation.org