Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstFactory.java @ 4255:670e98f5a441
Fixed leak while merging facets.
The ThemeList that is used by OutputHelper to sort the
Facets for an Output now uses a list to store the ManagedFacets.
The correct order is made up by sorting the List using
Collections.sort() function of the Java JDK. Therfore, the
ManagedFacet class implements the Comparable interface. The
return value of its compareTo(other) method depends on the
value of the 'position' field.
author | Ingo Weinzierl <weinzierl.ingo@googlemail.com> |
---|---|
date | Thu, 25 Oct 2012 14:01:46 +0200 |
parents | 02ca2ff96dee |
children |
line wrap: on
line source
package de.intevation.flys.artifacts.model; import java.util.List; import de.intevation.flys.backend.SessionHolder; import de.intevation.flys.model.River; import de.intevation.flys.model.Wst; import org.hibernate.Query; import org.hibernate.Session; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class WstFactory { public static final int DEFAULT_KIND = 0; /** We don't need to instantiate concrete objects of this class. */ private WstFactory() { } /** * Returns the Wst object for a given river. * * @param river The river. * * @return the Wst of <i>river</i>. */ public static Wst getWst(River river) { return getWst(river, DEFAULT_KIND); } public static Wst getWst(River river, int kind) { Session session = SessionHolder.HOLDER.get(); Query query = session.createQuery( "from Wst where river=:river and kind = :kind"); query.setParameter("river", river); query.setInteger("kind", kind); List<Wst> wsts = query.list(); return wsts.isEmpty() ? null : wsts.get(0); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :