[Dive4elements-commits] [PATCH 08 of 12] Waterl.Diff.Parser issue1354: Extract years from name, to later set timeintervals

Wald Commits scm-commit at wald.intevation.org
Wed Jun 12 11:51:17 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1371028836 -7200
# Node ID 69bc52b0219d123cbb7019ed1b952c4c186caf63
# Parent  6c0b0c6dbb762b2a6b6d5ad9698e9b9da7f3dd21
Waterl.Diff.Parser issue1354: Extract years from name, to later set timeintervals.

diff -r 6c0b0c6dbb76 -r 69bc52b0219d backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelDifferencesParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelDifferencesParser.java	Wed Jun 12 11:18:47 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelDifferencesParser.java	Wed Jun 12 11:20:36 2013 +0200
@@ -40,6 +40,9 @@
     public static final Pattern META_UNIT =
         Pattern.compile("^Einheit: \\[(.*)\\].*");
 
+    public static final Pattern YEARS_IN_COLUMN =
+        Pattern.compile(".*(\\d{4})-(\\d{4})$");
+
     /** List of parsed differences as ImportWst s. */
     private List<ImportWst> differences;
 
@@ -163,6 +166,16 @@
             log.debug("Create new column '" + name + "'");
             current.getColumn(i).setName(name);
             current.getColumn(i).setDescription(name);
+
+            Matcher m = YEARS_IN_COLUMN.matcher(name);
+
+            if (m.matches()) {
+                String startYear = m.group(1);
+                String endYear = m.group(2);
+                // TODO create and set ImportTimeInterval
+            } else {
+                log.debug("No time interval in column header found: " + name);
+            }
         }
     }
 


More information about the Dive4elements-commits mailing list