comparison backend/src/main/java/org/dive4elements/river/model/sinfo/InfrastructureValue.java @ 9614:d889ffe2fb05

Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
author mschaefer
date Wed, 09 Oct 2019 19:17:06 +0200
parents 1614cb14308f
children 26e113e8224f
comparison
equal deleted inserted replaced
9612:f8308db94634 9614:d889ffe2fb05
150 /** 150 /**
151 * Selects from the database the infrastructure values of a km range of a river and a river side 151 * Selects from the database the infrastructure values of a km range of a river and a river side
152 */ 152 */
153 public static List<InfrastructureValue> getValues(final River river, final double kmLo, final double kmHi, final AttributeKey riverside) { 153 public static List<InfrastructureValue> getValues(final River river, final double kmLo, final double kmHi, final AttributeKey riverside) {
154 final Session session = SessionHolder.HOLDER.get(); 154 final Session session = SessionHolder.HOLDER.get();
155 String riversideClause = "";
156 if ((riverside == AttributeKey.LEFT) || (riverside == AttributeKey.RIGHT))
157 riversideClause = " AND (v.attribute.id=:attr_id)";
158 final Query query = session.createQuery("FROM InfrastructureValue v" 155 final Query query = session.createQuery("FROM InfrastructureValue v"
159 + " WHERE (v.infrastructure.river=:river)" 156 + " WHERE (v.infrastructure.river=:river)"
160 + " AND (v.station BETWEEN :kmLo - 0.0001 AND :kmHi + 0.0001)" 157 + " AND (v.station BETWEEN :kmLo - 0.0001 AND :kmHi + 0.0001)"
161 + riversideClause 158 + getRiversideClause(riverside, "v", "attr_id")
162 + " ORDER BY v.station, v.attribute.id"); 159 + " ORDER BY v.station, v.attribute.id");
163 query.setParameter("river", river); 160 query.setParameter("river", river);
164 query.setParameter("kmLo", new Double(kmLo)); 161 query.setParameter("kmLo", new Double(kmLo));
165 query.setParameter("kmHi", new Double(kmHi)); 162 query.setParameter("kmHi", new Double(kmHi));
166 if (!riversideClause.isEmpty()) 163 if (!getRiversideClause(riverside, "v", "attr_id").isEmpty())
167 query.setParameter("attr_id", riverside.getId()); 164 query.setParameter("attr_id", riverside.getId());
168 return query.list(); 165 return query.list();
169 } 166 }
167
168 /**
169 * Gets a query's and-where-clause for a riverside key
170 */
171 public static String getRiversideClause(final AttributeKey riverside, final String tablealias, final String variable) {
172 if ((riverside == AttributeKey.LEFT) || (riverside == AttributeKey.RIGHT))
173 return " AND (" + tablealias + ".attribute.id=:" + variable + ")";
174 else
175 return "";
176 }
170 } 177 }

http://dive4elements.wald.intevation.org