# HG changeset patch # User Felix Wolfsteller # Date 1313153659 0 # Node ID abd2ab6dff4f1eacff12bf9d10374b9fe4380d26 # Parent bcef54a563ea3fcfe632bbcea335a1113ccf71d5 Let AnnotationArtifact fetch "more correct" data. flys-artifacts/trunk@2492 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r bcef54a563ea -r abd2ab6dff4f flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Aug 12 12:39:44 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Aug 12 12:54:19 2011 +0000 @@ -1,3 +1,9 @@ +2011-08-12 Felix Wolfsteller + + * src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java: + Resolved two TODOs: get Annotations of selected River, get "point" + Annotations only. + 2011-08-12 Felix Wolfsteller Added functionality to query range and point-annotations only to diff -r bcef54a563ea -r abd2ab6dff4f flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java Fri Aug 12 12:39:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java Fri Aug 12 12:54:19 2011 +0000 @@ -11,7 +11,7 @@ import org.hibernate.Session; -import net.sf.ehcache.Cache; +//import net.sf.ehcache.Cache; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.ArtifactNamespaceContext; @@ -48,8 +48,8 @@ /** The name of the artifact. */ public static final String ARTIFACT_NAME = "annotation"; - public static final String CACHE_NAME = "service-distanceinfo"; - + /* Name of cache. */ + //public static final String CACHE_NAME = "annotations"; @Override protected void initialize(Artifact artifact, Object context, CallMeta meta) { @@ -57,6 +57,11 @@ FLYSArtifact flys = (FLYSArtifact) artifact; addData("river", flys.getData("river")); + /* + logger.debug("Could set ranges to " + + AnnotationsFactory.getAnnotationsBreadth( + getRiver().getName())[0]); + */ List fs = new ArrayList(); @@ -76,8 +81,9 @@ @Override public double[] getDistance() { - /** TODO In initialize(), access maximal range of river instead of - * overriding getDistance, important for diagram generation. */ + /** TODO In initialize(), access maximal range of river (via + * AnnotationFactory) instead of overriding getDistance, + * important for diagram generation. */ return new double[] {0f, 1000f}; } @@ -226,28 +232,26 @@ * @return list of Annotations. */ public List getAnnotations() { - // TODO Use Cache of DistanceInfoService. - // TODO Use given river. - // TODO Query Points (opposed to segments) only. - String river = "Saar"; + String river = getRiver().getName(); logger.debug("Search annotations for river: " /*+ river*/); //Cache cache = CacheFactory.getCache(CACHE_NAME); List annotations = new ArrayList(); - //if (cache == null) { - // logger.debug("No cache configured for distance info."); - //return getUncached(river, filter); - //} + return getAnnotationsUncached(river); + } + + /** + * Gets Annotations from Session/Database. + * + * @return List of Annotations fetched fresh from session/database. + * @see DistanceInfoService to access cached documents. + */ + protected List getAnnotationsUncached(String river) { + List annotations = new ArrayList(); Session session = SessionHolder.acquire(); try { - Iterator iter = - AnnotationsFactory.getAnnotationsIterator(river); - while (iter.hasNext()) { - Annotation a = iter.next(); - logger.debug("Annotation: " + a.getPosition().getValue()); - annotations.add(a); - } + annotations = AnnotationsFactory.getPointAnnotations(river); } finally {session.close(); SessionHolder.release();} return annotations; }