changeset 1032:abd2ab6dff4f

Let AnnotationArtifact fetch "more correct" data. flys-artifacts/trunk@2492 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 12 Aug 2011 12:54:19 +0000
parents bcef54a563ea
children 821aaceb2776
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java
diffstat 2 files changed, 30 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- 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 <felix.wolfsteller@intevation.de>
+
+	* 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 <felix.wolfsteller@intevation.de>
 
 	Added functionality to query range and point-annotations only to
--- 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<Facet> fs = new ArrayList<Facet>();
 
@@ -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<Annotation> 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<Annotation> annotations = new ArrayList<Annotation>();
 
-        //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<Annotation> getAnnotationsUncached(String river) {
+        List<Annotation> annotations = new ArrayList<Annotation>();
         Session session = SessionHolder.acquire();
         try {
-            Iterator<Annotation> 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;
     }

http://dive4elements.wald.intevation.org