Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationsFactory.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 | 02c0cce0e469 |
children | bcef54a563ea |
line wrap: on
line source
package de.intevation.flys.artifacts.model; import java.util.List; import java.util.Iterator; import de.intevation.flys.backend.SessionHolder; import de.intevation.flys.model.Annotation; import de.intevation.flys.model.Range; import de.intevation.flys.model.River; import org.hibernate.Session; import org.hibernate.Query; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class AnnotationsFactory { public static List<Annotation> getAnnotations(River river) { return getAnnotations(river.getName()); } public static List<Annotation> getAnnotations(String river) { Session session = SessionHolder.HOLDER.get(); Query rangesQuery = session.createQuery( "from Range where river.name=:name"); rangesQuery.setParameter("name", river); List<Range> ranges = rangesQuery.list(); Query query = session.createQuery( "from Annotation where range in (:ranges) order by range.a"); query.setParameterList("ranges", ranges); return query.list(); } public static Iterator<Annotation> getAnnotationsIterator(String river) { Session session = SessionHolder.HOLDER.get(); Query rangesQuery = session.createQuery( "from Range where river.name=:name"); rangesQuery.setParameter("name", river); List<Range> ranges = rangesQuery.list(); Query query = session.createQuery( "from Annotation where range in (:ranges) order by range.a"); query.setParameterList("ranges", ranges); return (Iterator<Annotation>)query.iterate(); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :