changeset 812:41a7c49b5cb4

ISSUE 215 msg1170: Integrated additional Column into the ODV-Export to identify TimeSeries gnv-artifacts/trunk@896 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 09 Apr 2010 13:00:38 +0000
parents df6d980c5418
children 79c1db3ca7cc
files gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/products/timeseries/conf_mesh.xml gnv-artifacts/src/main/java/de/intevation/gnv/exports/ODVExport.java gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java
diffstat 4 files changed, 107 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Fri Apr 09 10:46:31 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Fri Apr 09 13:00:38 2010 +0000
@@ -1,3 +1,21 @@
+2010-04-09  Tim Englich  <tim.englich@intevation.de>
+
+	  ISSUE 215 msg1170
+
+	* src/main/java/de/intevation/gnv/exports/ODVExport.java : 
+	  Modified ODV-Export that it is possible to integrate an Timestamp which
+	  identifies a TimeSeries.
+	  The additional Column will only be integrated if the given Timestamp has 
+	  an value and is not null.
+	* src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java (getStartTime): 
+	  Integrated Method for lookup the Starttimevalue of an TimeSeries to use it
+	  in ODV-Exports. If no Startdate is stored (e.g. if this Methos is called
+	  by an verticalProfileOutputstate) null will be returned an put into the 
+	  ODV-Export.
+	* doc/conf/products/timeseries/conf_mesh.xml: 
+	  Added valuename for the Timeinterval to fetch the Starttime of an TimeSeries 
+	  from the inputData to integrate it into the ODV-Export.
+
 2010-04-09  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java,
--- a/gnv-artifacts/doc/conf/products/timeseries/conf_mesh.xml	Fri Apr 09 10:46:31 2010 +0000
+++ b/gnv-artifacts/doc/conf/products/timeseries/conf_mesh.xml	Fri Apr 09 13:00:38 2010 +0000
@@ -253,6 +253,7 @@
                 <value-name name="feature" value="mesh_point"></value-name>
                 <value-name name="parameter" value="parameterid"></value-name>
                 <value-name name="measurement" value="depthid"></value-name>
+                <value-name name="timeinterval" value="timeinterval"></value-name>
             </value-names>
             <outputsModes>
                 <outputsMode name="chart" description="Chartrepresentation of the Values" mime-type="image/png">
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/ODVExport.java	Fri Apr 09 10:46:31 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/ODVExport.java	Fri Apr 09 13:00:38 2010 +0000
@@ -30,16 +30,26 @@
      * Collection of parameters.
      */
     private Collection parameters = null;
+    
+    /**
+     * The TimeStime which should be integrated in the Export to mark a
+     * TimeSeries.
+     */
+    private String startTime = null;
 
     /**
      * Constructor
      * @param collector DataCollector used to extract the required data.
      * @param parameters A collection of parameters to be displayed in the
      * export.
+     * @param startTime The TimeStamp which should ne integrated in the export 
+     * to mark a TimeSeries. If it should not be a TimeSeries this Value must 
+     * be null.
      */
-    public ODVExport(DataCollector collector, Collection parameters) {
+    public ODVExport(DataCollector collector, Collection parameters, String startTime) {
         super(collector);
         this.parameters = parameters;
+        this.startTime = startTime;
     }
 
     /**
@@ -56,6 +66,10 @@
         for (int i= 0; i < header.length; i++){
             headerList.add(header[i]);
         }
+        
+        if (this.startTime != null){
+            headerList.add("time_ISO8601");
+        }
         ArrayList<String> paramids = new ArrayList<String>();
 
         Map<StringArrayKey, Map<String,String>> aggregatedRows = new HashMap<StringArrayKey, Map<String,String>>();
@@ -100,6 +114,9 @@
             for (int i= 0; i < rowArray.length; i++){
                 rowList.add(rowArray[i]);
             }
+            if (this.startTime != null){
+                rowList.add(this.startTime);
+            }
             for (int i = 0; i < paramids.size();i++){
                 String key = paramids.get(i);
                 String value = params.get(key);
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java	Fri Apr 09 10:46:31 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java	Fri Apr 09 13:00:38 2010 +0000
@@ -1,67 +1,8 @@
 package de.intevation.gnv.state.timeseries;
 
-import au.com.bytecode.opencsv.CSVWriter;
-
-import de.intevation.artifactdatabase.Config;
-import de.intevation.artifactdatabase.XMLUtils;
-
-import de.intevation.artifacts.ArtifactNamespaceContext;
-import de.intevation.artifacts.CallContext;
-import de.intevation.artifacts.CallMeta;
-
-import de.intevation.gnv.artifacts.context.GNVArtifactContext;
-
-import de.intevation.gnv.artifacts.ressource.RessourceFactory;
-
-import de.intevation.gnv.chart.Chart;
-import de.intevation.gnv.chart.ChartLabels;
-import de.intevation.gnv.chart.DefaultHistogram;
-import de.intevation.gnv.chart.TimeSeriesChart;
-import de.intevation.gnv.chart.XMLChartTheme;
-
-import de.intevation.gnv.chart.exception.TechnicalChartException;
-
-import de.intevation.gnv.exports.ChartExportHelper;
-import de.intevation.gnv.exports.DefaultDataCollector;
-import de.intevation.gnv.exports.DefaultExport;
-import de.intevation.gnv.exports.DefaultProfile;
-
-import de.intevation.gnv.exports.Export.Profile;
-
-import de.intevation.gnv.exports.Export;
-import de.intevation.gnv.exports.ODVExport;
-import de.intevation.gnv.exports.SimpleOdvDataCollector;
-
-import de.intevation.gnv.geobackend.base.Result;
-
-import de.intevation.gnv.histogram.HistogramHelper;
-
-import de.intevation.gnv.state.InputData;
-import de.intevation.gnv.state.OutputStateBase;
-
-import de.intevation.gnv.state.describedata.DefaultKeyValueDescribeData;
-import de.intevation.gnv.state.describedata.KeyValueDescibeData;
-import de.intevation.gnv.state.describedata.NamedArrayList;
-import de.intevation.gnv.state.describedata.NamedCollection;
-
-import de.intevation.gnv.state.exception.StateException;
-
-import de.intevation.gnv.statistics.Statistic;
-import de.intevation.gnv.statistics.StatisticSet;
-import de.intevation.gnv.statistics.Statistics;
-import de.intevation.gnv.statistics.TimeseriesStatistics;
-
-import de.intevation.gnv.statistics.exception.StatisticsException;
-
-import de.intevation.gnv.timeseries.gap.DefaultTimeGap;
-import de.intevation.gnv.timeseries.gap.TimeGap;
-
-import de.intevation.gnv.utils.ArtifactXMLUtilities;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -72,14 +13,53 @@
 import java.util.Vector;
 
 import org.apache.log4j.Logger;
-
 import org.jfree.chart.ChartTheme;
-
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import au.com.bytecode.opencsv.CSVWriter;
+import de.intevation.artifactdatabase.Config;
+import de.intevation.artifactdatabase.XMLUtils;
+import de.intevation.artifacts.ArtifactNamespaceContext;
+import de.intevation.artifacts.CallContext;
+import de.intevation.artifacts.CallMeta;
+import de.intevation.gnv.artifacts.context.GNVArtifactContext;
+import de.intevation.gnv.artifacts.ressource.RessourceFactory;
+import de.intevation.gnv.chart.Chart;
+import de.intevation.gnv.chart.ChartLabels;
+import de.intevation.gnv.chart.DefaultHistogram;
+import de.intevation.gnv.chart.TimeSeriesChart;
+import de.intevation.gnv.chart.XMLChartTheme;
+import de.intevation.gnv.chart.exception.TechnicalChartException;
+import de.intevation.gnv.exports.ChartExportHelper;
+import de.intevation.gnv.exports.DefaultDataCollector;
+import de.intevation.gnv.exports.DefaultExport;
+import de.intevation.gnv.exports.DefaultProfile;
+import de.intevation.gnv.exports.Export;
+import de.intevation.gnv.exports.ODVExport;
+import de.intevation.gnv.exports.SimpleOdvDataCollector;
+import de.intevation.gnv.exports.Export.Profile;
+import de.intevation.gnv.geobackend.base.Result;
+import de.intevation.gnv.histogram.HistogramHelper;
+import de.intevation.gnv.state.InputData;
+import de.intevation.gnv.state.OutputStateBase;
+import de.intevation.gnv.state.describedata.DefaultKeyValueDescribeData;
+import de.intevation.gnv.state.describedata.KeyValueDescibeData;
+import de.intevation.gnv.state.describedata.MinMaxDescribeData;
+import de.intevation.gnv.state.describedata.NamedArrayList;
+import de.intevation.gnv.state.describedata.NamedCollection;
+import de.intevation.gnv.state.exception.StateException;
+import de.intevation.gnv.statistics.Statistic;
+import de.intevation.gnv.statistics.StatisticSet;
+import de.intevation.gnv.statistics.Statistics;
+import de.intevation.gnv.statistics.TimeseriesStatistics;
+import de.intevation.gnv.statistics.exception.StatisticsException;
+import de.intevation.gnv.timeseries.gap.DefaultTimeGap;
+import de.intevation.gnv.timeseries.gap.TimeGap;
+import de.intevation.gnv.utils.ArtifactXMLUtilities;
+
 /**
  * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
@@ -135,6 +115,7 @@
     protected String parameterValuesName = "parameterid";
     protected String measuremenValueName = "measurementid";
     protected String dateValueName = "dateid";
+    protected String timeIntervalValueName = "timeinterval";
 
 
     /**
@@ -634,7 +615,8 @@
 
         Export export = new ODVExport(new SimpleOdvDataCollector(
             TIMESERIES_ODV_PROFILE_NAMES),
-            this.getParameters(uuid));
+            this.getParameters(uuid),
+            this.getStartTime());
 
         if (result == null)
             log.error("#################### RESULT == NULL #################");
@@ -642,6 +624,27 @@
     }
 
     /**
+     * Method that returns the Starttime of an TimeSeries or
+     * null if it is not a TimeSeries.
+     * @return the Starttime of an TimeSeries or null if it is not a TimeSeries.
+     */
+    protected String getStartTime(){
+        InputData data = inputData.get(this.timeIntervalValueName);
+        if (data != null){
+            Object describeData = data.getObject();
+            if (describeData instanceof MinMaxDescribeData){
+                return (((MinMaxDescribeData)describeData).
+                        getMinValue()+".0").
+                        replace(' ','T');
+            }
+            return null;
+        }else{
+            return null;
+        }
+        
+    }
+
+    /**
      * Returns the statistic generator.
      *
      * @return the statistic generator.
@@ -1157,6 +1160,11 @@
         if (measurementNameValue != null) {
             this.measuremenValueName = measurementNameValue;
         }
+        String timeIntervalValue = Config.getStringXPath(configuration,
+                "value-names/value-name[@name='timeinterval']/@value");
+        if (timeIntervalValue != null){
+            this.timeIntervalValueName = timeIntervalValue;
+        }
 
         String dateNameValue = Config.getStringXPath(configuration,
         "value-names/value-name[@name='date']/@value");

http://dive4elements.wald.intevation.org