changeset 2844:c4db0f75a94a

Prepared the importer to import MINFO specific waterlevel values and added a stub for a parser. flys-backend/trunk@4287 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 24 Apr 2012 11:16:06 +0000
parents 6a9f45697f81
children a65b5b0ade6f
files flys-backend/ChangeLog flys-backend/doc/schema/oracle-minfo.sql flys-backend/src/main/java/de/intevation/flys/importer/Config.java flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java
diffstat 5 files changed, 117 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Fri Apr 20 08:16:39 2012 +0000
+++ b/flys-backend/ChangeLog	Tue Apr 24 11:16:06 2012 +0000
@@ -1,3 +1,19 @@
+2012-04-24  Ingo Weinzierl <ingo@intevation.de>
+
+	* doc/schema/oracle-minfo.sql: Small type adaptions in the waterlevel_values
+	  relation.
+
+	* src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java:
+	  First stub of a parser for MINFO specific waterlevel values.
+
+	* src/main/java/de/intevation/flys/importer/Config.java: Added a new config
+	  option to skip parsing MINFO specifc waterlevel_values:
+
+	    -Dflys.backend.importer.skip.waterlevels=True
+
+	* src/main/java/de/intevation/flys/importer/ImportRiver.java: Added code
+	  path to start parsing and storing MINFO specific waterlevel values.
+
 2012-04-20  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/importer/ImportWaterlevelValue.java,
--- a/flys-backend/doc/schema/oracle-minfo.sql	Fri Apr 20 08:16:39 2012 +0000
+++ b/flys-backend/doc/schema/oracle-minfo.sql	Tue Apr 24 11:16:06 2012 +0000
@@ -309,8 +309,8 @@
 CREATE TABLE waterlevel_values(
     id                      NUMBER(38,0) NOT NULL,
     waterlevel_q_range_id   NUMBER(38,0) NOT NULL,
-    station                 NUMBER(38,0) NOT NULL,
-    w                       NUMBER(38,0) NOT NULL,
+    station                 NUMBER(38,3) NOT NULL,
+    w                       NUMBER(38,2) NOT NULL,
     PRIMARY KEY (id),
     CONSTRAINT fk_wv_waterlevel_q_range_id FOREIGN KEY (waterlevel_q_range_id) REFERENCES waterlevel_q_range(id)
 );
--- a/flys-backend/src/main/java/de/intevation/flys/importer/Config.java	Fri Apr 20 08:16:39 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/Config.java	Tue Apr 24 11:16:06 2012 +0000
@@ -59,6 +59,9 @@
     public static final String SKIP_SEDIMENT_YIELD =
         "flys.backend.importer.skip.sediment.yield";
 
+    public static final String SKIP_WATERLEVELS =
+        "flys.backend.importer.skip.waterlevels";
+
 
     public static final Config INSTANCE = new Config();
 
@@ -140,5 +143,9 @@
     public boolean skipSedimentYield() {
         return Boolean.getBoolean(SKIP_SEDIMENT_YIELD);
     }
+
+    public boolean skipWaterlevels() {
+        return Boolean.getBoolean(SKIP_WATERLEVELS);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Fri Apr 20 08:16:39 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Tue Apr 24 11:16:06 2012 +0000
@@ -36,6 +36,7 @@
 import de.intevation.flys.importer.parsers.SedimentDensityParser;
 import de.intevation.flys.importer.parsers.SedimentYieldParser;
 import de.intevation.flys.importer.parsers.WstParser;
+import de.intevation.flys.importer.parsers.WaterlevelParser;
 
 import org.hibernate.Session;
 import org.hibernate.Query;
@@ -88,6 +89,10 @@
 
     public static final String SEDIMENT_YIELD_EPOCH_DIR = "Epochen";
 
+    public static final String MINFO_FIXATIONS_DIR = "Fixierungsanalyse";
+
+    public static final String MINFO_WATERLEVELS_DIR = "Wasserspiegellagen";
+
 
     protected String name;
 
@@ -127,6 +132,8 @@
 
     protected List<ImportSedimentYield> sedimentYields;
 
+    protected List<ImportWaterlevel> waterlevels;
+
     protected ImportWst wst;
 
     protected ImportUnit wstUnit;
@@ -148,6 +155,7 @@
         flowVelocityModels        = new ArrayList<ImportFlowVelocityModel>();
         flowVelocityMeasurements  = new ArrayList<ImportFlowVelocityMeasurement>();
         sedimentYields            = new ArrayList<ImportSedimentYield>();
+        waterlevels               = new ArrayList<ImportWaterlevel>();
     }
 
     public ImportRiver(
@@ -216,6 +224,7 @@
         parseMorphologicalWidth();
         parseFlowVelocity();
         parseSedimentYield();
+        parseWaterlevels();
     }
 
     public void parseFloodProtection() throws IOException {
@@ -262,8 +271,6 @@
 
 
     public void parseBedHeight() throws IOException {
-        log.info("Parse bed height.");
-
         File minfoDir     = getMinfoDir();
         File bedHeightDir = new File(minfoDir, BED_HEIGHT_DIR);
         File singlesDir   = new File(bedHeightDir, BED_HEIGHT_SINGLE_DIR);
@@ -273,6 +280,7 @@
             log.info("skip parsing bed height single.");
         }
         else {
+            log.info("Parse bed height single.");
             parseBedHeightSingles(singlesDir);
         }
 
@@ -280,10 +288,9 @@
             log.info("skip parsing bed height epochs.");
         }
         else {
+            log.info("Parse bed height epochs.");
             parseBedHeightEpochs(epochDir);
         }
-
-        log.info("Finished parsing bed heights.");
     }
 
 
@@ -449,6 +456,35 @@
     }
 
 
+    protected void parseWaterlevels() throws IOException {
+        if (Config.INSTANCE.skipWaterlevels()) {
+            log.info("skip parsing waterlevels");
+            return;
+        }
+
+        File minfo  = getMinfoDir();
+        File fixDir = new File(minfo, MINFO_FIXATIONS_DIR);
+        File wspDir = new File(minfo, MINFO_WATERLEVELS_DIR);
+
+        File[] files = wspDir.listFiles();
+
+        if (files == null) {
+            log.warn("Cannot read directory '" + wspDir + "'");
+            return;
+        }
+
+        WaterlevelParser parser = new WaterlevelParser();
+
+        for (File file: files) {
+            parser.parse(file);
+        }
+
+        log.info("Parse waterlevels");
+
+        waterlevels = parser.getWaterlevels();
+    }
+
+
     protected void parseBedHeightSingles(File dir) throws IOException {
         log.debug("Parse bed height singles");
 
@@ -818,6 +854,7 @@
         storeMorphologicalWidth();
         storeFlowVelocity();
         storeSedimentYield();
+        storeWaterlevels();
     }
 
     public void storeWstUnit() {
@@ -1077,6 +1114,20 @@
         }
     }
 
+
+    public void storeWaterlevels() {
+        if (!Config.INSTANCE.skipWaterlevels()) {
+            log.info("store waterlevels");
+
+            River river = getPeer();
+
+            for (ImportWaterlevel waterlevel: waterlevels) {
+                waterlevel.storeDependencies(river);
+            }
+        }
+    }
+
+
     public void storeAnnotations() {
         if (!Config.INSTANCE.skipAnnotations()) {
             River river = getPeer();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java	Tue Apr 24 11:16:06 2012 +0000
@@ -0,0 +1,37 @@
+package de.intevation.flys.importer.parsers;
+
+import java.util.List;
+
+import de.intevation.flys.importer.ImportWaterlevel;
+
+
+public class WaterlevelParser extends LineParser {
+
+    private List<ImportWaterlevel> waterlevels;
+
+    public WaterlevelParser() {
+    }
+
+
+    public List<ImportWaterlevel> getWaterlevels() {
+        return waterlevels;
+    }
+
+
+    @Override
+    protected void reset() {
+
+    }
+
+
+    @Override
+    protected void finish() {
+
+    }
+
+    @Override
+    protected void handleLine(String line) {
+
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org