diff backend/src/main/java/org/dive4elements/river/importer/parsers/AbstractSedimentLoadParser.java @ 8059:bde5f5ec7c72

SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
author Tom Gottfried <tom@intevation.de>
date Fri, 18 Jul 2014 18:01:49 +0200
parents d86cc6a17b7a
children 3ae11daff343
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/AbstractSedimentLoadParser.java	Fri Jul 18 17:43:27 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/AbstractSedimentLoadParser.java	Fri Jul 18 18:01:49 2014 +0200
@@ -52,6 +52,9 @@
     public static final Pattern META_FRACTION_NAME =
         Pattern.compile("^Fraktionsname: (.*)");
 
+    public static final Pattern META_SQ_TIMEINTERVAL =
+        Pattern.compile("^S-Q-Beziehung: (.*)");
+
     public static final Pattern META_COLUMN_NAMES =
         Pattern.compile("^Fluss-km.*");
 
@@ -71,6 +74,8 @@
 
     protected ImportGrainFraction grainFraction;
 
+    protected ImportTimeInterval sqTimeInterval;
+
     protected String description;
 
     protected String[] columnNames;
@@ -164,6 +169,41 @@
     }
 
 
+    public boolean handleMetaSQTimeInterval(String line) {
+        Matcher m = META_SQ_TIMEINTERVAL.matcher(line);
+
+        if (m.matches()) {
+            String interval = m.group(1);
+
+            try {
+                Matcher a = TIMEINTERVAL_EPOCH.matcher(interval);
+                if (a.matches()) {
+                    int yearA = nf.parse(a.group(1)).intValue();
+                    int yearB = nf.parse(a.group(2)).intValue();
+
+                    sqTimeInterval = new ImportTimeInterval(
+                        DateUtil.getStartDateFromYear(yearA),
+                        DateUtil.getEndDateFromYear(yearB)
+                    );
+                }
+                else {
+                    log.warn("ASLP: Unknown SQ-time string: '" + interval +
+                        "'. Ignored.");
+                }
+            }
+            catch (ParseException pe) {
+                log.error("ASLP: Could not parse SQ-time string: '" +
+                    interval + "'. Ignored.", pe);
+            }
+
+            return true;
+
+        }
+
+        return false;
+    }
+
+
     public boolean handleColumnNames(String line) throws LineParserException {
         Matcher m = META_COLUMN_NAMES.matcher(line);
 

http://dive4elements.wald.intevation.org