changeset 4779:18908a3cbb3a

ImportRiver: Use callback (refactoring), resolving TODOs.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 08 Jan 2013 11:59:01 +0100
parents a70de5298248
children 562f631aab86
files flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java
diffstat 1 files changed, 9 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Tue Jan 08 11:57:03 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Tue Jan 08 11:59:01 2013 +0100
@@ -961,28 +961,9 @@
             .getParentFile()  // Hydrologie
             .getParentFile(); // <river>
 
-        // TODO this can probably be further merged with implementation for PRF parser.
-        parser.parseW80s(riverDir, new CrossSectionParser.Callback() {
-
-            Set<HashedFile> w80s = new HashSet<HashedFile>();
-
-            @Override
-            public boolean accept(File file) {
-                HashedFile hf = new HashedFile(file);
-                boolean success = w80s.add(hf);
-                if (!success) {
-                    log.warn("W80 file '" + file + "' seems to be a duplicate.");
-                }
-                return success;
-            }
-
-            @Override
-            public void parsed(CrossSectionParser parser) {
-                log.debug("callback from W80 parser");
-
-                addCrossSections(parser);
-            }
-        });
+        ImportRiverCrossSectionParserCallback w80Callback =
+            new ImportRiverCrossSectionParserCallback("w80");
+        parser.parseW80s(riverDir, w80Callback);
     }
 
     public void parseDA50s() {
@@ -1008,28 +989,9 @@
             .getParentFile()  // Hydrologie
             .getParentFile(); // <river>
 
-        // TODO this can probably be further merged with implementation for PRF parser.
-        parser.parseDA66s(riverDir, new CrossSectionParser.Callback() {
-
-            Set<HashedFile> da66s = new HashSet<HashedFile>();
-
-            @Override
-            public boolean accept(File file) {
-                HashedFile hf = new HashedFile(file);
-                boolean success = da66s.add(hf);
-                if (!success) {
-                    log.warn("DA66 file '" + file + "' seems to be a duplicate.");
-                }
-                return success;
-            }
-
-            @Override
-            public void parsed(CrossSectionParser parser) {
-                log.debug("callback from DA66 parser");
-
-                addCrossSections(parser);
-            }
-        });
+        ImportRiverCrossSectionParserCallback da66Callback =
+            new ImportRiverCrossSectionParserCallback("da66");
+        parser.parseDA66s(riverDir, da66Callback);
     }
 
     /** Create a PRFParser and let it parse the prf files found. */
@@ -1046,28 +1008,9 @@
             .getParentFile()  // Hydrologie
             .getParentFile(); // <river>
 
-        parser.parsePRFs(riverDir, new PRFParser.Callback() {
-
-            Set<HashedFile> prfs = new HashSet<HashedFile>();
-
-            // TODO merge Callback implementation with DA66 one.
-            @Override
-            public boolean accept(File file) {
-                HashedFile hf = new HashedFile(file);
-                boolean success = prfs.add(hf);
-                if (!success) {
-                    log.warn("PRF file '" + file + "' seems to be a duplicate.");
-                }
-                return success;
-            }
-
-            @Override
-            public void parsed(CrossSectionParser parser) {
-                log.debug("callback from PRF parser");
-
-                addCrossSections(parser);
-            }
-        });
+        ImportRiverCrossSectionParserCallback prfCallback =
+            new ImportRiverCrossSectionParserCallback("prf");
+        parser.parsePRFs(riverDir, prfCallback);
     }
 
     public static Date yearToDate(int year) {

http://dive4elements.wald.intevation.org