changeset 30:07e9c137a2f1

Added dynamic Outputparameter Support and Outputparameter-manipulation gnv/trunk@134 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 25 Sep 2009 14:24:08 +0000
parents bba8fd97e549
children ad739da2802b
files gnv/Changelog gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/Artifact.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactDescription.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputParameter.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputParameter.java gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp
diffstat 17 files changed, 451 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/Changelog	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/Changelog	Fri Sep 25 14:24:08 2009 +0000
@@ -1,3 +1,45 @@
+2009-09-25  Tim Englich  <tim.englich@intevation.de>
+
+    * src/main/java/de/intevation/gnv/artifactdatabase/objects/Artifact.java Edited, 
+      src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactDescription.java Edietd:
+      Integrated some Method for accessing and Setting OutputModes to an ArtifactDescription.
+       
+    * src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputParameter.java Edited, 
+      src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java Edited, 
+      src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputParameter.java Edited, 
+      src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java Edited: 
+       Adding some Beans and their InterfaceDescription for the Representation of OutputModes
+       supported by an Artifact
+    
+    * src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Edited:
+      Fetsching the OutputMode-Informations from the Describedocument and put them into a Collection
+      of OutputModes. 
+    
+    * src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java  Edited:
+      Restet SessionModel integrated.
+       
+    * src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Edited:
+      Cast for ArtifactDescription removed.
+       
+    * src/main/java/de/intevation/gnv/action/DoOutputAction.java Edited, 
+      src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Edited:
+      Dynamical read of OutputParameter for Outputgeneration 
+    
+    * src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Edited:,
+      src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Edited:
+      Added some Method for retrieving Diagrammoptions and reset the SessionModel
+     
+    * src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java Edited:
+      Dynamic Options Support Added
+      
+    * src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp Edited:
+      Dynamic Rendring of the Outputparameters of an ArtifactoutputType added.
+      Ath this Moment only The Outputparameter for Chart ist provided.
+       
+    * src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp Edited :
+      Integrated dynamic Setting of Diagramm-Parameter to the Link.
+      Also Read MimeType from the OPutputParameters of the Artifact. 
+      
 2009-09-25  Tim Englich  <tim.englich@intevation.de>
 
     * src/main/java/de/intevation/gnv/action/DoOutputAction.java Edited:
--- a/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Fri Sep 25 14:24:08 2009 +0000
@@ -3,6 +3,9 @@
  */
 package de.intevation.gnv.action;
 
+import java.util.Collection;
+import java.util.Iterator;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -12,11 +15,14 @@
 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;
 
@@ -42,10 +48,26 @@
             throws Exception {
         log.debug("NextArtifactStepAction.execute");
         SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
-        ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact();
+        
+        String target = request.getParameter("target");
+        OutputMode outputMode = sm.getOutputMode(target);
+        if (outputMode != null){
+            
+            Collection<OutputParameter> op = outputMode.getOutputParameters();
+            if (op != null){
+                Iterator<OutputParameter> it = op.iterator();
+                DiagrammOptions diagrammOptions = new DiagrammOptions();
+                while (it.hasNext()){
+                    OutputParameter parameter = it.next();
+                    diagrammOptions.setValue(parameter.getName(), request.getParameter(parameter.getName()));
+                    
+                }
+                sm.setDiagrammOptions(diagrammOptions);
+            }
+        }
+        
+        ArtifactDescription ad = sm.getArtifactDescription();
         ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient();
-        
-
         ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact());
         
         Node currentUI = artifactDescription.getCurrentUI();
@@ -56,7 +78,6 @@
         
         String staticUI = transformer.transform(new XMLUtils().getNodeXPath(currentUI, "static"), "UTF-8", request.getRealPath("WEB-INF/config/templates/describe-ui-static.xsl"));
         request.setAttribute("staticui", staticUI);
-        
         request.setAttribute("furthertargets", (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()));
         
         if (ad.getReachableStates() != null && !ad.getReachableStates().isEmpty()){
--- a/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java	Fri Sep 25 14:24:08 2009 +0000
@@ -23,6 +23,8 @@
 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
 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>
@@ -59,30 +61,38 @@
         // TODO Check if is propper;
         
         SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
-        ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact();
-        Collection<String> inputParameter = ad.getInputParameter();
-        Collection<InputParameter> ips = null;
-        if (inputParameter != null){
-            ips = new ArrayList<InputParameter>(inputParameter.size());
-            Iterator<String> it = inputParameter.iterator();
-            while (it.hasNext()){
-                String name = it.next();
-                String[] values = request.getParameterValues(name);
-                InputParameter ip = new DefaultInputParameter(name, values);
-                ips.add(ip);
+        OutputMode outputMode =  sm.getOutputMode(target);
+        if (outputMode != null && outputMode.getMimeType().equals(mimeType)){
+            Collection<OutputParameter> inputParameter =outputMode.getOutputParameters();
+            Collection<InputParameter> ips = null;
+            if (inputParameter != null){
+                ips = new ArrayList<InputParameter>(inputParameter.size());
+                Iterator<OutputParameter> it = inputParameter.iterator();
+                while (it.hasNext()){
+                    String name = it.next().getName();
+                    String[] values = request.getParameterValues(name);
+                    InputParameter ip = new DefaultInputParameter(name, values);
+                    ips.add(ip);
+                }
             }
+            
+            ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient();
+            
+            this.setHeaders(target, mimeType, response, request);
+            
+            OutputStream outputStream = response.getOutputStream();
+            adc.doOutput(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), outputStream, target, mimeType, ips);
+            
+            outputStream.flush();
+            outputStream.close();
+        }else{
+            if (outputMode == null){
+                log.error("Outputmode wird nicht unterstützt.");
+            }else if (!outputMode.getMimeType().equals(mimeType)){
+                log.error("MimeType "+mimeType+" wird nicht unterstützt.");
+            }
+            // TODO FIXME: Fehlerbehandlung
         }
-        
-        ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance().getArtifactDatabaseClient();
-        
-        this.setHeaders(target, mimeType, response, request);
-        
-        OutputStream outputStream = response.getOutputStream();
-        adc.doOutput(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact(), outputStream, target, mimeType, ips);
-        
-        outputStream.flush();
-        outputStream.close();
-        
         return super.execute(mapping, form, request, response);
     }
     
--- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java	Fri Sep 25 14:24:08 2009 +0000
@@ -52,7 +52,7 @@
             throws Exception {
         log.debug("NextArtifactStepAction.execute");
         SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
-        ArtifactDescription ad = (ArtifactDescription)sm.getCurrentArtifact();
+        ArtifactDescription ad = sm.getArtifactDescription();
         Collection<String> inputParameter = ad.getInputParameter();
         Collection<InputParameter> ips = null;
         if (inputParameter != null){
--- a/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/SelectArtifactFactoryAction.java	Fri Sep 25 14:24:08 2009 +0000
@@ -45,6 +45,8 @@
         
         SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
         Collection<ArtifactObject> artifactFactories = sm.getArtifactFactories();
+        // Löscht die Artifactspezifischen Attribute am Sessionmodel
+        sm.resetModel();
         if (artifactFactories == null || artifactFactories.isEmpty()){
             new FetchArtifactFactoriesAction().execute(mapping, form, request, response);
            
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java	Fri Sep 25 14:24:08 2009 +0000
@@ -6,7 +6,11 @@
 import java.util.Collection;
 import java.util.Iterator;
 
+import org.apache.log4j.Logger;
+
+import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
+import de.intevation.gnv.artifactdatabase.objects.OutputMode;
 
 /**
  * @author Tim Englich <tim.englich@intevation.de>
@@ -15,7 +19,15 @@
 public class DefaultSessionModel implements SessionModel{
 
 
+    /**
+     * the logger, used to log exceptions and additonaly information
+     */
+    private static Logger log = Logger.getLogger(DefaultSessionModel.class);
 
+    /**
+     * The UID of this Class.
+     */
+    private static final long serialVersionUID = 3431484439985158311L;
 
     private Collection<ArtifactObject> artifactFactories = null;
     
@@ -91,14 +103,52 @@
     public void setCurrentArtifact(ArtifactObject artifact) {
         this.currentArtifact = artifact;
     }
-    
+
+    /**
+     * @see de.intevation.gnv.action.sessionmodel.SessionModel#getDiagrammOptions()
+     */
     public DiagrammOptions getDiagrammOptions() {
-        if (diagrammOptions == null){
-            diagrammOptions = new DiagrammOptions();
+        return this.diagrammOptions;
+    }
+
+    /**
+     * @see de.intevation.gnv.action.sessionmodel.SessionModel#setDiagrammOptions(de.intevation.gnv.action.sessionmodel.DiagrammOptions)
+     */
+    public void setDiagrammOptions(DiagrammOptions diagrammOptions) {
+        this.diagrammOptions = diagrammOptions;
+    }
+
+    /**
+     * @see de.intevation.gnv.action.sessionmodel.SessionModel#getArtifactDescription()
+     */
+    public ArtifactDescription getArtifactDescription() {
+        if (this.currentArtifact != null){
+            return (ArtifactDescription)this.currentArtifact;
         }
-        return diagrammOptions;
+        return null;
+    }
+
+    /**
+     * @see de.intevation.gnv.action.sessionmodel.SessionModel#getOutputMode(java.lang.String)
+     */
+    public OutputMode getOutputMode(String name) {
+        ArtifactDescription ad = this.getArtifactDescription();
+        if (ad != null){
+            if (ad.getOutputModes() != null){
+                return ad.getOutputModes().get(name);
+            }
+        }
+        return null;
     }
     
-    
-
+    /**
+     * @see de.intevation.gnv.action.sessionmodel.SessionModel#resetModel()
+     */
+    public void resetModel() {
+        log.debug("DefaultSessionModel.resetModel");
+        selectedArtifactFactory = null;
+        currentArtifact  =null;
+        diagrammOptions= null;
+       
+    }
 }
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DiagrammOptions.java	Fri Sep 25 14:24:08 2009 +0000
@@ -2,6 +2,10 @@
  *
  */
 package de.intevation.gnv.action.sessionmodel;
+
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * @author Tim Englich <tim.englich@intevation.de>
  *
@@ -9,14 +13,7 @@
 public class DiagrammOptions {
 
     
-    public enum mode{
-        Standard,
-        User_Specific
-    }
-    
-    private mode modus = mode.Standard;
-    
-    private int width = 500;
+    private Map<String, String> values = new HashMap<String, String>();
     /**
      * Constructor
      */
@@ -24,32 +21,19 @@
         super();
     }
     
+
     /**
      * @return
      */
-    public mode getModus() {
-        return modus;
-    }
-    
-    /**
-     * @param modus
-     */
-    public void setModus(mode modus) {
-        this.modus = modus;
-    }
-    
-    /**
-     * @return
-     */
-    public int getWidth() {
-        return width;
+    public String getValue(String key) {
+        return this.values.get(key);
     }
     
     /**
      * @param width
      */
-    public void setWidth(int width) {
-        this.width = width;
+    public void setValue(String key, String value) {
+       this.values.put(key, value);
     }
 
 }
\ No newline at end of file
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java	Fri Sep 25 14:24:08 2009 +0000
@@ -3,15 +3,18 @@
  */
 package de.intevation.gnv.action.sessionmodel;
 
+import java.io.Serializable;
 import java.util.Collection;
 
+import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
+import de.intevation.gnv.artifactdatabase.objects.OutputMode;
 
 /**
  * @author Tim Englich <tim.englich@intevation.de>
  *
  */
-public interface SessionModel {
+public interface SessionModel extends Serializable{
     
     Collection<ArtifactObject> getArtifactFactories();
     
@@ -25,6 +28,14 @@
     
     void setCurrentArtifact(ArtifactObject artifact);
     
+    void setDiagrammOptions(DiagrammOptions diagrammOptions);
+    
     DiagrammOptions getDiagrammOptions();
+    
+    OutputMode getOutputMode(String name);
+    
+    ArtifactDescription getArtifactDescription();
+    
+    void resetModel();
 
 }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Fri Sep 25 14:24:08 2009 +0000
@@ -8,7 +8,9 @@
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
 
 import org.apache.log4j.Logger;
 import org.restlet.Client;
@@ -28,7 +30,11 @@
 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
+import de.intevation.gnv.artifactdatabase.objects.DefaultOutputMode;
+import de.intevation.gnv.artifactdatabase.objects.DefaultOutputParameter;
 import de.intevation.gnv.artifactdatabase.objects.InputParameter;
+import de.intevation.gnv.artifactdatabase.objects.OutputMode;
+import de.intevation.gnv.artifactdatabase.objects.OutputParameter;
 import de.intevation.gnv.propertiesreader.PropertiesReader;
 import de.intevation.gnv.propertiesreader.PropertiesReaderFactory;
 import de.intevation.gnv.util.XMLUtils;
@@ -289,6 +295,32 @@
             ArtifactDescription ad = (ArtifactDescription)artifact;
             Node uiNode =  xmlUtils.getNodeXPath(document, "/result/ui");
             Node outputNode = xmlUtils.getNodeXPath(document, "/result/outputs");
+            
+            Map<String, OutputMode> outputModes = null;
+            if (outputNode != null){
+                NodeList outputModesNodes = xmlUtils.getNodeSetXPath(outputNode, "output");
+                if (outputModesNodes != null){
+                    outputModes = new HashMap<String, OutputMode>(outputModesNodes.getLength());
+                    for (int i = 0; i < outputModesNodes.getLength(); i++){
+                        Node outputModeNode = outputModesNodes.item(i);
+                        String name = xmlUtils.getStringXPath(outputModeNode, "@name");
+                        String mimeType = xmlUtils.getStringXPath(outputModeNode, "@mime-type");
+                        
+                        NodeList parameterNodes = xmlUtils.getNodeSetXPath(outputModeNode, "parameter/parameter");
+                        Collection<OutputParameter> parameter = null;
+                        if (parameterNodes != null){
+                            parameter = new ArrayList<OutputParameter>(parameterNodes.getLength());
+                            for (int j = 0; j < parameterNodes.getLength(); j++){
+                                Node outputParameterNode =  parameterNodes.item(j);
+                                parameter.add(new DefaultOutputParameter(xmlUtils.getStringXPath(outputParameterNode,"@name"),xmlUtils.getStringXPath(outputParameterNode,"@value"),xmlUtils.getStringXPath(outputParameterNode,"@name"),xmlUtils.getStringXPath(outputParameterNode,"@type")));
+                            }
+                        }
+                        outputModes.put(name,new DefaultOutputMode(name, mimeType, parameter));
+                    }
+                    
+                }
+            }
+            
             String currentState = xmlUtils.getStringXPath(document, "/result/state/@name");
             NodeList statesList = xmlUtils.getNodeSetXPath(document, "/result/reachable-states/state/@name");
             Collection<String> reachableStates = new ArrayList<String>(statesList.getLength());
@@ -307,6 +339,7 @@
                 ad.setInputParameter(inputParameter);
             }
             
+            ad.setOutputModes(outputModes);
             ad.setCurrentOut(outputNode);
             ad.setCurrentUI(uiNode);
             ad.setCurrentState(currentState);
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/Artifact.java	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/Artifact.java	Fri Sep 25 14:24:08 2009 +0000
@@ -4,6 +4,7 @@
 package de.intevation.gnv.artifactdatabase.objects;
 
 import java.util.Collection;
+import java.util.Map;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -23,6 +24,7 @@
     
     private Collection<String> reachableStates;
     private Collection<String> inputParameter;
+    private Map<String,OutputMode> outputModes;
     private String currentState = null;
     
     /**
@@ -146,4 +148,27 @@
         this.inputParameter = inputParameter;
     }
 
+    /**
+     * @see de.intevation.gnv.artifactdatabase.objects.ArtifactDescription#getOutputModes()
+     */
+    public Map<String, OutputMode> getOutputModes() {
+        return this.outputModes;
+    }
+    
+    /**
+     * @see de.intevation.gnv.artifactdatabase.objects.ArtifactDescription#getOutputModesAsCollection()
+     */
+    public Collection<OutputMode> getOutputModesAsCollection() {
+        if (this.outputModes != null){
+            return this.outputModes.values();
+        }
+        return null;
+    }
+
+    /**
+     * @see de.intevation.gnv.artifactdatabase.objects.ArtifactDescription#setOutputModes(java.util.Map)
+     */
+    public void setOutputModes(Map<String, OutputMode> outputModes) {
+        this.outputModes = outputModes;
+    }
 }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactDescription.java	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactDescription.java	Fri Sep 25 14:24:08 2009 +0000
@@ -4,6 +4,7 @@
 package de.intevation.gnv.artifactdatabase.objects;
 
 import java.util.Collection;
+import java.util.Map;
 
 import org.w3c.dom.Node;
 
@@ -52,6 +53,24 @@
      */
     public Collection<String> getInputParameter();
     
+    /**
+     * @param inputParameter
+     */
     public void setInputParameter(Collection<String> inputParameter);
+    
+    /**
+     * @return the reachableStates
+     */
+    public Map<String, OutputMode> getOutputModes();
+    
+    /**
+     * @return the reachableStates
+     */
+    public Collection<OutputMode> getOutputModesAsCollection();
+    
+    /**
+     * @param outputParameter
+     */
+    public void setOutputModes(Map<String, OutputMode> outputModes);
 
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java	Fri Sep 25 14:24:08 2009 +0000
@@ -0,0 +1,51 @@
+/**
+ *
+ */
+package de.intevation.gnv.artifactdatabase.objects;
+
+import java.util.Collection;
+
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public class DefaultOutputMode implements OutputMode {
+
+    
+    private String name = null;
+    
+    private String mimeType = null;
+    
+    private Collection<OutputParameter> outputParameter = null;
+
+    public DefaultOutputMode(String name, String mimeType,
+            Collection<OutputParameter> outputParameter) {
+        super();
+        this.name = name;
+        this.mimeType = mimeType;
+        this.outputParameter = outputParameter;
+    }
+
+
+    /**
+     * @see de.intevation.gnv.artifactdatabase.objects.OutputMode#getMimeType()
+     */
+    public String getMimeType() {
+        return this.mimeType;
+    }
+
+    /**
+     * @see de.intevation.gnv.artifactdatabase.objects.OutputMode#getName()
+     */
+    public String getName() {
+        return this.name;
+    }
+    
+    /**
+     * @see de.intevation.gnv.artifactdatabase.objects.OutputMode#getOutputParameters()
+     */
+    public Collection<OutputParameter> getOutputParameters() {
+        return this.outputParameter;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputParameter.java	Fri Sep 25 14:24:08 2009 +0000
@@ -0,0 +1,56 @@
+/**
+ *
+ */
+package de.intevation.gnv.artifactdatabase.objects;
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public class DefaultOutputParameter implements OutputParameter {
+
+    
+    private String name = null;
+    
+    private String value = null;
+    
+    private String description = null;
+    
+    private String type = null;
+    
+    /**
+     * Constructor
+     * @param name
+     * @param value
+     * @param description
+     */
+    public DefaultOutputParameter(String name, String value, String description, String type) {
+        super();
+        this.name = name;
+        this.value = value;
+        this.description = description;
+        this.type = type;
+    }
+
+    /**
+     * @see de.intevation.gnv.artifactdatabase.objects.OutputParameter#getName()
+     */
+    public String getName() {
+        return this.name;
+    }
+
+    /**
+     * @see de.intevation.gnv.artifactdatabase.objects.OutputParameter#getValue()
+     */
+    public String getValue() {
+        return this.value;
+    }
+
+    public String getDescription() {
+        return this.description;
+    }
+
+    public String getType() {
+        return this.type;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java	Fri Sep 25 14:24:08 2009 +0000
@@ -0,0 +1,20 @@
+/**
+ *
+ */
+package de.intevation.gnv.artifactdatabase.objects;
+
+import java.util.Collection;
+
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public interface OutputMode {
+    
+    public String getName();
+    
+    public String getMimeType();
+    
+    public Collection<OutputParameter > getOutputParameters();
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputParameter.java	Fri Sep 25 14:24:08 2009 +0000
@@ -0,0 +1,17 @@
+/**
+ *
+ */
+package de.intevation.gnv.artifactdatabase.objects;
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public interface OutputParameter {
+    
+    
+    String getName();
+    String getValue();
+    String getDescription();
+    String getType();
+
+}
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp	Fri Sep 25 14:24:08 2009 +0000
@@ -1,28 +1,49 @@
 <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
 <%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%>
+<%@page import="de.intevation.gnv.action.sessionmodel.SessionModel"%>
+<%@page import="de.intevation.gnv.action.sessionmodel.DiagrammOptions"%>
+<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%>
+<%@page import="java.util.Collection"%>
+<%@page import="java.util.Iterator"%>
 <%Object diagramm = request.getAttribute("diagramm");
+SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
 if (diagramm != null){
-    
     String target = "chart"; 
     String targetCSV = "csv";
-    boolean supportCSV = true; // TODO get from SessionModel
-    String mimeType = "image/png";// TODO: get from SessionModel SessionModelFactory.getInstance().getSessionModel(request).
-    String mimeTypeCSV = "text/plain";// TODO: get from SessionModel SessionModelFactory.getInstance().getSessionModel(request).
+    boolean supportChart = sm.getOutputMode(target) != null;
+    boolean supportCSV = sm.getOutputMode(targetCSV) != null;
+    String mimeType = null;
+    String parameterString = "";
+    if (supportChart){
+       mimeType = sm.getOutputMode(target).getMimeType();
+       DiagrammOptions diagrammOptions = sm.getDiagrammOptions();
+       Collection<OutputParameter> op = sm.getOutputMode(target).getOutputParameters();
+       if (op != null){
+           Iterator<OutputParameter> it = op.iterator();
+           while (it.hasNext()){
+               OutputParameter parameter = it.next(); 
+               parameterString = parameterString +"&"+parameter.getName()+"="+(diagrammOptions != null ? diagrammOptions.getValue(parameter.getName()): parameter.getValue());
+           }
+       }
+    }
+    String mimeTypeCSV = null;
+    if (supportCSV){
+        mimeTypeCSV = sm.getOutputMode(targetCSV).getMimeType();
+    }
 %>
-    
-    <div id="diagram">
-        <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&target="+target+"&uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.diagramm.alt"/>'/>
+<div id="diagram">
+        <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&target="+target+parameterString+"&uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.diagramm.alt"/>'/>
         <br/>
         <div id="export">
-            <a href="<%=response.encodeURL("export.do?mimetype="+mimeType+"&target="+target+"&uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>">
+            <a href="<%=response.encodeURL("export.do?mimetype="+mimeType+"&target="+target+parameterString+"&uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>">
                 <img src="images/diagram_export.png" border="0"/>
             </a>
             <%if (supportCSV) { %>
-            <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeCSV+"&target="+targetCSV+"&uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.title"/>">
+            <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeCSV+"&target="+targetCSV+"+uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.title"/>">
                 <img src="images/data_export.png" border="0"/>
             </a>
             <%}%>
         </div>
+        <jsp:include page="/WEB-INF/jsp/includes/display_diagramm_adons_inc.jsp"></jsp:include>
     </div>
-    <jsp:include page="/WEB-INF/jsp/includes/display_diagramm_adons_inc.jsp"></jsp:include>
 <%}%>
\ No newline at end of file
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp	Fri Sep 25 14:24:08 2009 +0000
@@ -1,33 +1,33 @@
 <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
 <%@page import="de.intevation.gnv.action.sessionmodel.DiagrammOptions"%>
 <%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%>
-<%@page import="de.intevation.gnv.action.sessionmodel.DiagrammOptions.mode"%>
+<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputMode"%>
+<%@page import="de.intevation.gnv.action.sessionmodel.SessionModel"%>
+<%@page import="java.util.Collection"%>
+<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%>
+<%@page import="java.util.Iterator"%>
 <%
-  DiagrammOptions diagrammOptions = SessionModelFactory.getInstance().getSessionModel(request).getDiagrammOptions();
-  boolean isStandard = diagrammOptions.getModus() == DiagrammOptions.mode.Standard;
+  SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
+  DiagrammOptions diagrammOptions = sm.getDiagrammOptions();
+  boolean useDiagrammOptions = diagrammOptions != null;
+  String target = "chart";
+  OutputMode outputMode = sm.getOutputMode(target);
 %>
-
 <div id="diagramOptionsContent">
     <fieldset>
         <legend onmousedown="displayDiv('diagramOptionsContent');" class="expandableFieldset">
            <bean:message key="gnviewer.diagram.options.header.title"/>
         </legend>
         <form id="outputOptionsForm" method="post" action="changeOptions.do">
-           <input name="overrideSize" value="false" <%=isStandard ? "checked=\"checked\"" : "" %>onblur="document.forms.outputOptionsForm.submit()" type="radio">
-           <label for="overrideSize">
-                <bean:message key="gnviewer.diagram.options.size.fix"/>
-            </label>
-            <br>
-            <input name="overrideSize" value="true" <%=!isStandard ? "checked=\"checked\"" : "" %> onblur="document.forms.outputOptionsForm.submit()" type="radio">
-            <label for="overrideSize">
-                 <bean:message key="gnviewer.diagram.options.size.relative"/>
-            </label>
-            <label for="overridenWidth">
-                <bean:message key="gnviewer.diagram.options.size.text"/>
-            </label>
-            <input name="overridenWidth" value="<%=diagrammOptions.getWidth()%>" onblur="document.forms.outputOptionsForm.submit()" type="text">
-            <br/>
-            <span style="color: red;"></span>
+           <%if (outputMode != null && outputMode.getOutputParameters() != null && !outputMode.getOutputParameters().isEmpty()){
+               Iterator<OutputParameter> it = outputMode.getOutputParameters().iterator();
+               while (it.hasNext()){
+                   OutputParameter om = it.next(); %>
+               <%=om.getDescription()%>: <input type="text" name="<%=om.getName() %>"value="<%=useDiagrammOptions ? diagrammOptions.getValue(om.getName()): om.getValue()%>"/><br/>
+           <%}%>
+           <input type="hidden" name="target" value="<%=target%>"/>
+           <input type="submit" value="<bean:message key="gnviewer.select.button"/>"/>
+           <%}%>
         </form>
     </fieldset>
 </div>
\ No newline at end of file

http://dive4elements.wald.intevation.org