Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstFactory.java @ 622:02ca2ff96dee
flys/issue84: Forget to select wst kind.
flys-artifacts/trunk@1978 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 23 May 2011 13:35:52 +0000 |
parents | 8a4360ccbe1c |
children |
comparison
equal
deleted
inserted
replaced
621:4e0ca3890696 | 622:02ca2ff96dee |
---|---|
12 /** | 12 /** |
13 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 13 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
14 */ | 14 */ |
15 public class WstFactory { | 15 public class WstFactory { |
16 | 16 |
17 public static final int DEFAULT_KIND = 0; | |
18 | |
17 /** We don't need to instantiate concrete objects of this class. */ | 19 /** We don't need to instantiate concrete objects of this class. */ |
18 private WstFactory() { | 20 private WstFactory() { |
19 } | 21 } |
20 | 22 |
21 | 23 |
25 * @param river The river. | 27 * @param river The river. |
26 * | 28 * |
27 * @return the Wst of <i>river</i>. | 29 * @return the Wst of <i>river</i>. |
28 */ | 30 */ |
29 public static Wst getWst(River river) { | 31 public static Wst getWst(River river) { |
32 return getWst(river, DEFAULT_KIND); | |
33 } | |
34 | |
35 public static Wst getWst(River river, int kind) { | |
30 Session session = SessionHolder.HOLDER.get(); | 36 Session session = SessionHolder.HOLDER.get(); |
31 | 37 |
32 Query query = session.createQuery( | 38 Query query = session.createQuery( |
33 "from Wst where river=:river"); | 39 "from Wst where river=:river and kind = :kind"); |
34 query.setParameter("river", river); | 40 query.setParameter("river", river); |
41 query.setInteger("kind", kind); | |
35 | 42 |
36 List<Wst> wst = query.list(); | 43 List<Wst> wsts = query.list(); |
37 | 44 |
38 return (wst != null && wst.size() > 0) ? wst.get(0) : null; | 45 return wsts.isEmpty() ? null : wsts.get(0); |
39 } | 46 } |
40 } | 47 } |
41 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 48 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |