changeset 403:bd76529d612b

FacetActivity: Added interface and registry to decide if a facet should initially active or not. artifacts/trunk@5150 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 29 Jul 2012 09:37:55 +0000
parents b4ed641f01db
children 4c78c5d2b367
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/state/FacetActivity.java
diffstat 2 files changed, 64 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jul 27 06:21:40 2012 +0000
+++ b/ChangeLog	Sun Jul 29 09:37:55 2012 +0000
@@ -1,3 +1,9 @@
+2012-07-29	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/state/FacetActivity.java:
+	  New. Implementors of this interface can decide if a facet should be initially
+	  active or not. Contains a registry singleton.
+
 2012-07-27  Ingo Weinzierl <ingo@intevation.de>
 
 	Tagged trunk as '2.8.1'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/FacetActivity.java	Sun Jul 29 09:37:55 2012 +0000
@@ -0,0 +1,58 @@
+package de.intevation.artifactdatabase.state;
+
+import de.intevation.artifacts.Artifact;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public interface FacetActivity
+{
+    public static final FacetActivity ACTIVE = new FacetActivity() {
+        @Override
+        public boolean isInitialActive(
+            Artifact artifact,
+            Facet    facet,
+            String   output
+        ) {
+            return true;
+        }
+    };
+
+    public static final FacetActivity INACTIVE = new FacetActivity() {
+        @Override
+        public boolean isInitialActive(
+            Artifact artifact,
+            Facet    facet,
+            String   output
+        ) {
+            return false;
+        }
+    };
+
+    boolean isInitialActive(Artifact artifact, Facet facet, String output);
+
+    public static final class Registry {
+
+        private static final Registry INSTANCE = new Registry();
+
+        private Map<String, FacetActivity> activities;
+
+        private Registry() {
+            activities = new HashMap<String, FacetActivity>();
+        }
+
+        public Registry getInstance() {
+            return INSTANCE;
+        }
+
+        public synchronized FacetActivity getActivity(String key) {
+            FacetActivity activity = activities.get(key);
+            return activity != null ? activity : ACTIVE;
+        }
+
+        public synchronized void register(String key, FacetActivity activity) {
+            activities.put(key, activity);
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org