changeset 3756:912a398968b6

The factory for minfo bed quality calculation can load bedload and bed data from seddb now. flys-artifacts/trunk@5451 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 13 Sep 2012 10:49:49 +0000
parents 9c555ce5ca50
children e8a90a5ce624
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java
diffstat 2 files changed, 68 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Sep 13 10:34:51 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Sep 13 10:49:49 2012 +0000
@@ -1,4 +1,9 @@
-2012-09-12  Raimund Renkert <raimund.renkert@intevation.de>
+2012-09-13  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java:
+	  The factory can load bedload and bed data from seddb now.
+
+2012-09-13  Raimund Renkert <raimund.renkert@intevation.de>
 
 	Objects and factory for minfo bedquality calculation data.
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java	Thu Sep 13 10:34:51 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/QualityMeasurementFactory.java	Thu Sep 13 10:49:49 2012 +0000
@@ -13,7 +13,7 @@
 
 public class QualityMeasurementFactory {
 
-    private static final String SQL_MEASUREMENT = 
+    private static final String SQL_BED_MEASUREMENT = 
         "SELECT st.km    as km," +
         "       st.datum as date,"+
         "       sa.d10   as d10," +
@@ -41,6 +41,32 @@
         "      st.km BETWEEN :from - 0.001 AND :to + 0.001 AND" +
         "      st.datum BETWEEN :start AND :end";
 
+   private static final String SQL_BEDLOAD_MEASUREMENT = 
+        "SELECT m.km    as km," +
+        "       m.datum as date,"+
+        "       m.d10   as d10," +
+        "       m.d16   as d16," +
+        "       m.d20   as d20," +
+        "       m.d25   as d25," +
+        "       m.d30   as d30," +
+        "       m.d40   as d40," +
+        "       m.d50   as d50," +
+        "       m.d60   as d60," +
+        "       m.d70   as d70," +
+        "       m.d75   as d75," +
+        "       m.d80   as d80," +
+        "       m.d84   as d84," +
+        "       m.d90   as d90," +
+        "       m.dmin  as dmin," +
+        "       m.dmax  as dmax " +
+        "FROM messung m" +
+        "    JOIN station sn ON sn.stationid = m.stationid" +
+        "    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
     {
@@ -81,9 +107,10 @@
         double from,
         double to,
         Date start,
-        Date end
+        Date end,
+        String statement
     ) {
-        SQLQuery query = session.createSQLQuery(SQL_MEASUREMENT)
+        SQLQuery query = session.createSQLQuery(statement)
             .addScalar("km",    StandardBasicTypes.DOUBLE)
             .addScalar("date",  StandardBasicTypes.DATE)
             .addScalar("d10",  StandardBasicTypes.DOUBLE)
@@ -114,7 +141,7 @@
         return new QualityMeasurements(query.list());
     }
 
-    public static QualityMeasurements getMeasurements(
+    public static QualityMeasurements getBedMeasurements(
         String river,
         double from,
         double to,
@@ -123,7 +150,37 @@
     ) {
         Session session = SedDBSessionHolder.HOLDER.get();
         try {
-            return load(session, river, from, to, start, end);
+            return load(
+                session,
+                river,
+                from,
+                to,
+                start,
+                end,
+                SQL_BED_MEASUREMENT);
+        }
+        finally {
+            session.close();
+        }
+    }
+
+    public static QualityMeasurements getBedloadMeasurements(
+        String river,
+        double from,
+        double to,
+        Date start,
+        Date end
+    ){
+        Session session = SedDBSessionHolder.HOLDER.get();
+        try {
+            return load(
+                session,
+                river,
+                from,
+                to,
+                start,
+                end,
+                SQL_BEDLOAD_MEASUREMENT);
         }
         finally {
             session.close();

http://dive4elements.wald.intevation.org