annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesVectorOutputState.java @ 1081:846b2b70b2e0

Implemented histogram creation for vectorial timeseries. gnv-artifacts/trunk@1183 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 09 Jun 2010 09:51:05 +0000
parents 1728aac87717
children f953c9a559d8
rev   line source
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.state.timeseries;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
3 import au.com.bytecode.opencsv.CSVWriter;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
4
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import de.intevation.artifacts.CallContext;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
7 import de.intevation.gnv.artifacts.cache.CacheFactory;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
8
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import de.intevation.gnv.chart.Chart;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.gnv.chart.ChartLabels;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.gnv.chart.TimeSeriesVectorChart;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
13 import de.intevation.gnv.exports.DefaultExport;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
14 import de.intevation.gnv.exports.DefaultProfile;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
15 import de.intevation.gnv.exports.Export;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
16 import de.intevation.gnv.exports.Export.Profile;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
17 import de.intevation.gnv.exports.SimpleOdvDataCollector;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
18
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.gnv.geobackend.base.Result;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import de.intevation.gnv.utils.VectorDataProcessor;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
1081
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
23 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
24 import de.intevation.gnv.state.exception.StateException;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
25
1077
1728aac87717 Added statistics for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
26 import de.intevation.gnv.statistics.Statistics;
1728aac87717 Added statistics for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
27 import de.intevation.gnv.statistics.TimeseriesVectorStatistics;
1728aac87717 Added statistics for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
28
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
29 import java.io.IOException;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
30 import java.io.OutputStream;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
31
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 import java.util.Collection;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 import java.util.Locale;
1081
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
34 import java.util.Map;
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
36 import net.sf.ehcache.Cache;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
37
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 import org.apache.log4j.Logger;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 import org.jfree.chart.ChartTheme;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 /**
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 */
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 public class TimeSeriesVectorOutputState extends TimeSeriesOutputState {
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 private static Logger logger =
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 Logger.getLogger(TimeSeriesVectorOutputState.class);
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
1071
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
50 public static final String[] RESULT_COLUMNS = {
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
51 "YORDINATE", "XORDINATE", "GROUP1", "GROUP2", "GROUP3", "GAPID", "SERIES"
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
52 };
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
53
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
54 public static final String[] ODV_COLUMN_HEADERS = {
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
55 "Cruise",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
56 "Station",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
57 "Type",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
58 "yyyy-mm-dd hh:mm",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
59 "Lon (°E)",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
60 "Lat (°N)",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
61 "Bot. Depth [m]",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
62 "Depth [m]",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
63 "QF",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
64 "XComponent",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
65 "QF",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
66 "YComponent",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
67 "QF",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
68 "ZComponent",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
69 "QF",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
70 "Speed",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
71 "QF",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
72 "Direction",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
73 "QF"
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
74 };
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
75
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
76 public static final String[] ODV_PROFILE_NAMES = {
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
77 "CRUISE",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
78 "STATION",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
79 "TYPE",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
80 "TIMEVALUE",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
81 "SHAPE",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
82 "BOTDEPTH",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
83 "DEPTH",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
84 "QF",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
85 "XCOMPONENT",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
86 "QF",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
87 "YCOMPONENT",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
88 "QF",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
89 "ZCOMPONENT",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
90 "QF",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
91 "SPEED",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
92 "QF",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
93 "DIRECTION",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
94 "QF"};
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
95
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 public TimeSeriesVectorOutputState() {
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 }
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 @Override
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
101 protected Object getChartResult(String uuid, CallContext callContext) {
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
102 logger.debug("OutputStateBase.getChartResult");
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
103 CacheFactory factory = CacheFactory.getInstance();
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
105 if (factory.isInitialized()) {
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
106 // we use a cache
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
107 logger.info("Using cache.");
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
108 Cache cache = factory.getCache();
1060
cc4ec127d666 Remove the elements of an outdated state from cache if its endOfLife method is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1041
diff changeset
109 String key = "chart_" + getHash();
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
110
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
111 net.sf.ehcache.Element value = cache.get(key);
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
112 if (value != null) {
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
113 logger.debug("Found element in cache.");
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
114 return value.getObjectValue();
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
115 }
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
116 else {
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
117 logger.debug("Element not in cache, we ask the database");
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
118 Collection<Result> res = (Collection<Result>)getData(queryID);
1071
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
119 res = VectorDataProcessor.process(res, RESULT_COLUMNS);
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
120 cache.put(new net.sf.ehcache.Element(key, res));
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
121
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
122 return res;
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
123 }
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 }
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
125 else {
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
126 // we don't use a cache, so we have to query the database every
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
127 // single time
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
128 logger.info("Not using a cache.");
1071
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
129 return VectorDataProcessor.process(
9bb1979aabbe Added a new output state and chart type for vertical profiles using vector data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1060
diff changeset
130 getData(queryID), RESULT_COLUMNS);
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 }
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 }
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 @Override
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 protected Chart getChart(
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 ChartLabels chartLables,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 ChartTheme theme,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 Collection parameters,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140 Collection measurements,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 Collection dates,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 Object result,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 Locale locale,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 String uuid,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 boolean linesVisible,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 boolean shapesVisible,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 CallContext callContext
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 ) {
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 Chart chart = new TimeSeriesVectorChart(
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 chartLables,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 theme,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 parameters,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 measurements,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 dates,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 (Collection)result,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 timeGapDefinitions,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 locale,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 linesVisible,
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 shapesVisible
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 );
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 chart.generateChart();
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 return chart;
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 }
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
165
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
166
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
167 @Override
1081
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
168 protected Chart[] getHistograms(
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
169 String uuid,
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
170 CallContext callContext,
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
171 Collection<KeyValueDescibeData> parameters,
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
172 Collection<KeyValueDescibeData> measurements,
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
173 Collection<KeyValueDescibeData> dates,
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
174 Map requestParameter
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
175 ) {
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
176 Collection results = (Collection) getChartResult(uuid, callContext);
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
177 ChartTheme theme = createStyle(callContext);
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
178
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
179 return VectorDataProcessor.getHistograms(
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
180 uuid, callContext, results, theme, requestParameter);
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
181 }
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
182
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
183
846b2b70b2e0 Implemented histogram creation for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1077
diff changeset
184 @Override
1041
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
185 protected void createODV(
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
186 OutputStream outputStream, Collection result, String uuid)
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
187 throws IOException, StateException
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
188 {
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
189 logger.info("Start exporting " + result.size() + " items to odv.");
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
190 Export export = new DefaultExport(
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
191 new SimpleOdvDataCollector(ODV_PROFILE_NAMES));
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
192
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
193 Profile profile = new DefaultProfile(
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
194 ODV_COLUMN_HEADERS,
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
195 '\t',
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
196 CSVWriter.NO_QUOTE_CHARACTER,
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
197 CSVWriter.NO_ESCAPE_CHARACTER,
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
198 "ODV",
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
199 "ISO-8859-1");
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
200
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
201 export.create(profile, outputStream, result);
8a8ee5abc084 Implemented the odv export for timeseries using vector data (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1040
diff changeset
202 }
1077
1728aac87717 Added statistics for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
203
1728aac87717 Added statistics for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
204
1728aac87717 Added statistics for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
205 protected Statistics getStatisticsGenerator() {
1728aac87717 Added statistics for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
206 return new TimeseriesVectorStatistics();
1728aac87717 Added statistics for vectorial timeseries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1071
diff changeset
207 }
1040
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 }
70653c29fc1d Finished vector support for timeseriespoints (Issue27).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org