changeset 5542:f3b270e5462e

Wst Parser: Another attempt to fix the order of the Q ranges.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 03 Apr 2013 20:16:01 +0200
parents b09c095a0b7e
children 732a8bd44650
files flys-backend/src/main/java/de/intevation/flys/importer/ImportRange.java flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumnQRange.java flys-backend/src/main/java/de/intevation/flys/importer/ImportWstQRange.java flys-backend/src/main/java/de/intevation/flys/importer/parsers/WstParser.java
diffstat 6 files changed, 33 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRange.java	Wed Apr 03 17:59:11 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRange.java	Wed Apr 03 20:16:01 2013 +0200
@@ -40,6 +40,12 @@
         return a.compareTo(b);
     }
 
+    public void fixRangesOrder() {
+        if (compare(a, b) > 0) {
+            BigDecimal t = a; a = b; b = t;
+        }
+    }
+
     public int compareTo(ImportRange other) {
         int cmp = compare(a, other.a);
         if (cmp != 0) return cmp;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java	Wed Apr 03 17:59:11 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java	Wed Apr 03 20:16:01 2013 +0200
@@ -98,6 +98,12 @@
         session.flush();
     }
 
+    public void fixRangesOrder() {
+        for (ImportWstColumn column: columns) {
+            column.fixRangesOrder();
+        }
+    }
+
     /** Get corresponding mapped wst (from database). */
     public Wst getPeer(River river) {
         if (peer == null) {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java	Wed Apr 03 17:59:11 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java	Wed Apr 03 20:16:01 2013 +0200
@@ -150,5 +150,11 @@
         }
         return peer;
     }
+
+    public void fixRangesOrder() {
+        for (ImportWstColumnQRange wcqr: columnQRanges) {
+            wcqr.fixRangesOrder();
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumnQRange.java	Wed Apr 03 17:59:11 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumnQRange.java	Wed Apr 03 20:16:01 2013 +0200
@@ -44,6 +44,10 @@
         this.qRange = qRange;
     }
 
+    public void fixRangesOrder() {
+        qRange.fixRangesOrder();
+    }
+
     public WstColumnQRange getPeer(River river) {
         if (peer == null) {
             WstColumn c = wstColumn.getPeer(river);
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstQRange.java	Wed Apr 03 17:59:11 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstQRange.java	Wed Apr 03 20:16:01 2013 +0200
@@ -45,6 +45,10 @@
         this.q = q;
     }
 
+    public void fixRangesOrder() {
+        range.fixRangesOrder();
+    }
+
     public WstQRange getPeer(River river) {
         if (peer == null) {
             Range r = range.getPeer(river);
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WstParser.java	Wed Apr 03 17:59:11 2013 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WstParser.java	Wed Apr 03 20:16:01 2013 +0200
@@ -316,11 +316,13 @@
                     }
                 }
 
-            }
+            } // for all lines in WST file
 
             wst.setUnit(new ImportUnit(einheit));
 
             addInterval(minKm, maxKm, aktAbfluesse);
+
+            fixRangesOrder();
         }
         finally {
             if (in != null) {
@@ -329,6 +331,10 @@
         }
     }
 
+    protected void fixRangesOrder() {
+        wst.fixRangesOrder();
+    }
+
     protected void addValue(BigDecimal km, BigDecimal w, int index) {
         if (w != null) {
             ImportWstColumn column = wst.getColumn(index);
@@ -360,10 +366,6 @@
             return;
         }
 
-        if (to.compareTo(from) < 0) {
-            BigDecimal t = from; from = to; to = t;
-        }
-
         ImportRange range = new ImportRange(from, to);
 
         // little workaround to make the q ranges tightly fit.

http://dive4elements.wald.intevation.org