changeset 7185:963b8bd54a63

SedimentLoadFactory: Added method to quickly get the description of a given load.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 27 Sep 2013 14:36:05 +0200
parents 73d7886fa59e
children 644b2f461272
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java
diffstat 1 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Fri Sep 27 14:35:42 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Fri Sep 27 14:36:05 2013 +0200
@@ -54,6 +54,13 @@
         "       AND ti.stop_time IS NULL " +
         "       AND syv.station BETWEEN :startKm AND :endKm";
 
+    /** Query to get description of single sediment_yield. */
+    public static final String SQL_SELECT_SINGLE_BY_ID =
+        "SELECT DISTINCT " +
+        "       sy.description AS description " +
+        "   FROM     sediment_yield sy " +
+        "   WHERE   sy.id = :id ";
+
     /** Query to get description, name and time range for official
      * epoch-type sediment yields. */
     public static final String SQL_SELECT_OFFEPOCHS =
@@ -271,6 +278,26 @@
     }
 
     /**
+     * Get sediment load description.
+     * @param id the sediment yield by id.
+     * @return sediment yields description
+     */
+    public static String getSedimentYieldDescription(int id) {
+        log.debug("SedimentLoadFactory.getSedimentYieldDescription");
+
+        Session session = SessionHolder.HOLDER.get();
+        SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_BY_ID)
+                .addScalar("description", StandardBasicTypes.STRING);
+        sqlQuery.setDouble("id", id);
+
+        List<Object> results = sqlQuery.list();
+
+        return (String) results.get(0);
+
+    }
+
+
+    /**
      * Get sediment loads from db.
      * @param river the river
      * @param type the sediment load type (year or epoch)

http://dive4elements.wald.intevation.org