Mercurial > dive4elements > river
changeset 1031:bcef54a563ea
Added functionality to query range and point-annotations only to
AnnotationFactory.
flys-artifacts/trunk@2491 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 12 Aug 2011 12:39:44 +0000 |
parents | c586b6220f35 |
children | abd2ab6dff4f |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationsFactory.java |
diffstat | 2 files changed, 58 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Thu Aug 11 15:08:24 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Aug 12 12:39:44 2011 +0000 @@ -1,3 +1,12 @@ +2011-08-12 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Added functionality to query range and point-annotations only to + AnnotationFactory. + + * src/main/java/de/intevation/flys/artifacts/model/AnnotationsFactory.java + (getPointAnnotations, getAnnotationsBreadth): + New functions to query breadth and point-only annotations. + 2011-08-11 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/datacage/Recommendations.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationsFactory.java Thu Aug 11 15:08:24 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationsFactory.java Fri Aug 12 12:39:44 2011 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.artifacts.model; +import java.math.BigDecimal; + import java.util.List; import java.util.Iterator; @@ -21,6 +23,29 @@ } + /** + * Get Annotations which do not have a "b" ("to")-value set. + * + * @param river name of the river of interest. + * + * @return List of Annotations for river which have only "a" ("from") + * value set. + */ + public static List<Annotation> getPointAnnotations(String river) { + Session session = SessionHolder.HOLDER.get(); + + Query rangesQuery = session.createQuery( + "from Range where river.name=:name and b = null"); + 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 List<Annotation> getAnnotations(String river) { Session session = SessionHolder.HOLDER.get(); @@ -36,6 +61,30 @@ } + /** + * Get minimal "a" ("from") and maximal "b" ("to") value of annotations' + * ranges of a river. + * + * @param river name of the river of interest. + * + * @return Array containing minimal "a" and max "b" value of any + * annotation stored for the given river. + */ + public static double[] getAnnotationsBreadth(String river) { + Session session = SessionHolder.HOLDER.get(); + + Query minAQuery = session.createQuery( + "select min(a), max(b) from Range where river.name=:name"); + minAQuery.setParameter("name", river); + + double[] minAmaxB = {0.0f, 0.0f}; + Object[] row = (Object[]) minAQuery.list().iterator().next(); + minAmaxB[0] = ((BigDecimal) row[0]).doubleValue(); + minAmaxB[1] = ((BigDecimal) row[1]).doubleValue(); + return minAmaxB; + } + + public static Iterator<Annotation> getAnnotationsIterator(String river) { Session session = SessionHolder.HOLDER.get();