changeset 6319:550cb41d37d9

issue1354: TimeIntervals in Waterlevels from csv files.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 12 Jun 2013 12:36:43 +0200
parents bc09f8fff694
children 6cdafb6feee1
files backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelParser.java
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelParser.java	Wed Jun 12 18:21:48 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelParser.java	Wed Jun 12 12:36:43 2013 +0200
@@ -20,6 +20,7 @@
 
 import org.apache.log4j.Logger;
 
+import org.dive4elements.river.importer.ImportTimeInterval;
 import org.dive4elements.river.importer.ImportUnit;
 
 import org.dive4elements.river.importer.ImportRange;
@@ -91,6 +92,22 @@
         column        = current.getColumn(0);
         column.setName(currentDescription);
         column.setDescription(currentDescription);
+
+        // Try to extract and set the TimeInterval.
+        Matcher m = WaterlevelDifferencesParser.YEARS_IN_COLUMN.matcher(currentDescription);
+
+        if (m.matches()) {
+            int startYear = Integer.parseInt(m.group(1));
+            int endYear   = Integer.parseInt(m.group(2));
+            ImportTimeInterval time = new ImportTimeInterval(
+                getStartDateFromYear(startYear),
+                getEndDateFromYear(endYear)
+            );
+            column.setTimeInterval(time);
+        } else {
+            log.debug("No time interval in column header found: " + currentDescription);
+        }
+
         current.setKind(7);
     }
 

http://dive4elements.wald.intevation.org