diff gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java @ 470:b7bb66440cc8

Added mechanism for advancing to previous states. gnv-artifacts/trunk@533 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 12 Jan 2010 15:25:32 +0000
parents 70df44021a9f
children a6a33ef35809
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java	Tue Jan 12 12:42:53 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java	Tue Jan 12 15:25:32 2010 +0000
@@ -116,6 +116,23 @@
         return this.inputValues.values();
     }
 
+
+    public void reset(String uuid) {
+        
+        // clear input values of the current state
+        Iterator iter = inputValueNames.iterator();
+        while (iter.hasNext()) {
+            String name = (String) iter.next();
+            inputValues.remove(name);
+        }
+
+        // remove data of last state from cache
+        List describeData = getDescibeData(uuid);
+        if (describeData != null && describeData.size() != 0) {
+            describeData.remove(describeData.size()-1);
+        }
+    }
+
     /**
      * @see de.intevation.gnv.state.State#setup(org.w3c.dom.Node)
      */
@@ -344,7 +361,6 @@
             }
         }
         return null;
-
     }
 
     /**
@@ -460,7 +476,7 @@
      */
     protected void purifyResult(Collection<Result> result, String uuid) {
         log.debug("StateBase.purifyResult");
-        Collection<Object> describeData = this.getDescibeData(uuid);
+        List<Object> describeData = this.getDescibeData(uuid);
         if (describeData == null) {
             describeData = new ArrayList<Object>();
         }
@@ -518,7 +534,8 @@
      */
     public void describe(Document document, Node rootNode, CallMeta callMeta,String uuid) {
         log.debug("StateBase.describe");
-        Collection<Object> descibeData = this.getDescibeData(uuid);
+
+        List<Object> descibeData = this.getDescibeData(uuid);
         if (descibeData != null) {
             Iterator<Object> it = descibeData.iterator();
 
@@ -798,13 +815,13 @@
     /**
      * @see de.intevation.gnv.state.State#getDescibeData()
      */
-    protected Collection<Object> getDescibeData(String uuid) {
+    protected List<Object> getDescibeData(String uuid) {
         if (CacheFactory.getInstance().isInitialized()) {
             String key = uuid + DESCRIBEDATAKEY;
             log.debug("Hash for Queryelements: " + key);
             net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key);
             if (value != null) {
-                return (Collection<Object>) (value.getObjectValue());
+                return (List<Object>) (value.getObjectValue());
             }
         }
         return null;
@@ -813,7 +830,7 @@
     /**
      * @see de.intevation.gnv.state.State#getDescibeData()
      */
-    protected void setDescibeData(String uuid, Collection<Object> describeData) {
+    protected void setDescibeData(String uuid, List<Object> describeData) {
         
         if (CacheFactory.getInstance().isInitialized()) {
             String key = uuid + DESCRIBEDATAKEY;

http://dive4elements.wald.intevation.org