changeset 691:2600aa2c7319 facets-slt

Store facets for each state. flys-artifacts/branches/facets-slt@2131 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 16 Jun 2011 09:04:59 +0000
parents 3481cd37e609
children 22e4bffbe240
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Thu Jun 16 08:57:05 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Thu Jun 16 09:04:59 2011 +0000
@@ -3,6 +3,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.TreeMap;
 import java.util.List;
 import java.util.Map;
@@ -104,7 +105,7 @@
     protected Map<String, StateData> data;
 
     /** The list of facets supported by this artifact.*/
-    protected List<Facet> facets;
+    protected Map<String, List<Facet>> facets;
 
 
     /**
@@ -113,7 +114,7 @@
     public FLYSArtifact() {
         data             = new TreeMap<String, StateData>();
         previousStateIds = new ArrayList<String>();
-        facets           = new ArrayList<Facet>();
+        facets           = new HashMap<String, List<Facet>>();
     }
 
 
@@ -258,6 +259,7 @@
                 String prev = prevs.get(i);
                 logger.debug("Remove state id '" + prev + "'");
                 prevs.remove(prev);
+                facets.remove(prev);
             }
 
             setCurrentStateId(targetState);
@@ -1089,15 +1091,21 @@
         ComputeCallback callback,
         ComputeType     type)
     {
+        String stateId = getCurrentStateId();
+        List<Facet> fs = facets.get(stateId);
+        if (fs == null) {
+            fs = new ArrayList<Facet>();
+            facets.put(stateId, fs);
+        }
+
         Cache cache = CacheFactory.getCache(COMPUTING_CACHE);
-
         if (cache == null) {
             switch (type) {
                 case FEED:
-                    return callback.computeFeed(facets);
+                    return callback.computeFeed(fs);
 
                 case ADVANCE:
-                    return callback.computeAdvance(facets);
+                    return callback.computeAdvance(fs);
             }
         }
 
@@ -1110,11 +1118,11 @@
         Object result = null;
         switch (type) {
             case FEED:
-                result = callback.computeFeed(facets);
+                result = callback.computeFeed(fs);
                 break;
 
             case ADVANCE:
-                result = callback.computeAdvance(facets);
+                result = callback.computeAdvance(fs);
         }
 
         if (result != null) {

http://dive4elements.wald.intevation.org