Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RiverFactory.java @ 965:79251b1d47da
Modified the CollectionMonitor to recommend artifacts for the current state's outputs only.
flys-artifacts/trunk@2385 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 21 Jul 2011 14:00:09 +0000 |
parents | 94c176fdcb89 |
children | feaf778d510e |
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 org.hibernate.Query; import org.hibernate.Session; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class RiverFactory { /** We don't need to instantiate concrete objects of this class. */ private RiverFactory() { } /** * Returns all rivers that were found in the backend. * * @return all rivers. */ public static List<River> getRivers() { Session session = SessionHolder.HOLDER.get(); return (List<River>)session .createQuery("from River order by name").list(); } /** * Returns a River object fetched from database based on its name. * * @param river The name of a river. * * @return the River object. */ public static River getRiver(String river) { Session session = SessionHolder.HOLDER.get(); Query query = session.createQuery( "from River where name =:name"); query.setParameter("name", river); List<River> rivers = query.list(); return (rivers != null && rivers.size() > 0) ? rivers.get(0) : null; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :