changeset 525:0fdd239f4f39 facet-metadata

Merged default into branch facet-metadata.
author Tom Gottfried <tom@intevation.de>
date Tue, 08 Jul 2014 18:33:15 +0200
parents ab13ab6acc5c (diff) 52c11c3a1f79 (current diff)
children e149751b9c6d 41feef58781b
files
diffstat 2 files changed, 60 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/artifact-database/src/main/java/org/dive4elements/artifactdatabase/state/DefaultFacet.java	Fri Jun 27 19:28:24 2014 +0200
+++ b/artifact-database/src/main/java/org/dive4elements/artifactdatabase/state/DefaultFacet.java	Tue Jul 08 18:33:15 2014 +0200
@@ -1,6 +1,8 @@
 package org.dive4elements.artifactdatabase.state;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -32,9 +34,12 @@
     /** The description of this facet. */
     protected String description;
 
+    /** The meta data this facet provides. */
+    protected Map<String, String> metaData;
 
     /** Trivial, empty constructor. */
     public DefaultFacet() {
+        this.metaData = new HashMap<String, String>();
     }
 
 
@@ -60,6 +65,7 @@
         this.index       = index;
         this.name        = name;
         this.description = description;
+        this.metaData    = new HashMap<String, String>();
     }
 
 
@@ -108,6 +114,32 @@
 
 
     /**
+     * Returns the meta data this facet provides.
+     *
+     * @param artifact The owner artifact.
+     * @param context The CallContext.
+     *
+     * @return the meta data.
+     */
+    @Override
+    public Map<String, String> getMetaData(
+        Artifact artifact,
+        CallContext context)
+    {
+        return this.metaData;
+    }
+
+    @Override
+    public Map<String, String> getMetaData() {
+        return this.metaData;
+    }
+
+    @Override
+    public void addMetaData(String key, String value) {
+        this.metaData.put(key, value);
+    }
+
+    /**
      * (Do not) provide data.
      * Override to allow other facets to access your data.
      * @return always null.
@@ -179,6 +211,7 @@
         name        = other.getName();
         description = other.getDescription();
         boundToOut  = other.getBoundToOut();
+        metaData    = other.getMetaData();
     }
 
 
--- a/artifact-database/src/main/java/org/dive4elements/artifactdatabase/state/Facet.java	Fri Jun 27 19:28:24 2014 +0200
+++ b/artifact-database/src/main/java/org/dive4elements/artifactdatabase/state/Facet.java	Tue Jul 08 18:33:15 2014 +0200
@@ -1,6 +1,7 @@
 package org.dive4elements.artifactdatabase.state;
 
 import java.util.List;
+import java.util.Map;
 
 import java.io.Serializable;
 
@@ -62,6 +63,31 @@
 
 
     /**
+     * Returns the meta data this facet provides.
+     *
+     * @return the meta data.
+     */
+    Map<String, String> getMetaData();
+
+    /**
+     * Returns the meta data this facet provides.
+     *
+     * @param artifact The owner artifact.
+     * @param context The CallContext.
+     *
+     * @return the meta data.
+     */
+    Map<String, String> getMetaData(Artifact artifact, CallContext context);
+
+    /**
+     * Add a key value pair to the facets metadata.
+     *
+     * @param key   The meta data key.
+     * @param value The meta data value.
+     */
+    void addMetaData(String key, String value);
+
+    /**
      * Get keys for which this Facet can provide data (for other facets, not
      * for plot).
      * @param artifact Artifact that this facet belongs to.
@@ -97,5 +123,6 @@
     Node toXML(Document doc);
 
     Facet deepCopy();
+
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org