changeset 4174:eaf83d4ae6b1

Sorted gauges for reference gauge selection in historical discharge calculation based on their name. Now, Gauge implements the Java Comparable interface and takes its name into account.
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 18 Oct 2012 13:12:24 +0200
parents 7d4480c0e68e
children f03774ed984e
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceGaugeState.java flys-backend/src/main/java/de/intevation/flys/model/Gauge.java
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceGaugeState.java	Thu Oct 18 12:13:48 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceGaugeState.java	Thu Oct 18 13:12:24 2012 +0200
@@ -1,5 +1,6 @@
 package de.intevation.flys.artifacts.states;
 
+import java.util.Collections;
 import java.util.List;
 
 import org.w3c.dom.Element;
@@ -33,6 +34,7 @@
     {
         River       river   = FLYSUtils.getRiver((FLYSArtifact) artifact);
         List<Gauge> gauges  = river.getGauges();
+        Collections.sort(gauges);
 
         int num = gauges != null ? gauges.size() : 0;
 
--- a/flys-backend/src/main/java/de/intevation/flys/model/Gauge.java	Thu Oct 18 12:13:48 2012 +0200
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Gauge.java	Thu Oct 18 13:12:24 2012 +0200
@@ -25,7 +25,7 @@
 @Entity
 @Table(name = "gauges")
 public class Gauge
-implements   Serializable
+implements   Serializable, Comparable<Gauge>
 {
     public static final int DEFAULT_SCALE = 100;
 
@@ -325,5 +325,10 @@
 
         return new MinMaxWQ(minw, maxw, minq, maxq);
     }
+
+    @Override
+    public int compareTo(Gauge o) {
+        return getName().compareTo(o.getName());
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org