changeset 6724:0baf7abffcc6

issue1393/ImportRiver: Import official epochs from directory, minor refac.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 31 Jul 2013 11:13:41 +0200
parents 796750499cd2
children 7ea933f9c6ea
files backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java
diffstat 1 files changed, 33 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- 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();

http://dive4elements.wald.intevation.org