changeset 8665:8fbc0649da13

Move static measurement types to their natural home.
author Tom Gottfried <tom@intevation.de>
date Wed, 08 Apr 2015 14:47:30 +0200
parents b9e5fa7f7a28
children 1a4ad0d4231a
files backend/src/main/java/org/dive4elements/river/importer/parsers/MeasurementStationsParser.java backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentLoadParser.java backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java
diffstat 3 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/MeasurementStationsParser.java	Tue Apr 07 16:35:11 2015 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/MeasurementStationsParser.java	Wed Apr 08 14:47:30 2015 +0200
@@ -16,6 +16,8 @@
 
 import org.apache.log4j.Logger;
 
+import org.dive4elements.river.model.MeasurementStation;
+
 import org.dive4elements.river.importer.ImportMeasurementStation;
 import org.dive4elements.river.importer.ImportRange;
 import org.dive4elements.river.importer.ImportTimeInterval;
@@ -36,9 +38,6 @@
 
     public static final int MAX_COMMENT_LENGTH = 512;
 
-    public static final String MEASUREMENT_TYPE_BEDLOAD = "Geschiebe";
-    public static final String MEASUREMENT_TYPE_SUSP = "Schwebstoff";
-
     private static final Logger log = Logger
         .getLogger(MeasurementStationsParser.class);
 
@@ -144,8 +143,8 @@
     protected String getMeasurementType(String[] cols, int lineNum)
         throws MeasurementStationParserException {
         String mtype = cols[2].trim();
-        if (!(MEASUREMENT_TYPE_BEDLOAD.equals(mtype) ||
-                MEASUREMENT_TYPE_SUSP.equals(mtype))) {
+        if (!(MeasurementStation.MEASUREMENT_TYPE_BEDLOAD.equals(mtype) ||
+                MeasurementStation.MEASUREMENT_TYPE_SUSP.equals(mtype))) {
             throw new MeasurementStationParserException(
                 "invalid measurement type in line " + lineNum);
         }
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentLoadParser.java	Tue Apr 07 16:35:11 2015 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentLoadParser.java	Wed Apr 08 14:47:30 2015 +0200
@@ -22,9 +22,6 @@
 import org.dive4elements.river.model.River;
 import org.dive4elements.river.model.MeasurementStation;
 
-import static org.dive4elements.river.importer.parsers.MeasurementStationsParser.MEASUREMENT_TYPE_BEDLOAD;
-import static org.dive4elements.river.importer.parsers.MeasurementStationsParser.MEASUREMENT_TYPE_SUSP;
-
 /** Parses sediment load longitudinal section files. */
 public class SedimentLoadParser extends AbstractSedimentLoadParser {
     private static final Logger log =
@@ -130,13 +127,15 @@
                         return;
                     }
                     if (gfn.equals(GRAINFRACTION_NAME_SUSP) &&
-                        m.getMeasurementType().equals(MEASUREMENT_TYPE_SUSP)) {
+                        m.getMeasurementType().equals(
+                            MeasurementStation.MEASUREMENT_TYPE_SUSP)) {
                         // susp. sediment can only be at respective stations
                         initializeSedimentLoadValues(vals, m);
                         return;
                     }
                     if (!gfn.equals(GRAINFRACTION_NAME_SUSP) &&
-                        m.getMeasurementType().equals(MEASUREMENT_TYPE_BEDLOAD)) {
+                        m.getMeasurementType().equals(
+                            MeasurementStation.MEASUREMENT_TYPE_BEDLOAD)) {
                         /** anything but total load and susp. sediment
                             can only be at bed load measurement stations */
                         initializeSedimentLoadValues(vals, m);
--- a/backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java	Tue Apr 07 16:35:11 2015 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java	Wed Apr 08 14:47:30 2015 +0200
@@ -50,12 +50,17 @@
 
     private TimeInterval observationTimerange;
 
+    public static final String MEASUREMENT_TYPE_BEDLOAD = "Geschiebe";
+    public static final String MEASUREMENT_TYPE_SUSP = "Schwebstoff";
+
     public static final class MeasurementStationComparator
         implements Comparator<MeasurementStation> {
 
         public MeasurementStationComparator() {
         }
 
+        /* Compare MeasurementStations by km and consider MeasurementStations
+           of type "Geschiebe" as smaller if at same km. */
         @Override
         public int compare(MeasurementStation m1, MeasurementStation m2)
             throws IllegalArgumentException {
@@ -80,7 +85,9 @@
                         "Two stations of same type at same km");
                 }
 
-                return m1.getMeasurementType().equals("Geschiebe") ? -1 : +1;
+                return m1.getMeasurementType().equals(MEASUREMENT_TYPE_BEDLOAD)
+                    ? -1
+                    : +1;
             }
             return cmpStations;
         }

http://dive4elements.wald.intevation.org