comparison backend/src/main/java/org/dive4elements/river/model/FlowVelocityModel.java @ 7371:6baaa700eada

Add getModelDescription to FlowVelocityModel.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 17 Oct 2013 08:29:46 +0200
parents dd8103e8ee5b
children 9d2e69f971f5
comparison
equal deleted inserted replaced
7370:4eccd72595ee 7371:6baaa700eada
34 @Table(name = "flow_velocity_model") 34 @Table(name = "flow_velocity_model")
35 public class FlowVelocityModel 35 public class FlowVelocityModel
36 implements Serializable 36 implements Serializable
37 { 37 {
38 private static Logger logger = Logger.getLogger(FlowVelocityModel.class); 38 private static Logger logger = Logger.getLogger(FlowVelocityModel.class);
39
40 39
41 private Integer id; 40 private Integer id;
42 41
43 private DischargeZone dischargeZone; 42 private DischargeZone dischargeZone;
44 43
109 query.setParameter("zone", zone); 108 query.setParameter("zone", zone);
110 109
111 return query.list(); 110 return query.list();
112 } 111 }
113 112
113
114 /** Get a Model by id. */
114 public static FlowVelocityModel getModel(int id) { 115 public static FlowVelocityModel getModel(int id) {
115 116
116 Session session = SessionHolder.HOLDER.get(); 117 Session session = SessionHolder.HOLDER.get();
117 118
118 Query query = session.createQuery( 119 Query query = session.createQuery(
120 121
121 query.setParameter("id", id); 122 query.setParameter("id", id);
122 123
123 return (FlowVelocityModel) query.list().get(0); 124 return (FlowVelocityModel) query.list().get(0);
124 } 125 }
126
127
128 /** Get description of a Model by id. */
129 public static String getModelDescription(int id) {
130
131 Session session = SessionHolder.HOLDER.get();
132
133 Query query = session.createQuery(
134 "from FlowVelocityModel where id=:id");
135
136 query.setParameter("id", id);
137
138 FlowVelocityModel model = (FlowVelocityModel) query.list().get(0);
139
140 return (model == null) ? null : model.getDescription();
141 }
125 } 142 }
126 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 143 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org