changeset 4724:c30152f77f77

ImportRiver: Refactoring, use description and year of da66parser.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 27 Dec 2012 16:14:41 +0100
parents 83304d3651ec
children b0adce0592c9
files flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java
diffstat 1 files changed, 25 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Thu Dec 27 16:14:15 2012 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Thu Dec 27 16:14:41 2012 +0100
@@ -887,6 +887,29 @@
     }
 
 
+    /** Add cross sections with description, years and lines to
+     * store. */
+    private void addCrossSections(CrossSectionParser parser) {
+        String  description = parser.getDescription();
+        Integer year        = parser.getYear();
+        ImportTimeInterval ti = year != null
+            ? new ImportTimeInterval(yearToDate(year))
+            : null;
+
+        List<ImportCrossSectionLine> lines =
+            new ArrayList<ImportCrossSectionLine>();
+
+        for (Map.Entry<Double, List<XY>> entry: parser.getData().entrySet()) {
+            Double   km     = entry.getKey();
+            List<XY> points = entry.getValue();
+            lines.add(new ImportCrossSectionLine(km, points));
+        }
+
+        crossSections.add(new ImportCrossSection(
+            ImportRiver.this, description, ti, lines));
+    }
+
+
     /** Create a DA66 Parser and parse the da66 files found. */
     // TODO this is a copy of parsePRFs, extract interfaces (e.g. CrossSectionParser).
     public void parseDA66s() {
@@ -920,24 +943,7 @@
             public void parsed(CrossSectionParser parser) {
                 log.debug("callback from DA66 parser");
 
-                // TODO populate with real-world data
-                String  description = "dummy";//parser.getDescription();
-                Integer year        = 2012;//parser.getYear();
-                ImportTimeInterval ti = year != null
-                    ? new ImportTimeInterval(yearToDate(year))
-                    : null;
-
-                List<ImportCrossSectionLine> lines =
-                    new ArrayList<ImportCrossSectionLine>();
-
-                for (Map.Entry<Double, List<XY>> entry: parser.getData().entrySet()) {
-                    Double   km     = entry.getKey();
-                    List<XY> points = entry.getValue();
-                    lines.add(new ImportCrossSectionLine(km, points));
-                }
-
-                crossSections.add(new ImportCrossSection(
-                    ImportRiver.this, description, ti, lines));
+                addCrossSections(parser);
             }
         });
     }
@@ -975,23 +981,7 @@
             public void parsed(CrossSectionParser parser) {
                 log.debug("callback from PRF parser");
 
-                String  description = parser.getDescription();
-                Integer year        = parser.getYear();
-                ImportTimeInterval ti = year != null
-                    ? new ImportTimeInterval(yearToDate(year))
-                    : null;
-
-                List<ImportCrossSectionLine> lines =
-                    new ArrayList<ImportCrossSectionLine>();
-
-                for (Map.Entry<Double, List<XY>> entry: parser.getData().entrySet()) {
-                    Double   km     = entry.getKey();
-                    List<XY> points = entry.getValue();
-                    lines.add(new ImportCrossSectionLine(km, points));
-                }
-
-                crossSections.add(new ImportCrossSection(
-                    ImportRiver.this, description, ti, lines));
+                addCrossSections(parser);
             }
         });
     }

http://dive4elements.wald.intevation.org