[PATCH 3 of 3] issue1393/ImportRiver: Import official epochs from directory, minor refac

Wald Commits scm-commit at wald.intevation.org
Wed Jul 31 11:03:54 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1375262021 -7200
# Node ID 0baf7abffcc63587905bc88f498a6457207871b7
# Parent  796750499cd23e529aad92f6fa5fc879e5017381
issue1393/ImportRiver: Import official epochs from directory, minor refac.

diff -r 796750499cd2 -r 0baf7abffcc6 backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Wed Jul 31 11:12:53 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Wed Jul 31 11:13:41 2013 +0200
@@ -109,6 +109,8 @@
 
     public static final String SEDIMENT_YIELD_EPOCH_DIR = "Epochen";
 
+    public static final String SEDIMENT_YIELD_OFF_EPOCH_DIR = "amtliche Epochen";
+
     public static final String MINFO_FIXATIONS_DIR = "Fixierungsanalyse";
 
     public static final String MINFO_WATERLEVELS_DIR = "Wasserspiegellagen";
@@ -502,6 +504,22 @@
     }
 
 
+    private void parseSedimentYieldDir(
+        File[] files,
+        SedimentYieldParser parser
+    ) throws IOException {
+       for (File file: files) {
+           if (file.isDirectory()) {
+               for (File child: file.listFiles()) {
+                   parser.parse(child);
+               }
+           }
+           else {
+               parser.parse(file);
+           }
+       }
+    }
+
     protected void parseSedimentYield() throws IOException {
         if (Config.INSTANCE.skipSedimentYield()) {
             log.info("skip parsing sediment yield data");
@@ -513,11 +531,13 @@
         File minfoDir         = getMinfoDir();
         File sedimentYieldDir = new File(minfoDir, SEDIMENT_YIELD_DIR);
 
-        File singleDir = new File(sedimentYieldDir, SEDIMENT_YIELD_SINGLE_DIR);
-        File epochDir  = new File(sedimentYieldDir, SEDIMENT_YIELD_EPOCH_DIR);
+        File singleDir   = new File(sedimentYieldDir, SEDIMENT_YIELD_SINGLE_DIR);
+        File epochDir    = new File(sedimentYieldDir, SEDIMENT_YIELD_EPOCH_DIR);
+        File offEpochDir = new File(sedimentYieldDir, SEDIMENT_YIELD_OFF_EPOCH_DIR);
 
-        File[] singles = singleDir.listFiles();
-        File[] epochs  = epochDir.listFiles();
+        File[] singles   = singleDir.listFiles();
+        File[] epochs    = epochDir.listFiles();
+        File[] offEpochs = offEpochDir.listFiles();
 
         SedimentYieldParser parser = new SedimentYieldParser();
 
@@ -525,32 +545,21 @@
             log.warn("Cannot read directory '" + singleDir + "'");
         }
         else {
-            for (File file: singles) {
-                if (file.isDirectory()) {
-                    for (File child: file.listFiles()) {
-                        parser.parse(child);
-                    }
-                }
-                else {
-                    parser.parse(file);
-                }
-            }
+            parseSedimentYieldDir(singles, parser);
         }
 
         if (epochs == null || epochs.length == 0) {
             log.warn("Cannot read directory '" + epochDir + "'");
         }
         else {
-            for (File file: epochs) {
-                if (file.isDirectory()) {
-                    for (File child: file.listFiles()) {
-                        parser.parse(child);
-                    }
-                }
-                else {
-                    parser.parse(file);
-                }
-            }
+            parseSedimentYieldDir(epochs, parser);
+        }
+
+        if (offEpochs == null || offEpochs.length == 0) {
+            log.warn("Cannot read directory '" + offEpochDir + "'");
+        }
+        else {
+            parseSedimentYieldDir(offEpochs, parser);
         }
 
         sedimentYields = parser.getSedimentYields();


More information about the Dive4elements-commits mailing list