diff flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 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 71175502d868
children a65b5b0ade6f
line wrap: on
line diff
--- 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();

http://dive4elements.wald.intevation.org