changeset 4211:47b7325eafeb

merged
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 22 Oct 2012 17:07:02 +0200
parents e47559908acc (diff) 0dd8963cec9c (current diff)
children fbaba8e1a3a2
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java
diffstat 3 files changed, 49 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java	Mon Oct 22 15:33:16 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/AnnotationArtifact.java	Mon Oct 22 17:07:02 2012 +0200
@@ -16,10 +16,13 @@
 
 import de.intevation.artifactdatabase.ProtocolUtils;
 import de.intevation.artifactdatabase.state.Facet;
+import de.intevation.artifactdatabase.state.FacetActivity;
 import de.intevation.artifactdatabase.state.Output;
 import de.intevation.artifactdatabase.state.State;
 import de.intevation.artifactdatabase.state.StateEngine;
 
+import de.intevation.flys.artifacts.model.FacetTypes;
+
 import de.intevation.artifacts.common.utils.XMLUtils;
 
 import de.intevation.flys.artifacts.states.DefaultState;
@@ -30,7 +33,9 @@
 /**
  * Artifact to access names of Points Of Interest along a segment of a river.
  */
-public class AnnotationArtifact extends StaticFLYSArtifact {
+public class AnnotationArtifact
+extends      StaticFLYSArtifact
+implements   FacetTypes {
 
     /** The logger for this class. */
     private static Logger logger = Logger.getLogger(AnnotationArtifact.class);
@@ -38,6 +43,32 @@
     /** The name of the artifact. */
     public static final String ARTIFACT_NAME = "annotation";
 
+    // Let Annotations enter life inactively if in Fix Analysis LS setting.
+    static {
+        FacetActivity.Registry.getInstance().register(
+            "annotation",
+            new FacetActivity() {
+                @Override
+                public Boolean isInitialActive(
+                    Artifact artifact,
+                    Facet    facet,
+                    String   output
+                ) {
+                    if (output.contains(FacetTypes.ChartType.FLSC.toString())) {
+                        // Longitudinal section chart
+                        String name = facet.getName();
+
+                        if (name.contains(FacetTypes.LONGITUDINAL_ANNOTATION)) {
+                            return Boolean.FALSE;
+                        }
+                    }
+
+                    return Boolean.TRUE;
+                }
+            });
+    }
+
+
     @Override
     public void setup(
         String          identifier,
@@ -55,6 +86,7 @@
         super.setup(identifier, factory, context, callMeta, data);
     }
 
+
     /** Get river, setup Facets. */
     @Override
     protected void initialize(Artifact artifact, Object context,
@@ -81,6 +113,8 @@
         }
     }
 
+
+    /** Shortcut to nameFilter-data (TODO: move to respective Access). */
     public String getFilterName() {
         return getDataAsString("nameFilter");
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Mon Oct 22 15:33:16 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Mon Oct 22 17:07:02 2012 +0200
@@ -249,6 +249,7 @@
     }
 
 
+    /** Clone the internal map of map of state-name to state-data. */
     protected Map<String, StateData> cloneData() {
         Map<String, StateData> copy = new TreeMap<String, StateData>();
 
@@ -518,7 +519,7 @@
             String.valueOf(context.isInBackground()),
             true);
 
-        CalculationMessage  message  = (CalculationMessage) messages.getLast();
+        CalculationMessage message = (CalculationMessage) messages.getLast();
         cr.addAttr(
             inBackground,
             "steps",
@@ -743,6 +744,7 @@
     }
 
 
+    /** Remove and return statedata associated to name. */
     protected StateData removeData(String name) {
         return this.data.remove(name);
     }
@@ -760,6 +762,7 @@
         return data.get(name);
     }
 
+
     /**
      * A derived Artifact class can use this method to set the data
      */
@@ -767,6 +770,7 @@
         this.data = data;
     }
 
+
     /** Return named data item, null if not found. */
     public String getDataAsString(String name) {
         StateData data = getData(name);
@@ -887,9 +891,11 @@
     }
 
 
+    /** Return all produced facets. */
     public List<Facet> getFacets() {
         List<Facet> all = new ArrayList<Facet>();
 
+        // Iterate over facets of each state.
         for (List<Facet> fs: facets.values()) {
             all.addAll(fs);
         }
@@ -1488,6 +1494,7 @@
     }
 
 
+    /** Destroy and clean up state with given id. */
     protected void destroyState(String id, Object context) {
         State s = getState(context, id);
         s.endOfLife(this, context);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Mon Oct 22 15:33:16 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Mon Oct 22 17:07:02 2012 +0200
@@ -3,7 +3,9 @@
 /** 'Types' of facets. */
 public interface FacetTypes {
 
-    public class IS {
+    /** Static helper class to determine if a Facet name is of a generalized
+     * 'type'. */
+    public static class IS {
         public static boolean WQ_KM(String type) {
            return type.equals(DISCHARGE_LONGITUDINAL_W)
                || type.equals(LONGITUDINAL_W);
@@ -103,6 +105,9 @@
         }
     };
 
+    /** Available diagram/chart-types.  This enum is evaluated at certain
+     * places to iterate over chart-types to e.g. dynamically generate
+     * Facet-names (ManualPoints for example). */
     public enum ChartType {
         FD("fix_derivate_curve"),
         LS("longitudinal_section"),

http://dive4elements.wald.intevation.org