diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/BlackboardDataFacet.java @ 3814:8083f6384023

merged flys-artifacts/pre2.6-2012-01-04
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:56 +0200
parents 2bb160b2768e
children bb0dede9294f
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/model/BlackboardDataFacet.java	Fri Sep 28 12:14:56 2012 +0200
@@ -0,0 +1,55 @@
+package de.intevation.flys.artifacts.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.DefaultFacet;
+
+
+/**
+ * Facet that writes artifact-uui and facet index on the blackboard,
+ * delivers data if asked so.
+ */
+public class BlackboardDataFacet extends DefaultFacet {
+
+    public BlackboardDataFacet() {}
+
+    /** Do not instantiate a BlackboardDataFacet, subclass it instead. */
+    public BlackboardDataFacet(int idx, String name, String description) {
+        super(idx, name, description);
+    }
+
+
+    /** Hey, We can ArtifactUUID+FacetIndex (i.e. getData)! */
+    public List getDataProviderKeys(Artifact art) {
+        List list = new ArrayList();
+        list.add(art.identifier() + getIndex());
+        return list;
+    }
+
+
+    /**
+     * Can provide whatever getData returns.
+     * @param key      will respond on uuid+index
+     * @param param    ignored
+     * @param context  ignored
+     * @return whatever getData delivers.
+     */
+    public Object provideBlackboardData(Artifact artifact,
+        Object key,
+        Object param,
+        CallContext context
+    ) {
+        if (key.equals(artifact.identifier() + getIndex())) {
+            return getData(artifact, context);
+        }
+        else {
+            return null;
+        }
+    }
+
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org