changeset 409:df78178e1180

Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this. gnv/trunk@599 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 22 Jan 2010 11:28:25 +0000
parents b5733f9f386b
children 9602f4bffc07
files gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java gnv/src/main/java/de/intevation/gnv/action/DescribeUIAction.java gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java gnv/src/main/java/de/intevation/gnv/action/FetchArtifactFactoriesAction.java gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java gnv/src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java
diffstat 8 files changed, 235 insertions(+), 223 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/ChangeLog	Fri Jan 22 09:49:34 2010 +0000
+++ b/gnv/ChangeLog	Fri Jan 22 11:28:25 2010 +0000
@@ -1,3 +1,22 @@
+2010-01-22  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/java/de/intevation/gnv/action/DescribeUIAction.java: New action.
+	  The only task of this action is to parse the describe document and create 
+	  static and dynamic user interface out of it.
+
+	* src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java,
+	  src/main/java/de/intevation/gnv/action/DoOutputAction.java,
+	  src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java,
+	  src/main/java/de/intevation/gnv/action/FetchArtifactFactoriesAction.java,
+	  src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java,
+	  src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java:
+	  Removed xsl transformation. Classes which needs xsl transformation inherit
+	  from DescribeUIAction which does the transformation. Now, it is much
+	  easier to write new actions, because they do not need to parse the
+	  describe document and create static and dynamic user interfaces.
+
+	  Removed some useless imports.
+
 2010-01-22  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/webapp/WEB-INF/jsp/index.jsp,
--- a/gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java	Fri Jan 22 09:49:34 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java	Fri Jan 22 11:28:25 2010 +0000
@@ -7,6 +7,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.log4j.Logger;
+
 import org.apache.struts.action.Action;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
@@ -18,12 +19,6 @@
  */
 public class ArtifactDatabaseActionBase extends Action {
 
-    public static final String XSL_SHEET_DYNAMIC =
-        "WEB-INF/config/templates/describe-ui.xsl";
-
-    public static final String XSL_SHEET_STATIC =
-        "WEB-INF/config/templates/describe-ui-static.xsl";
-
     protected final static String SUCCSESS_FORWARD_ID = "success";
     protected final static String EXCEPTION_FORWARD_ID = "success";
 
@@ -51,6 +46,7 @@
                                  HttpServletRequest request,
                                  HttpServletResponse response) throws Exception {
         log.debug("ArtifactDatabaseActionBase.execute");
+
         ActionForward forward = mapping.findForward(SUCCSESS_FORWARD_ID);
         return forward;
     }
--- a/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Fri Jan 22 09:49:34 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Fri Jan 22 11:28:25 2010 +0000
@@ -14,24 +14,19 @@
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
-import org.w3c.dom.Node;
 
 import de.intevation.gnv.action.sessionmodel.DiagrammOptions;
 import de.intevation.gnv.action.sessionmodel.SessionModel;
 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
-import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
-import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
 import de.intevation.gnv.artifactdatabase.objects.OutputMode;
 import de.intevation.gnv.artifactdatabase.objects.OutputParameter;
-import de.intevation.gnv.util.XMLUtils;
-import de.intevation.gnv.util.XSLTransformer;
 
 /**
  * @author Tim Englich <tim.englich@intevation.de>
  * 
  */
-public class ChangeOptionsAction extends ArtifactDatabaseActionBase {
+public class ChangeOptionsAction extends DescribeUIAction {
     /**
      * the logger, used to log exceptions and additonaly information
      */
@@ -53,6 +48,8 @@
             SessionModel sm = SessionModelFactory.getInstance()
                     .getSessionModel(request);
 
+            ArtifactDescription ad = sm.getArtifactDescription();
+
             String target = request.getParameter("target");
             OutputMode outputMode = sm.getOutputMode(target);
             if (outputMode != null) {
@@ -80,42 +77,6 @@
                 }
             }
 
-            ArtifactDescription ad = sm.getArtifactDescription();
-            ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory
-                                                .getInstance()
-                                                .getArtifactDatabaseClient(getLocale(request));
-
-            ArtifactDescription artifactDescription = adc
-                    .getCurrentStepDescription(sm.getSelectedArtifactFactory(),
-                                               sm.getCurrentArtifact(),
-                                               true);
-
-            Node currentUI = artifactDescription.getCurrentUI();
-            XSLTransformer transformer = new XSLTransformer();
-
-            String url = response.encodeURL(
-                mapping.findForward("back").getPath());
-            transformer.addParameter("back-url", url);
-
-            String fisUrl = response.encodeURL(
-                mapping.findForward("selectfis").getPath());
-            transformer.addParameter("selectfis", fisUrl);
-
-            String ui = transformer.transform(
-                new XMLUtils().getNodeXPath(currentUI, "art:dynamic"),
-                "UTF-8",
-                request.getRealPath(XSL_SHEET_DYNAMIC
-            ));
-
-            if (ui != null && ui.length() > 1)
-                request.setAttribute("ui", ui);
-
-            String staticUI = transformer.transform(
-                new XMLUtils().getNodeXPath(currentUI, "art:static"),
-                "UTF-8",
-                request.getRealPath(XSL_SHEET_STATIC));
-            request.setAttribute("staticui", staticUI);
-
             Map tmpOuts = ad.getOutputModes();
             if (tmpOuts == null || tmpOuts.isEmpty()) {
                 request.setAttribute("furthertargets", true);
@@ -135,3 +96,4 @@
     }
 
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/DescribeUIAction.java	Fri Jan 22 11:28:25 2010 +0000
@@ -0,0 +1,131 @@
+package de.intevation.gnv.action;
+
+import de.intevation.gnv.action.sessionmodel.SessionModel;
+import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
+
+import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
+import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
+
+import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
+
+import de.intevation.gnv.util.ArtifactNamespaceContext;
+import de.intevation.gnv.util.XMLUtils;
+import de.intevation.gnv.util.XSLTransformer;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import javax.xml.xpath.XPathConstants;
+
+import org.apache.log4j.Logger;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+import org.w3c.dom.Node;
+
+/**
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ */
+public class DescribeUIAction extends ArtifactDatabaseActionBase {
+
+    public static final String XPATH_DYNAMIC_UI = "art:dynamic";
+    public static final String XPATH_STATIC_UI  = "art:static";
+
+    public static final String XSL_SHEET_DYNAMIC =
+        "WEB-INF/config/templates/describe-ui.xsl";
+
+    public static final String XSL_SHEET_STATIC =
+        "WEB-INF/config/templates/describe-ui-static.xsl";
+
+    private static Logger logger = Logger.getLogger(DescribeUIAction.class);
+
+
+    public DescribeUIAction() {
+        super();
+    }
+
+
+    @Override
+    public ActionForward execute(
+        ActionMapping       mapping,
+        ActionForm          form,
+        HttpServletRequest  request,
+        HttpServletResponse response
+    ) throws Exception
+    {
+        logger.info("describe user interface");
+        try {
+            // render describe document and create user interface
+            SessionModel sm = SessionModelFactory.getInstance().getSessionModel(
+                request);
+
+            ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory
+                .getInstance().getArtifactDatabaseClient(getLocale(request));
+
+            ArtifactDescription artifactDescription =
+                adc.getCurrentStepDescription(
+                    sm.getSelectedArtifactFactory(),
+                    sm.getCurrentArtifact(),
+                    true);
+
+            Node currentUI = artifactDescription.getCurrentUI();
+            if (currentUI != null) {
+                XSLTransformer transformer = new XSLTransformer();
+
+                String url = response.encodeURL(
+                    mapping.findForward("back").getPath());
+                transformer.addParameter("back-url", url);
+
+                String fisUrl = response.encodeURL(
+                    mapping.findForward("selectfis").getPath());
+                transformer.addParameter("selectfis", fisUrl);
+
+                // fetch dynamic part from describe document and transform it
+                Node dynamicNode = (Node) XMLUtils.xpath(
+                    currentUI,
+                    XPATH_DYNAMIC_UI,
+                    XPathConstants.NODE,
+                    ArtifactNamespaceContext.INSTANCE
+                );
+
+                String ui = transformer.transform(
+                    dynamicNode,
+                    "UTF-8",
+                    request.getRealPath(XSL_SHEET_DYNAMIC
+                ));
+
+                if (ui != null && ui.length() > 1)
+                    request.setAttribute("ui", ui);
+
+                // fetch static part from describe document and transform it
+                Node staticNode = (Node) XMLUtils.xpath(
+                    currentUI,
+                    XPATH_STATIC_UI,
+                    XPathConstants.NODE,
+                    ArtifactNamespaceContext.INSTANCE
+                );
+
+                String staticUI = transformer.transform(
+                    staticNode,
+                    "UTF-8",
+                    request.getRealPath(XSL_SHEET_STATIC));
+
+                if (staticUI != null && staticUI.length() > 1)
+                    request.setAttribute("staticui", staticUI); 
+            }
+
+            return super.execute(mapping, form, request, response);
+        }
+        catch (Exception e) {
+            logger.error(e, e);
+            request.setAttribute(
+                CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID,
+                e.getMessage());
+
+            return super.getExceptionForward(mapping);
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java	Fri Jan 22 09:49:34 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java	Fri Jan 22 11:28:25 2010 +0000
@@ -3,7 +3,19 @@
  */
 package de.intevation.gnv.action;
 
+import de.intevation.gnv.action.sessionmodel.SessionModel;
+import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
+
+import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
+import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
+
+import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter;
+import de.intevation.gnv.artifactdatabase.objects.InputParameter;
+import de.intevation.gnv.artifactdatabase.objects.OutputMode;
+import de.intevation.gnv.artifactdatabase.objects.OutputParameter;
+
 import java.io.OutputStream;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -12,19 +24,11 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.log4j.Logger;
+
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
 
-import de.intevation.gnv.action.sessionmodel.SessionModel;
-import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
-import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
-import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
-import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter;
-import de.intevation.gnv.artifactdatabase.objects.InputParameter;
-import de.intevation.gnv.artifactdatabase.objects.OutputMode;
-import de.intevation.gnv.artifactdatabase.objects.OutputParameter;
-
 /**
  * @author Tim Englich <tim.englich@intevation.de>
  * 
@@ -121,3 +125,4 @@
     }
 
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv/src/main/java/de/intevation/gnv/action/FetchArtifactFactoriesAction.java	Fri Jan 22 09:49:34 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/FetchArtifactFactoriesAction.java	Fri Jan 22 11:28:25 2010 +0000
@@ -3,23 +3,27 @@
  */
 package de.intevation.gnv.action;
 
+import de.intevation.gnv.action.sessionmodel.SessionModel;
+import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
+
+import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
+
+import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
+
 import java.util.Collection;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.log4j.Logger;
+
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
 
-import de.intevation.gnv.action.sessionmodel.SessionModel;
-import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
-import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
-import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
-
 /**
  * @author Tim Englich <tim.englich@intevation.de>
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
  * 
  */
 public class FetchArtifactFactoriesAction extends ArtifactDatabaseActionBase {
@@ -45,19 +49,26 @@
                                  HttpServletResponse response) throws Exception {
         log.debug("ArtifactDatabaseActionBase.execute");
         try {
-            Collection<ArtifactObject> artifactFactories = ArtifactDatabaseClientFactory
-                    .getInstance().getArtifactDatabaseClient(getLocale(request))
+            Collection<ArtifactObject> artifactFactories =
+                ArtifactDatabaseClientFactory.getInstance()
+                    .getArtifactDatabaseClient(getLocale(request))
                     .getArtifactFactories();
-            SessionModel sm = SessionModelFactory.getInstance()
-                    .getSessionModel(request);
+
+            SessionModel sm = SessionModelFactory.getInstance().getSessionModel(
+                request);
+
             sm.setArtifacteFactories(artifactFactories);
+
             return super.execute(mapping, form, request, response);
-        } catch (Exception e) {
+        }
+        catch (Exception e) {
             log.error(e, e);
             request.setAttribute(
-                    CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e
-                            .getMessage());
+                CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID,
+                e.getMessage());
+
             return super.getExceptionForward(mapping);
         }
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java	Fri Jan 22 09:49:34 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java	Fri Jan 22 11:28:25 2010 +0000
@@ -2,6 +2,15 @@
  *
  */
 package de.intevation.gnv.action;
+import de.intevation.gnv.action.sessionmodel.SessionModel;
+import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
+
+import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
+import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
+
+import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
+import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter;
+import de.intevation.gnv.artifactdatabase.objects.InputParameter;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -12,27 +21,18 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.log4j.Logger;
+
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
-import org.w3c.dom.Node;
 
-import de.intevation.gnv.action.sessionmodel.SessionModel;
-import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
-import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
-import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
-import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
-import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet;
-import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter;
-import de.intevation.gnv.artifactdatabase.objects.InputParameter;
-import de.intevation.gnv.util.XMLUtils;
-import de.intevation.gnv.util.XSLTransformer;
 
 /**
  * @author Tim Englich <tim.englich@intevation.de>
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
  * 
  */
-public class NextArtifactStepAction extends ArtifactDatabaseActionBase {
+public class NextArtifactStepAction extends DescribeUIAction {
 
     /**
      * the logger, used to log exceptions and additonaly information
@@ -92,60 +92,28 @@
                         target = ad.getReachableStates().iterator().next();
                     }
     
-                    ArtifactDescription artifactDescription;
                     try {
-                        artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), 
-                                                             sm.getCurrentArtifact(),
-                                                             target, ips);
+                        adc.doNextStep(
+                            sm.getSelectedArtifactFactory(), 
+                            sm.getCurrentArtifact(),
+                            target,
+                            ips
+                        );
                     } catch (Exception e) {
                         log.error(e, e);
                         request.setAttribute(
                                 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e
                                         .getMessage());
-                        artifactDescription = sm.getArtifactDescription();
                     }
     
-                    Node currentUI = artifactDescription.getCurrentUI();
-                    if (currentUI != null){
-                        XSLTransformer transformer = new XSLTransformer();
-                        String url = response.encodeURL(
-                            mapping.findForward("back").getPath());
-                        transformer.addParameter("back-url", url);
-
-                        String fisUrl = response.encodeURL(
-                            mapping.findForward("selectfis").getPath());
-                        transformer.addParameter("selectfis", fisUrl);
-
-                        Node dynamicUINode =  new XMLUtils().getNodeXPath(currentUI,"art:dynamic");
-                        if (dynamicUINode != null){
-                            String ui = transformer.transform(
-                                dynamicUINode,
-                                "UTF-8",
-                                request.getRealPath(XSL_SHEET_DYNAMIC));
-            
-                            if (ui != null && ui.length() > 1)
-                                request.setAttribute("ui", ui);
-                        }
-                        
-                        Node staticUINode = new XMLUtils().getNodeXPath(currentUI, "art:static");
-                        if (staticUINode != null){
-                            String staticUI = transformer.transform(
-                                staticUINode,
-                                "UTF-8",
-                                request.getRealPath(XSL_SHEET_STATIC));
-                            request.setAttribute("staticui", staticUI);
-                        }
-                    }
                     Map tmpOuts = ad.getOutputModes();
                     request.setAttribute(
                         "furthertargets",
                         tmpOuts == null || tmpOuts.isEmpty()
                     );
                 } else {
-                    // statistic abholen und in das sessionmodell schreiben.
-                    ArtifactDescription artifactDescription;
                     try{
-                        artifactDescription = adc.getCurrentStepDescription(
+                        adc.getCurrentStepDescription(
                             sm.getSelectedArtifactFactory(),
                             sm.getCurrentArtifact(),
                             true
@@ -156,43 +124,10 @@
                     } catch (Exception e) {
                         log.error(e, e);
                         request.setAttribute(
-                                CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e
-                                        .getMessage());
-                        artifactDescription = sm.getArtifactDescription();
+                            CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID,
+                            e.getMessage());
                     }
     
-                    Node currentUI = artifactDescription.getCurrentUI();
-                    if (currentUI != null){
-                        XSLTransformer transformer = new XSLTransformer();
-                        String url = response.encodeURL(
-                            mapping.findForward("back").getPath());
-                        transformer.addParameter("back-url", url);
-
-                        String fisUrl = response.encodeURL(
-                            mapping.findForward("selectfis").getPath());
-                        transformer.addParameter("selectfis", fisUrl);
-                        
-                        Node dynamicUINode =  new XMLUtils().getNodeXPath(currentUI,"art:dynamic");
-                        if (dynamicUINode != null){
-                            String ui = transformer.transform(
-                                dynamicUINode,
-                                "UTF-8",
-                                request.getRealPath(XSL_SHEET_DYNAMIC));
-            
-                            if (ui != null && ui.length() > 1)
-                                request.setAttribute("ui", ui);
-                        }
-                        
-                        Node staticUINode = new XMLUtils().getNodeXPath(currentUI, "art:static");
-                        if (staticUINode != null){
-                            String staticUI = transformer.transform(
-                                staticUINode,
-                                "UTF-8",
-                                request.getRealPath(XSL_SHEET_STATIC));
-
-                            request.setAttribute("staticui", staticUI);
-                        }
-                    }
                     request.setAttribute("furthertargets", false);
                 }
             }else{
@@ -205,3 +140,4 @@
     }
 
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv/src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java	Fri Jan 22 09:49:34 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java	Fri Jan 22 11:28:25 2010 +0000
@@ -6,33 +6,24 @@
 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
 
-import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
 
-import de.intevation.gnv.util.ArtifactNamespaceContext;
-import de.intevation.gnv.util.XMLUtils;
-import de.intevation.gnv.util.XSLTransformer;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import javax.xml.xpath.XPathConstants;
-
 import org.apache.log4j.Logger;
 
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
 
-import org.w3c.dom.Node;
+
 /**
  * @author Ingo Weinzierl <ingo.weinzierl@intevation.de>
  *
  */
-public class PreviousArtifactStepAction extends ArtifactDatabaseActionBase {
+public class PreviousArtifactStepAction extends DescribeUIAction {
 
-    public static final String XPATH_DYNAMIC_UI = "art:dynamic";
-    public static final String XPATH_STATIC_UI  = "art:static";
 
     public static final String URL_STATE_KEY = "target";
 
@@ -55,68 +46,29 @@
 
         String id = request.getSession().getId();
 
-        SessionModel session =
-            SessionModelFactory.getInstance().getSessionModel(request);
-
-            // TODO check if target is reachable
-
-            ArtifactDatabaseClientFactory f =
-                ArtifactDatabaseClientFactory.getInstance();
-            ArtifactDatabaseClient client   =
-                f.getArtifactDatabaseClient(getLocale(request));
-
-            ArtifactObject artifactFactory = session.getSelectedArtifactFactory();
-            ArtifactObject currentArtifact = session.getCurrentArtifact();
-
-            String target = (String) request.getParameter(URL_STATE_KEY);
-            logger.debug("Step back to previous state: " + target);
-
-            client.doAdvance(
-                artifactFactory,
-                currentArtifact,
-                target
-            );
-
-            ArtifactDescription description = client.getCurrentStepDescription(
-                artifactFactory,
-                currentArtifact,
-                true
-            );
+        SessionModel session = SessionModelFactory.getInstance().getSessionModel(
+            request);
 
-            Node currentUI = description.getCurrentUI();
-            if (currentUI != null) {
-                XSLTransformer transformer = new XSLTransformer();
-                Node dynamicNode = (Node) XMLUtils.xpath(
-                    currentUI,
-                    XPATH_DYNAMIC_UI,
-                    XPathConstants.NODE,
-                    ArtifactNamespaceContext.INSTANCE
-                );
+        // TODO check if target is reachable
 
-                if (dynamicNode != null) {
-                    String dynamicUI = transformer.transform(
-                        dynamicNode, "UTF-8", request.getRealPath(
-                            "WEB-INF/config/templates/describe-ui.xsl")
-                    );
-                    request.setAttribute("ui", dynamicUI);
-                }
+        ArtifactDatabaseClientFactory f =
+            ArtifactDatabaseClientFactory.getInstance();
+        ArtifactDatabaseClient client   =
+            f.getArtifactDatabaseClient(getLocale(request));
 
-                Node staticNode = (Node) XMLUtils.xpath(
-                    currentUI,
-                    XPATH_STATIC_UI,
-                    XPathConstants.NODE,
-                    ArtifactNamespaceContext.INSTANCE
-                );
+        ArtifactObject artifactFactory = session.getSelectedArtifactFactory();
+        ArtifactObject currentArtifact = session.getCurrentArtifact();
 
-                if (staticNode != null){
-                    String staticUI = transformer.transform(
-                        staticNode, "UTF-8", request.getRealPath(
-                            "WEB-INF/config/templates/describe-ui-static.xsl")
-                    );
-                    request.setAttribute("staticui", staticUI);
-                }
-            }
+        String target = (String) request.getParameter(URL_STATE_KEY);
+        logger.debug("Step back to previous state: " + target);
+
+        client.doAdvance(
+            artifactFactory,
+            currentArtifact,
+            target
+        );
 
         return super.execute(mapping, form, request, response);
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org