diff gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java @ 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 bb7afd783321
children cda3bede32f8
line wrap: on
line diff
--- 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