changeset 4015:7f8d92873d58

Handle annotationtypes in AnnotationArtifact and -Facet.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 02 Oct 2012 10:42:34 +0200
parents e5e1331d0440
children 87aafd2c643a
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java
diffstat 3 files changed, 38 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Oct 02 10:38:39 2012 +0200
+++ b/flys-artifacts/ChangeLog	Tue Oct 02 10:42:34 2012 +0200
@@ -1,3 +1,12 @@
+2012-10-02	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java
+	  (setup): Deal with ids from datacage-doc, expose a data-item with the
+	  annotationtypename.
+	  
+	* flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java
+	  (getData): filter annotations given by typename, if available.
+
 2012-10-02	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* doc/conf/meta-data.xml: Show "per-type" annotations in
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java	Tue Oct 02 10:38:39 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java	Tue Oct 02 10:42:34 2012 +0200
@@ -9,6 +9,7 @@
 import org.apache.log4j.Logger;
 
 import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.ArtifactFactory;
 import de.intevation.artifacts.ArtifactNamespaceContext;
 import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
@@ -37,6 +38,23 @@
     /** The name of the artifact. */
     public static final String ARTIFACT_NAME = "annotation";
 
+    @Override
+    public void setup(
+        String          identifier,
+        ArtifactFactory factory,
+        Object          context,
+        CallMeta        callMeta,
+        Document        data)
+    {
+        logger.debug("AnnotationArtifact.setup");
+        String filter = StaticFLYSArtifact.getDatacageIDValue(data);
+        String[] splits = filter.split(":");
+        if (splits.length > 1) {
+            addStringData("nameFilter", splits[1]);
+        }
+        super.setup(identifier, factory, context, callMeta, data);
+    }
+
     /** Get river, setup Facets. */
     @Override
     protected void initialize(Artifact artifact, Object context,
@@ -63,6 +81,10 @@
         }
     }
 
+    public String getFilterName() {
+        return getDataAsString("nameFilter");
+    }
+
 
     public double[] getDistance() {
         /** TODO In initialize(), access maximal range of river (via
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java	Tue Oct 02 10:38:39 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/AnnotationFacet.java	Tue Oct 02 10:42:34 2012 +0200
@@ -70,11 +70,17 @@
 
         FastAnnotations fas = LocationProvider.getAnnotations(riverName);
 
+        String filterName = annotationArtifact.getFilterName();
+
+        FastAnnotations.Filter filter = (filterName == null)
+            ? FastAnnotations.IS_POINT
+            : new FastAnnotations.NameFilter(filterName);
+
         List<StickyAxisAnnotation> xy =
             new ArrayList<StickyAxisAnnotation>(fas.size());
 
         for (Iterator<FastAnnotations.Annotation> iter =
-                fas.filter(FastAnnotations.IS_POINT); iter.hasNext();) {
+                fas.filter(filter); iter.hasNext();) {
             FastAnnotations.Annotation fa = iter.next();
 
             xy.add(new StickyAxisAnnotation(

http://dive4elements.wald.intevation.org