changeset 626:61f688a69a55

Split up export modes from output modes. gnv-artifacts/trunk@700 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 23 Feb 2010 11:47:08 +0000
parents 40ead2d2a08d
children c009d8df53aa
files gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/products/timeseries/conf_mesh.xml gnv-artifacts/doc/conf/products/timeseries/conf_timeseriespoint.xml gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultExportMode.java gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultOutputMode.java gnv-artifacts/src/main/java/de/intevation/gnv/state/ExportMode.java gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputMode.java gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java
diffstat 9 files changed, 150 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Mon Feb 22 11:29:34 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Tue Feb 23 11:47:08 2010 +0000
@@ -1,3 +1,26 @@
+2010-02-23  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* doc/conf/products/timeseries/conf_timeseriespoint.xml,
+	  doc/conf/products/timeseries/conf_mesh.xml: Added an export mode section
+	  in output modes and added an export mode 'pdf' for showcase. This work is
+	  necessary to split up output modes (chart, histogram, ...) from export 
+	  modes (pdf, svg, png, ...). GUI components are now able to distinguish
+	  between these modes and render each mode in an own section.
+
+	* src/main/java/de/intevation/gnv/state/OutputStateBase.java: Read export
+	  modes from configuration node.
+
+	* src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java: Write
+	  export modes into describe document.
+
+	* src/main/java/de/intevation/gnv/state/DefaultOutputMode.java,
+	  src/main/java/de/intevation/gnv/state/OutputMode.java: Added export modes
+	  as java.util.List. 'getExportModes()' will deliver this list.
+
+	* src/main/java/de/intevation/gnv/state/DefaultExportMode.java,
+	  src/main/java/de/intevation/gnv/state/ExportMode.java: Object storing
+	  necessary information for export mode.
+
 2010-02-22  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* doc/conf/conf.xml: Restructured configuration of shapfile and template
--- a/gnv-artifacts/doc/conf/products/timeseries/conf_mesh.xml	Mon Feb 22 11:29:34 2010 +0000
+++ b/gnv-artifacts/doc/conf/products/timeseries/conf_mesh.xml	Tue Feb 23 11:47:08 2010 +0000
@@ -214,6 +214,9 @@
                         <inputvalue name="height" type="Integer" value="400"/>
                         <inputvalue name="points" type="Boolean" value="false"/>
                     </parameters>
+                    <exportModes>
+                        <export name="pdf" description="PDF-Export der Daten" mime-type="application/pdf" />
+                    </exportModes>
                 </outputsMode>
                 <outputsMode name="histogram" description="Histogram of the Values" mime-type="image/png">
                     <parameters>
--- a/gnv-artifacts/doc/conf/products/timeseries/conf_timeseriespoint.xml	Mon Feb 22 11:29:34 2010 +0000
+++ b/gnv-artifacts/doc/conf/products/timeseries/conf_timeseriespoint.xml	Tue Feb 23 11:47:08 2010 +0000
@@ -197,11 +197,16 @@
                         <inputvalue name="height" type="Integer" value="400"/>
                         <inputvalue name="points" type="Boolean" value="false"/>
                     </parameters>
+                    <exportModes>
+                        <export name="pdf" description="PDF-Export der Daten" mime-type="application/pdf" />
+                    </exportModes>
                 </outputsMode>
                 <outputsMode name="histogram" description="Histogram of the Values" mime-type="image/png">
                     <parameters>
                         <inputvalue name="width" type="Integer" value="600"/>
                         <inputvalue name="height" type="Integer" value="400"/>
+                        <inputvalue name="bincount" type="Integer" value="7"/>
+                        <inputvalue name="binwidth" type="Integer" value="7"/>
                     </parameters>
                 </outputsMode>
                 <outputsMode name="pdf" description="PDF-Export der Daten" mime-type="application/pdf">
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java	Mon Feb 22 11:29:34 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java	Tue Feb 23 11:47:08 2010 +0000
@@ -36,6 +36,7 @@
 import de.intevation.gnv.artifacts.fis.product.Product;
 import de.intevation.gnv.artifacts.ressource.RessourceFactory;
 import de.intevation.gnv.state.DefaultInputData;
+import de.intevation.gnv.state.ExportMode;
 import de.intevation.gnv.state.InputData;
 import de.intevation.gnv.state.InputValue;
 import de.intevation.gnv.state.OutputMode;
@@ -442,7 +443,7 @@
             ArtifactNamespaceContext.NAMESPACE_URI,
             ArtifactNamespaceContext.NAMESPACE_PREFIX
         );
-
+        
         return document;
     }
 
@@ -774,6 +775,25 @@
                             inputParametersNode.appendChild(inputParameterNode);
                         }
                     }
+
+                    // append export modes
+                    List<ExportMode> exportModes = outputMode.getExportModes();
+                    if (exportModes != null) {
+                        Element exports = creator.create("exports");
+                        outputModeNode.appendChild(exports);
+
+                        for (ExportMode exp: exportModes) {
+                            Element export = creator.create("export");
+                            creator.addAttr(
+                                export, "name", exp.getName());
+                            creator.addAttr(
+                                export, "description", exp.getDescription());
+                            creator.addAttr(
+                                export, "mime-type", exp.getMimeType());
+
+                            exports.appendChild(export);
+                        }
+                    }
                 }
             } else {
                 log.warn("No Outputmodes given.");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultExportMode.java	Tue Feb 23 11:47:08 2010 +0000
@@ -0,0 +1,31 @@
+package de.intevation.gnv.state;
+
+/**
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ */
+public class DefaultExportMode
+implements   ExportMode
+{
+    protected String name;
+    protected String description;
+    protected String mimeType;
+
+    public DefaultExportMode(String name, String description, String mimeType){
+        this.name        = name;
+        this.description = description;
+        this.mimeType    = mimeType;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public String getMimeType() {
+        return mimeType;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultOutputMode.java	Mon Feb 22 11:29:34 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultOutputMode.java	Tue Feb 23 11:47:08 2010 +0000
@@ -1,13 +1,11 @@
-/**
- *
- */
 package de.intevation.gnv.state;
 
 import java.util.Collection;
+import java.util.List;
 
 /**
- * @author Tim Englich <tim.englich@intevation.de>
- * 
+ * @author Tim Englich (tim.englich@intevation.de)
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
  */
 public class DefaultOutputMode implements OutputMode {
 
@@ -19,6 +17,7 @@
     private String description = null;
     private String mimeType = null;
     private Collection<InputValue> inputParameters = null;
+    private List<ExportMode> exportModes;
 
     /**
      * Constructor
@@ -27,13 +26,19 @@
      * @param description
      * @param mimeType
      */
-    public DefaultOutputMode(String name, String description, String mimeType,
-                             Collection<InputValue> inputParameters) {
+    public DefaultOutputMode(
+        String name,
+        String description,
+        String mimeType,
+        Collection<InputValue> inputParameters,
+        List<ExportMode> exportModes)
+    {
         super();
-        this.name = name;
-        this.description = description;
-        this.mimeType = mimeType;
+        this.name            = name;
+        this.description     = description;
+        this.mimeType        = mimeType;
         this.inputParameters = inputParameters;
+        this.exportModes     = exportModes;
     }
 
     /**
@@ -73,4 +78,9 @@
         return this.inputParameters;
     }
 
+    public List<ExportMode> getExportModes() {
+        return exportModes;
+    }
+
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/ExportMode.java	Tue Feb 23 11:47:08 2010 +0000
@@ -0,0 +1,15 @@
+package de.intevation.gnv.state;
+
+import java.io.Serializable;
+
+/**
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ */
+public interface ExportMode
+extends          Serializable
+{
+    public String getName();
+    public String getDescription();
+    public String getMimeType();
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputMode.java	Mon Feb 22 11:29:34 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputMode.java	Tue Feb 23 11:47:08 2010 +0000
@@ -5,6 +5,7 @@
 
 import java.io.Serializable;
 import java.util.Collection;
+import java.util.List;
 
 /**
  * @author Tim Englich <tim.englich@intevation.de>
@@ -19,4 +20,6 @@
     public String getMimeType();
 
     public Collection<InputValue> getInputParameters();
+
+    public List<ExportMode> getExportModes();
 }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java	Mon Feb 22 11:29:34 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java	Tue Feb 23 11:47:08 2010 +0000
@@ -8,8 +8,11 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 
+import javax.xml.xpath.XPathConstants;
+
 import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -17,6 +20,7 @@
 import org.w3c.dom.NodeList;
 
 import de.intevation.artifactdatabase.Config;
+import de.intevation.artifactdatabase.XMLUtils; 
 import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
 import de.intevation.gnv.artifacts.cache.CacheFactory;
@@ -43,6 +47,9 @@
     public static final String XPATH_MIME_TYPE   =
         "/art:action/art:out/art:mime-type/@value";
 
+    public static final String XPATH_EXPORTS =
+        "exportModes/export";
+
     /**
      * The UID of this Class
      */
@@ -115,8 +122,28 @@
                     }
                 }
 
+                // parse export modes
+                List<ExportMode> exportList = null;
+                NodeList exports = (NodeList) XMLUtils.xpath(
+                    currentNode, XPATH_EXPORTS, XPathConstants.NODESET);
+
+                if (exports != null) {
+                    int exportSize   = exports.getLength();
+
+                    exportList = new ArrayList<ExportMode>(exportSize);
+                    for (int k = 0; k < exportSize; k++) {
+                        Element exp    = (Element) exports.item(k);
+                        String expName = exp.getAttribute("name");
+                        String expDesc = exp.getAttribute("description");
+                        String expMime = exp.getAttribute("mime-type");
+
+                        exportList.add(
+                            new DefaultExportMode(expName, expDesc, expMime));
+                    }
+                }
+
                 OutputMode outputMode = new DefaultOutputMode(name,
-                        description, mimeType, inputParameters);
+                        description, mimeType, inputParameters, exportList);
                 log.debug(outputMode.toString());
                 this.outputModes.add(outputMode);
 
@@ -385,3 +412,4 @@
         );
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org