[PATCH 9 of 9] Add getModelDescription to FlowVelocityModel

Wald Commits scm-commit at wald.intevation.org
Thu Oct 17 08:51:35 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1381991386 -7200
# Node ID 6baaa700eada94627fb897a3a54efc9afefdd38b
# Parent  4eccd72595eee1c07dc4a9536361d76be3742fce
Add getModelDescription to FlowVelocityModel.

diff -r 4eccd72595ee -r 6baaa700eada backend/src/main/java/org/dive4elements/river/model/FlowVelocityModel.java
--- a/backend/src/main/java/org/dive4elements/river/model/FlowVelocityModel.java	Thu Oct 17 07:48:51 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/FlowVelocityModel.java	Thu Oct 17 08:29:46 2013 +0200
@@ -37,7 +37,6 @@
 {
     private static Logger logger = Logger.getLogger(FlowVelocityModel.class);
 
-
     private Integer id;
 
     private DischargeZone dischargeZone;
@@ -111,6 +110,8 @@
         return query.list();
     }
 
+
+    /** Get a Model by id. */
     public static FlowVelocityModel getModel(int id) {
 
         Session session = SessionHolder.HOLDER.get();
@@ -122,5 +123,21 @@
 
         return (FlowVelocityModel) query.list().get(0);
     }
+
+
+    /** Get description of a Model by id. */
+    public static String getModelDescription(int id) {
+
+        Session session = SessionHolder.HOLDER.get();
+
+        Query query = session.createQuery(
+            "from FlowVelocityModel where id=:id");
+
+        query.setParameter("id", id);
+
+        FlowVelocityModel model = (FlowVelocityModel) query.list().get(0);
+
+        return (model == null) ? null : model.getDescription();
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :


More information about the Dive4elements-commits mailing list