diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticState.java @ 3468:f37e7e8907cb

merged flys-artifacts/2.8.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:39 +0200
parents 94c4dd5aaf20
children 6cdd994ee8a4
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticState.java	Fri Sep 28 12:14:39 2012 +0200
@@ -0,0 +1,111 @@
+package de.intevation.flys.artifacts.states;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.flys.artifacts.model.FacetTypes;
+
+import de.intevation.artifactdatabase.state.Facet;
+import de.intevation.artifactdatabase.state.DefaultOutput;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+
+import de.intevation.artifacts.CallContext;
+import de.intevation.artifacts.CallMeta;
+
+/**
+ * Yet, a non-abstract DefaultState.
+ */
+public class StaticState
+extends      DefaultState
+implements   FacetTypes
+{
+    /** The logger that is used in this state. */
+    private static final Logger logger = Logger.getLogger(StaticState.class);
+
+
+    /**
+     * Trivial constructor, sets id and description.
+     * @param id String used for both id and description.
+     */
+    public StaticState(String id) {
+        this(id, id);
+    }
+
+
+    public StaticState(String id, String description) {
+        super();
+        setID(id);
+        setDescription(description);
+    }
+
+    public void addDefaultChartOutput(String nameDesc, List<Facet> facets) {
+        DefaultOutput output = new DefaultOutput(nameDesc,
+            nameDesc, "image/png", facets, "chart");
+        getOutputs().add(output);
+    }
+
+    public static void addDefaultChartOutput(
+        DefaultState state,
+        String nameDesc,
+        List<Facet> facets
+    ) {
+        DefaultOutput output = new DefaultOutput(nameDesc,
+            nameDesc, "image/png", facets, "chart");
+        state.getOutputs().add(output);
+    }
+
+
+    /**
+     * Do nothing (override to include your logic).
+     * @param facets List of facets (to add to).
+     */
+    public Object staticCompute(List<Facet> facets, FLYSArtifact artifact) {
+        return staticCompute(facets);
+    }
+
+    public Object staticCompute(List<Facet> facets) {
+        return null;
+    }
+
+
+    /** Call staticCompute to allow easy adjustments. */
+    @Override
+    public Object computeAdvance(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets,
+        Object       old
+    ) {
+        return staticCompute(facets, artifact);
+    }
+
+
+    /** Call staticCompute to allow easy adjustments. */
+    @Override
+    public Object computeFeed(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets,
+        Object       old
+    ) {
+        return staticCompute(facets, artifact);
+    }
+
+
+    /** Call staticCompute to allow easy adjustments. */
+    @Override
+    public Object computeInit(
+        FLYSArtifact artifact,
+        String       hash,
+        Object       context,
+        CallMeta     meta,
+        List<Facet>  facets
+    ) {
+        return staticCompute(facets, artifact);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org