comparison 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
comparison
equal deleted inserted replaced
811:df6d980c5418 812:41a7c49b5cb4
1 package de.intevation.gnv.state.timeseries; 1 package de.intevation.gnv.state.timeseries;
2
3 import au.com.bytecode.opencsv.CSVWriter;
4
5 import de.intevation.artifactdatabase.Config;
6 import de.intevation.artifactdatabase.XMLUtils;
7
8 import de.intevation.artifacts.ArtifactNamespaceContext;
9 import de.intevation.artifacts.CallContext;
10 import de.intevation.artifacts.CallMeta;
11
12 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
13
14 import de.intevation.gnv.artifacts.ressource.RessourceFactory;
15
16 import de.intevation.gnv.chart.Chart;
17 import de.intevation.gnv.chart.ChartLabels;
18 import de.intevation.gnv.chart.DefaultHistogram;
19 import de.intevation.gnv.chart.TimeSeriesChart;
20 import de.intevation.gnv.chart.XMLChartTheme;
21
22 import de.intevation.gnv.chart.exception.TechnicalChartException;
23
24 import de.intevation.gnv.exports.ChartExportHelper;
25 import de.intevation.gnv.exports.DefaultDataCollector;
26 import de.intevation.gnv.exports.DefaultExport;
27 import de.intevation.gnv.exports.DefaultProfile;
28
29 import de.intevation.gnv.exports.Export.Profile;
30
31 import de.intevation.gnv.exports.Export;
32 import de.intevation.gnv.exports.ODVExport;
33 import de.intevation.gnv.exports.SimpleOdvDataCollector;
34
35 import de.intevation.gnv.geobackend.base.Result;
36
37 import de.intevation.gnv.histogram.HistogramHelper;
38
39 import de.intevation.gnv.state.InputData;
40 import de.intevation.gnv.state.OutputStateBase;
41
42 import de.intevation.gnv.state.describedata.DefaultKeyValueDescribeData;
43 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
44 import de.intevation.gnv.state.describedata.NamedArrayList;
45 import de.intevation.gnv.state.describedata.NamedCollection;
46
47 import de.intevation.gnv.state.exception.StateException;
48
49 import de.intevation.gnv.statistics.Statistic;
50 import de.intevation.gnv.statistics.StatisticSet;
51 import de.intevation.gnv.statistics.Statistics;
52 import de.intevation.gnv.statistics.TimeseriesStatistics;
53
54 import de.intevation.gnv.statistics.exception.StatisticsException;
55
56 import de.intevation.gnv.timeseries.gap.DefaultTimeGap;
57 import de.intevation.gnv.timeseries.gap.TimeGap;
58
59 import de.intevation.gnv.utils.ArtifactXMLUtilities;
60 2
61 import java.io.IOException; 3 import java.io.IOException;
62 import java.io.OutputStream; 4 import java.io.OutputStream;
63 import java.io.UnsupportedEncodingException; 5 import java.io.UnsupportedEncodingException;
64
65 import java.util.ArrayList; 6 import java.util.ArrayList;
66 import java.util.Collection; 7 import java.util.Collection;
67 import java.util.HashMap; 8 import java.util.HashMap;
68 import java.util.Iterator; 9 import java.util.Iterator;
69 import java.util.List; 10 import java.util.List;
70 import java.util.Locale; 11 import java.util.Locale;
71 import java.util.Map; 12 import java.util.Map;
72 import java.util.Vector; 13 import java.util.Vector;
73 14
74 import org.apache.log4j.Logger; 15 import org.apache.log4j.Logger;
75
76 import org.jfree.chart.ChartTheme; 16 import org.jfree.chart.ChartTheme;
77
78 import org.w3c.dom.Document; 17 import org.w3c.dom.Document;
79 import org.w3c.dom.Element; 18 import org.w3c.dom.Element;
80 import org.w3c.dom.Node; 19 import org.w3c.dom.Node;
81 import org.w3c.dom.NodeList; 20 import org.w3c.dom.NodeList;
21
22 import au.com.bytecode.opencsv.CSVWriter;
23 import de.intevation.artifactdatabase.Config;
24 import de.intevation.artifactdatabase.XMLUtils;
25 import de.intevation.artifacts.ArtifactNamespaceContext;
26 import de.intevation.artifacts.CallContext;
27 import de.intevation.artifacts.CallMeta;
28 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
29 import de.intevation.gnv.artifacts.ressource.RessourceFactory;
30 import de.intevation.gnv.chart.Chart;
31 import de.intevation.gnv.chart.ChartLabels;
32 import de.intevation.gnv.chart.DefaultHistogram;
33 import de.intevation.gnv.chart.TimeSeriesChart;
34 import de.intevation.gnv.chart.XMLChartTheme;
35 import de.intevation.gnv.chart.exception.TechnicalChartException;
36 import de.intevation.gnv.exports.ChartExportHelper;
37 import de.intevation.gnv.exports.DefaultDataCollector;
38 import de.intevation.gnv.exports.DefaultExport;
39 import de.intevation.gnv.exports.DefaultProfile;
40 import de.intevation.gnv.exports.Export;
41 import de.intevation.gnv.exports.ODVExport;
42 import de.intevation.gnv.exports.SimpleOdvDataCollector;
43 import de.intevation.gnv.exports.Export.Profile;
44 import de.intevation.gnv.geobackend.base.Result;
45 import de.intevation.gnv.histogram.HistogramHelper;
46 import de.intevation.gnv.state.InputData;
47 import de.intevation.gnv.state.OutputStateBase;
48 import de.intevation.gnv.state.describedata.DefaultKeyValueDescribeData;
49 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
50 import de.intevation.gnv.state.describedata.MinMaxDescribeData;
51 import de.intevation.gnv.state.describedata.NamedArrayList;
52 import de.intevation.gnv.state.describedata.NamedCollection;
53 import de.intevation.gnv.state.exception.StateException;
54 import de.intevation.gnv.statistics.Statistic;
55 import de.intevation.gnv.statistics.StatisticSet;
56 import de.intevation.gnv.statistics.Statistics;
57 import de.intevation.gnv.statistics.TimeseriesStatistics;
58 import de.intevation.gnv.statistics.exception.StatisticsException;
59 import de.intevation.gnv.timeseries.gap.DefaultTimeGap;
60 import de.intevation.gnv.timeseries.gap.TimeGap;
61 import de.intevation.gnv.utils.ArtifactXMLUtilities;
82 62
83 /** 63 /**
84 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> 64 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
85 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 65 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
86 */ 66 */
133 113
134 protected String featureValuesName = "featureid"; 114 protected String featureValuesName = "featureid";
135 protected String parameterValuesName = "parameterid"; 115 protected String parameterValuesName = "parameterid";
136 protected String measuremenValueName = "measurementid"; 116 protected String measuremenValueName = "measurementid";
137 protected String dateValueName = "dateid"; 117 protected String dateValueName = "dateid";
118 protected String timeIntervalValueName = "timeinterval";
138 119
139 120
140 /** 121 /**
141 * Array used to specify the columns used in csv exports. 122 * Array used to specify the columns used in csv exports.
142 */ 123 */
632 String uuid) 613 String uuid)
633 throws IOException, StateException { 614 throws IOException, StateException {
634 615
635 Export export = new ODVExport(new SimpleOdvDataCollector( 616 Export export = new ODVExport(new SimpleOdvDataCollector(
636 TIMESERIES_ODV_PROFILE_NAMES), 617 TIMESERIES_ODV_PROFILE_NAMES),
637 this.getParameters(uuid)); 618 this.getParameters(uuid),
619 this.getStartTime());
638 620
639 if (result == null) 621 if (result == null)
640 log.error("#################### RESULT == NULL #################"); 622 log.error("#################### RESULT == NULL #################");
641 export.create(TIMESERIES_ODV_PROFILE, outputStream, result); 623 export.create(TIMESERIES_ODV_PROFILE, outputStream, result);
624 }
625
626 /**
627 * Method that returns the Starttime of an TimeSeries or
628 * null if it is not a TimeSeries.
629 * @return the Starttime of an TimeSeries or null if it is not a TimeSeries.
630 */
631 protected String getStartTime(){
632 InputData data = inputData.get(this.timeIntervalValueName);
633 if (data != null){
634 Object describeData = data.getObject();
635 if (describeData instanceof MinMaxDescribeData){
636 return (((MinMaxDescribeData)describeData).
637 getMinValue()+".0").
638 replace(' ','T');
639 }
640 return null;
641 }else{
642 return null;
643 }
644
642 } 645 }
643 646
644 /** 647 /**
645 * Returns the statistic generator. 648 * Returns the statistic generator.
646 * 649 *
1155 String measurementNameValue = Config.getStringXPath(configuration, 1158 String measurementNameValue = Config.getStringXPath(configuration,
1156 "value-names/value-name[@name='measurement']/@value"); 1159 "value-names/value-name[@name='measurement']/@value");
1157 if (measurementNameValue != null) { 1160 if (measurementNameValue != null) {
1158 this.measuremenValueName = measurementNameValue; 1161 this.measuremenValueName = measurementNameValue;
1159 } 1162 }
1163 String timeIntervalValue = Config.getStringXPath(configuration,
1164 "value-names/value-name[@name='timeinterval']/@value");
1165 if (timeIntervalValue != null){
1166 this.timeIntervalValueName = timeIntervalValue;
1167 }
1160 1168
1161 String dateNameValue = Config.getStringXPath(configuration, 1169 String dateNameValue = Config.getStringXPath(configuration,
1162 "value-names/value-name[@name='date']/@value"); 1170 "value-names/value-name[@name='date']/@value");
1163 if (dateNameValue != null) { 1171 if (dateNameValue != null) {
1164 this.dateValueName = dateNameValue; 1172 this.dateValueName = dateNameValue;

http://dive4elements.wald.intevation.org