[PATCH 2 of 7] SedimentLoadFactory: Added method to quickly get the description of a given load
Wald Commits
scm-commit at wald.intevation.org
Fri Sep 27 14:33:26 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1380285365 -7200
# Node ID 963b8bd54a638716b6503259dbb0c7024b3ffb54
# Parent 73d7886fa59e96ad4276aa7c8605a6328e87bca2
SedimentLoadFactory: Added method to quickly get the description of a given load.
diff -r 73d7886fa59e -r 963b8bd54a63 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java
--- 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)
More information about the Dive4elements-commits
mailing list