comparison flys-backend/src/main/java/de/intevation/flys/model/Wst.java @ 2372:027736510a30

Added a new method Wst.determineMinMaxQ(double,double). flys-backend/trunk@3552 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 28 Dec 2011 12:16:52 +0000
parents 0acf28a3d28a
children ab1e642e7c85
comparison
equal deleted inserted replaced
2371:fe89d6cf55fb 2372:027736510a30
127 * @param range The range used for querying the Q values. 127 * @param range The range used for querying the Q values.
128 * 128 *
129 * @return the min and max Q values of this WST. 129 * @return the min and max Q values of this WST.
130 */ 130 */
131 public double[] determineMinMaxQ(Range range) { 131 public double[] determineMinMaxQ(Range range) {
132 if (range != null) {
133 return determineMinMaxQ(
134 range.getA().doubleValue(),
135 range.getB().doubleValue());
136 }
137
138 return null;
139 }
140
141
142 /**
143 * Determines the min and max Q values of this WST in the given range. The
144 * min value is placed in the first field of the resulting array - the max
145 * value is placed in the second field.
146 *
147 * @param fromKm the lower km value.
148 * @param toKm the upper km value.
149 *
150 * @return the min and max Q values of this WST.
151 */
152 public double[] determineMinMaxQ(double fromKm, double toKm) {
132 Session session = SessionHolder.HOLDER.get(); 153 Session session = SessionHolder.HOLDER.get();
133 154
134 Query query = session.createQuery( 155 Query query = session.createQuery(
135 "select min(q), max(q) from WstQRange where " + 156 "select min(q), max(q) from WstQRange where " +
136 " id in " + 157 " id in " +
138 " wstColumn.id in (select id from WstColumn where wst.id = :wst)) " + 159 " wstColumn.id in (select id from WstColumn where wst.id = :wst)) " +
139 " and range.id in " + 160 " and range.id in " +
140 " (select id from Range where not (a > :end or b < :start))"); 161 " (select id from Range where not (a > :end or b < :start))");
141 162
142 query.setParameter("wst", getId()); 163 query.setParameter("wst", getId());
143 query.setParameter("start", range.getA()); 164 query.setParameter("start", new BigDecimal(fromKm));
144 query.setParameter("end", range.getB()); 165 query.setParameter("end", new BigDecimal(toKm));
145 166
146 List<Object []> results = query.list(); 167 List<Object []> results = query.list();
147 168
148 if (results.isEmpty()) { 169 if (results.isEmpty()) {
149 return null; 170 return null;

http://dive4elements.wald.intevation.org