changeset 3758:75bc96dd9d82

Added depth parameter to bed quality data. flys-artifacts/trunk@5456 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 13 Sep 2012 13:43:00 +0000
parents e8a90a5ce624
children e54f8dc222cf
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurement.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java
diffstat 3 files changed, 101 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Sep 13 12:08:50 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Sep 13 13:43:00 2012 +0000
@@ -1,3 +1,9 @@
+2012-09-13  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurement.java:
+	  Added depth parameter to bed quality data.
+
 2012-09-13  Ingo Weinzierl <ingo@intevation.de>
 
 	* doc/conf/conf.xml: Registered new OutGenerators BedQualityGenerator and
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurement.java	Thu Sep 13 12:08:50 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurement.java	Thu Sep 13 13:43:00 2012 +0000
@@ -3,10 +3,13 @@
 import java.util.Date;
 import java.util.Map;
 
+
 public class QualityMeasurement {
 
-    private double km;
-    private Date date;
+    private double              km;
+    private Date                date;
+    private double              depth1;
+    private double              depth2;
     private Map<String, Double> charDiameter;
 
     public QualityMeasurement() {
@@ -16,10 +19,13 @@
     public QualityMeasurement(
         double km,
         Date date,
-        Map<String, Double> diameter)
-    {
+        double depth1,
+        double depth2,
+        Map<String, Double> diameter) {
         this.setKm(km);
         this.setDate(date);
+        this.depth1 = depth1;
+        this.depth2 = depth2;
         this.setDiameter(diameter);
     }
 
@@ -54,4 +60,21 @@
     public void setDiameter(String key, double value) {
         charDiameter.put(key, value);
     }
+
+    public double getDepth1() {
+        return depth1;
+    }
+
+    public void setDepth1(double depth1) {
+        this.depth1 = depth1;
+    }
+
+    public double getDepth2() {
+        return depth2;
+    }
+
+    public void setDepth2(double depth2) {
+        this.depth2 = depth2;
+    }
+
 }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java	Thu Sep 13 12:08:50 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java	Thu Sep 13 13:43:00 2012 +0000
@@ -11,39 +11,42 @@
 
 import de.intevation.flys.backend.SedDBSessionHolder;
 
+
 public class QualityMeasurementFactory {
 
-    private static final String SQL_BED_MEASUREMENT = 
-        "SELECT st.km    as km," +
-        "       st.datum as date,"+
-        "       sa.d10   as d10," +
-        "       sa.d16   as d16," +
-        "       sa.d20   as d20," +
-        "       sa.d25   as d25," +
-        "       sa.d30   as d30," +
-        "       sa.d40   as d40," +
-        "       sa.d50   as d50," +
-        "       sa.d60   as d60," +
-        "       sa.d70   as d70," +
-        "       sa.d75   as d75," +
-        "       sa.d80   as d80," +
-        "       sa.d84   as d84," +
-        "       sa.d90   as d90," +
-        "       sa.dmin  as dmin," +
-        "       sa.dmax  as dmax " +
+    private static final String SQL_BED_MEASUREMENT =
+        "SELECT st.km       as km," +
+        "       st.datum    as date," +
+        "       sp.tiefevon as depth1" +
+        "       sp.tiefebis as depth2" +
+        "       sa.d10      as d10," +
+        "       sa.d16      as d16," +
+        "       sa.d20      as d20," +
+        "       sa.d25      as d25," +
+        "       sa.d30      as d30," +
+        "       sa.d40      as d40," +
+        "       sa.d50      as d50," +
+        "       sa.d60      as d60," +
+        "       sa.d70      as d70," +
+        "       sa.d75      as d75," +
+        "       sa.d80      as d80," +
+        "       sa.d84      as d84," +
+        "       sa.d90      as d90," +
+        "       sa.dmin     as dmin," +
+        "       sa.dmax     as dmax " +
         "FROM sohltest st" +
         "    JOIN station sn ON sn.stationid = st.stationid" +
         "    JOIN gewaesser gw ON gw.gewaesserid = sn.gewaesserid" +
         "    JOIN sohlprobe sp ON sp.sohltestid = st.sohltestid" +
-        "    JOIN siebanalyse sa ON sa.sohlprobeid = sp.sohlprobeid" +
+        "    JOIN siebanalyse sa ON sa.sohlprobeid = sp.sohlprobeid " +
         "WHERE gw.name = :name AND " +
         "      st.km IS NOT NULL AND " +
         "      st.km BETWEEN :from - 0.001 AND :to + 0.001 AND" +
         "      st.datum BETWEEN :start AND :end";
 
-   private static final String SQL_BEDLOAD_MEASUREMENT = 
+    private static final String SQL_BEDLOAD_MEASUREMENT =
         "SELECT m.km    as km," +
-        "       m.datum as date,"+
+        "       m.datum as date," +
         "       m.d10   as d10," +
         "       m.d16   as d16," +
         "       m.d20   as d20," +
@@ -61,40 +64,47 @@
         "       m.dmax  as dmax " +
         "FROM messung m" +
         "    JOIN station sn ON sn.stationid = m.stationid" +
-        "    JOIN gewaesser gw ON gw.gewaesserid = sn.gewaesserid" +
+        "    JOIN gewaesser gw ON gw.gewaesserid = sn.gewaesserid " +
         "WHERE gw.name = :name AND " +
         "      m.km IS NOT NULL AND " +
         "      m.km BETWEEN :from - 0.001 AND :to + 0.001 AND" +
         "      m.datum BETWEEN :start AND :end";
 
     public static final class QualityMeasurementResultTransformer
-    extends                   BasicTransformerAdapter
-    {
-        public static QualityMeasurementResultTransformer INSTANCE =
-            new QualityMeasurementResultTransformer();
+    extends BasicTransformerAdapter {
+
+        public static QualityMeasurementResultTransformer INSTANCE = new QualityMeasurementResultTransformer();
 
         public QualityMeasurementResultTransformer() {
         }
 
         @Override
-        public Object transformTuple(Object [] tuple, String [] aliases) {
+        public Object transformTuple(Object[] tuple, String[] aliases) {
             Map<String, Double> map = new HashMap<String, Double>();
             double km = 0;
             Date d = null;
+            double depth1 = 0;
+            double depth2 = 0;
             for (int i = 0; i < tuple.length; ++i) {
                 if (tuple[i] != null) {
                     if (aliases[i].equals("km")) {
-                        km = ((Number)tuple[i]).doubleValue();
+                        km = ((Number) tuple[i]).doubleValue();
                     }
                     else if (aliases[i].equals("date")) {
-                        d = (Date)tuple[i];
+                        d = (Date) tuple[i];
+                    }
+                    else if (aliases[i].equals("depth1")) {
+                        depth1 = ((Number) tuple[i]).doubleValue();
+                    }
+                    else if (aliases[i].equals("depth2")) {
+                        depth2 = ((Number) tuple[i]).doubleValue();
                     }
                     else {
-                        map.put(aliases[i], (Double)tuple[i]);
+                        map.put(aliases[i], (Double) tuple[i]);
                     }
                 }
             }
-            return new QualityMeasurement(km, d, map);
+            return new QualityMeasurement(km, d, depth1, depth2, map);
         }
     } // class BasicTransformerAdapter
 
@@ -111,27 +121,32 @@
         String statement
     ) {
         SQLQuery query = session.createSQLQuery(statement)
-            .addScalar("km",    StandardBasicTypes.DOUBLE)
-            .addScalar("date",  StandardBasicTypes.DATE)
-            .addScalar("d10",  StandardBasicTypes.DOUBLE)
-            .addScalar("d16",  StandardBasicTypes.DOUBLE)
-            .addScalar("d20",  StandardBasicTypes.DOUBLE)
-            .addScalar("d25",  StandardBasicTypes.DOUBLE)
-            .addScalar("d30",  StandardBasicTypes.DOUBLE)
-            .addScalar("d40",  StandardBasicTypes.DOUBLE)
-            .addScalar("d50",  StandardBasicTypes.DOUBLE)
-            .addScalar("d60",  StandardBasicTypes.DOUBLE)
-            .addScalar("d70",  StandardBasicTypes.DOUBLE)
-            .addScalar("d75",  StandardBasicTypes.DOUBLE)
-            .addScalar("d80",  StandardBasicTypes.DOUBLE)
-            .addScalar("d84",  StandardBasicTypes.DOUBLE)
-            .addScalar("d90",  StandardBasicTypes.DOUBLE)
-            .addScalar("dmin",  StandardBasicTypes.DOUBLE)
-            .addScalar("dmax",  StandardBasicTypes.DOUBLE);
+            .addScalar("km", StandardBasicTypes.DOUBLE)
+            .addScalar("date", StandardBasicTypes.DATE)
+            .addScalar("d10", StandardBasicTypes.DOUBLE)
+            .addScalar("d16", StandardBasicTypes.DOUBLE)
+            .addScalar("d20", StandardBasicTypes.DOUBLE)
+            .addScalar("d25", StandardBasicTypes.DOUBLE)
+            .addScalar("d30", StandardBasicTypes.DOUBLE)
+            .addScalar("d40", StandardBasicTypes.DOUBLE)
+            .addScalar("d50", StandardBasicTypes.DOUBLE)
+            .addScalar("d60", StandardBasicTypes.DOUBLE)
+            .addScalar("d70", StandardBasicTypes.DOUBLE)
+            .addScalar("d75", StandardBasicTypes.DOUBLE)
+            .addScalar("d80", StandardBasicTypes.DOUBLE)
+            .addScalar("d84", StandardBasicTypes.DOUBLE)
+            .addScalar("d90", StandardBasicTypes.DOUBLE)
+            .addScalar("dmin", StandardBasicTypes.DOUBLE)
+            .addScalar("dmax", StandardBasicTypes.DOUBLE);
+
+        if (statement.equals(SQL_BED_MEASUREMENT)) {
+            query.addScalar("depth1", StandardBasicTypes.DOUBLE);
+            query.addScalar("depth2", StandardBasicTypes.DOUBLE);
+        }
 
         query.setString("name", river);
         query.setDouble("from", from);
-        query.setDouble("to", to); 
+        query.setDouble("to", to);
         query.setDate("start", start);
         query.setDate("end", end);
 
@@ -146,18 +161,11 @@
         double from,
         double to,
         Date start,
-        Date end
-    ) {
+        Date end) {
         Session session = SedDBSessionHolder.HOLDER.get();
         try {
-            return load(
-                session,
-                river,
-                from,
-                to,
-                start,
-                end,
-                SQL_BED_MEASUREMENT);
+            return load(session, river, from, to, start, end,
+            SQL_BED_MEASUREMENT);
         }
         finally {
             session.close();
@@ -170,7 +178,7 @@
         double to,
         Date start,
         Date end
-    ){
+    ) {
         Session session = SedDBSessionHolder.HOLDER.get();
         try {
             return load(

http://dive4elements.wald.intevation.org