comparison flys-backend/src/main/java/de/intevation/flys/model/River.java @ 757:c19d4c643526

River: add method to find gauge by its station position. flys-backend/trunk@2090 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 08 Jun 2011 19:03:44 +0000
parents ca13926b8871
children e09f00ecb915
comparison
equal deleted inserted replaced
756:ca13926b8871 757:c19d4c643526
114 query.setParameter("b", new BigDecimal(b)); 114 query.setParameter("b", new BigDecimal(b));
115 115
116 return query.list(); 116 return query.list();
117 } 117 }
118 118
119 public Gauge determineGaugeByStation(double a, double b) {
120
121 if (a > b) { double t = a; a = b; b = t; }
122
123 Session session = SessionHolder.HOLDER.get();
124
125 Query query = session.createQuery(
126 "from Gauge where river.id=:river " +
127 "and station between :a and :b");
128 query.setParameter("river", getId());
129 query.setParameter("a", new BigDecimal(a));
130 query.setParameter("b", new BigDecimal(b));
131
132 List<Gauge> gauges = query.list();
133 return gauges.isEmpty() ? null : gauges.get(0);
134 }
135
119 136
120 /** 137 /**
121 * This method returns the first gauge that is intersected by <i>a</i> and 138 * This method returns the first gauge that is intersected by <i>a</i> and
122 * <i>b</i>, 139 * <i>b</i>,
123 * 140 *

http://dive4elements.wald.intevation.org