[Dive4elements-commits] [PATCH 06 of 13] Fixed SQL statements and parameters

Wald Commits scm-commit at wald.intevation.org
Wed Nov 14 17:26:32 CET 2012


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1352909211 -3600
# Node ID a5e4fae31089cf7e942ab24de498fe8bb38a533c
# Parent  de4832ffde2a76b2a35db52235de3ea3a96bfc6e
Fixed SQL statements and parameters.

diff -r de4832ffde2a -r a5e4fae31089 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFactory.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFactory.java	Wed Nov 14 17:04:01 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFactory.java	Wed Nov 14 17:06:51 2012 +0100
@@ -74,7 +74,8 @@
     public static final String SQL_SELECT_EPOCHS_DATA =
         "SELECT" +
         "       sy.description AS description, " +
-        "       ti.start_time AS year, " +
+        "       ti.start_time AS startYear, " +
+        "       ti.stop_time AS endYear, " +
         "       syv.value AS load, " +
         "       syv.station AS km " +
         "   FROM     sediment_yield sy" +
@@ -195,7 +196,6 @@
         Session session = SessionHolder.HOLDER.get();
         SQLQuery sqlQuery = null;
 
-
         if (type.equals("single")) {
             sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLES)
                 .addScalar("description", StandardBasicTypes.STRING)
@@ -254,7 +254,6 @@
         int eyear
     ) {
         log.debug("SedimentLoadFactory.getSedimentLoadWithDataUncached");
-
         Session session = SessionHolder.HOLDER.get();
         SQLQuery sqlQuery = null;
 
@@ -289,6 +288,7 @@
             getValues("suspended_sediment", sqlQuery, load);
             getValues("susp_sand_bed", sqlQuery, load);
             getValues("susp_sand", sqlQuery, load);
+ 
             return load;
         }
         else if (type.equals("off_epoch")) {
@@ -297,16 +297,17 @@
             Calendar toEnd = Calendar.getInstance();
             toEnd.set(eyear, 12, 31);
 
-            sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCHS)
+            sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCHS_DATA)
                 .addScalar("description", StandardBasicTypes.STRING)
-                .addScalar("start_time", StandardBasicTypes.DATE)
-                .addScalar("stop_time", StandardBasicTypes.DATE)
-                .addScalar("load", StandardBasicTypes.DOUBLE);
+                .addScalar("startYear", StandardBasicTypes.DATE)
+                .addScalar("stopYear", StandardBasicTypes.DATE)
+                .addScalar("load", StandardBasicTypes.DOUBLE)
+                .addScalar("km", StandardBasicTypes.DOUBLE);
             sqlQuery.setString("name", river);
             sqlQuery.setDouble("startKm", startKm);
             sqlQuery.setDouble("endKm", endKm);
             sqlQuery.setDate("sbegin", start.getTime());
-            sqlQuery.setDate("sbegin", end.getTime());
+            sqlQuery.setDate("send", end.getTime());
             sqlQuery.setDate("ebegin",toStart.getTime());
             sqlQuery.setDate("eend", toEnd.getTime());
             sqlQuery.setString("grain", "total");
@@ -365,7 +366,7 @@
             else if (fraction.equals("suspended_sediment")) {
                 load.setSuspSediment(km, v);
             }
-            else if (fraction.equals("sups_sand")) {
+            else if (fraction.equals("susp_sand")) {
                 load.setSuspSand(km, v);
             }
             else if (fraction.equals("susp_sand_bed")) {


More information about the Dive4elements-commits mailing list