comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/vertical/VerticalProfileOutputState.java @ 762:b3f922908a31

ISSUE122: Added all required Columns for the CSV-Export. gnv-artifacts/trunk@817 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 22 Mar 2010 12:47:44 +0000
parents 8975de9d7483
children 9a828e5a2390
comparison
equal deleted inserted replaced
761:0b1de7e38907 762:b3f922908a31
9 import java.util.Collection; 9 import java.util.Collection;
10 import java.util.Iterator; 10 import java.util.Iterator;
11 import java.util.Locale; 11 import java.util.Locale;
12 12
13 import org.apache.log4j.Logger; 13 import org.apache.log4j.Logger;
14
15 import org.jfree.chart.ChartTheme; 14 import org.jfree.chart.ChartTheme;
16 15
16 import de.intevation.artifacts.CallContext;
17 import de.intevation.gnv.chart.Chart; 17 import de.intevation.gnv.chart.Chart;
18 import de.intevation.gnv.chart.ChartLabels; 18 import de.intevation.gnv.chart.ChartLabels;
19 import de.intevation.gnv.chart.VerticalProfileChart; 19 import de.intevation.gnv.chart.VerticalProfileChart;
20 import de.intevation.gnv.exports.DefaultDataCollector;
20 import de.intevation.gnv.exports.DefaultExport; 21 import de.intevation.gnv.exports.DefaultExport;
21 import de.intevation.gnv.exports.DefaultDataCollector;
22 import de.intevation.gnv.exports.DefaultProfile; 22 import de.intevation.gnv.exports.DefaultProfile;
23 import de.intevation.gnv.exports.Export.Profile; 23 import de.intevation.gnv.exports.Export.Profile;
24 import de.intevation.gnv.geobackend.base.Result; 24 import de.intevation.gnv.geobackend.base.Result;
25 import de.intevation.gnv.state.exception.StateException; 25 import de.intevation.gnv.state.exception.StateException;
26 import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; 26 import de.intevation.gnv.state.timeseries.TimeSeriesOutputState;
27 import de.intevation.gnv.statistics.Statistics; 27 import de.intevation.gnv.statistics.Statistics;
28 import de.intevation.gnv.statistics.VerticalProfileStatistics; 28 import de.intevation.gnv.statistics.VerticalProfileStatistics;
29 29
30 import de.intevation.artifacts.CallContext;
31
32 /** 30 /**
33 * @author Tim Englich <tim.englich@intevation.de> 31 * @author Tim Englich <tim.englich@intevation.de>
34 * 32 *
35 */ 33 */
36 public class VerticalProfileOutputState extends TimeSeriesOutputState { 34 public class VerticalProfileOutputState extends TimeSeriesOutputState {
37 35
38 public static final String [] VERTICAL_PROFILE_COLUMNS = { 36 public static final String [] VERTICAL_PROFILE_COLUMNS = {
39 "XORDINATE", // not quite sure if this is depth 37 "XORDINATE", // not quite sure if this is depth
40 "YORDINATE", 38 "YORDINATE",
41 "GROUP1" 39 "GROUP1",
42 // "GROUP2", 40 "FEATUREID",
43 // "GROUP3" 41 "TIMESERIESID"
42 };
43
44 public static final String [] VERTICAL_PROFILE_MESH_COLUMNS = {
45 "XORDINATE", // not quite sure if this is depth
46 "YORDINATE",
47 "GROUP1",
48 "FEATUREID",
49 "MESHID"
50 };
51
52 public static final String [] VERTICAL_PROFILE_MEASUREMENT_COLUMNS = {
53 "XORDINATE", // not quite sure if this is depth
54 "YORDINATE",
55 "GROUP1",
56 "FEATUREID",
57 "SERIESID"
44 }; 58 };
45 59
46 60
47 public static final String [] VERTICAL_MESH_CSV_COLUMN_LABEL = { 61 public static final String [] VERTICAL_MESH_CSV_COLUMN_LABEL = {
48 "CentralDepth", 62 "CentralDepth",
49 "Value", 63 "Value",
50 "ParameterID" 64 "ParameterID",
51 // TODO "FeatureID", 65 "FeatureID",
52 // TODO "MeshID" 66 "MeshID"
53 }; 67 };
54 68
55 69
56 public static final String [] VERTICAL_TIMESERIES_CSV_COLUMN_LABEL = { 70 public static final String [] VERTICAL_TIMESERIES_CSV_COLUMN_LABEL = {
57 "Depth", 71 "Depth",
58 "Value", 72 "Value",
59 "ParameterID" 73 "ParameterID",
60 // TODO FeatureID missing 74 "FeatureID",
61 // TODO TimeseriesID missing 75 "TimeseriesID"
62 }; 76 };
63 77
64 78
65 public static final String [] VERTICAL_MEASUREMENT_CSV_COLUMN_LABEL = { 79 public static final String [] VERTICAL_MEASUREMENT_CSV_COLUMN_LABEL = {
66 "Depth", 80 "Depth",
67 "Value", 81 "Value",
68 "ParameterID" 82 "ParameterID",
69 // TODO FeatureID missing 83 "FeatureID",
70 // TODO SeriesID missing 84 "SeriesID"
71 }; 85 };
72 86
73 87
74 /** 88 /**
75 * The UID of this class 89 * The UID of this class
138 152
139 @Override 153 @Override
140 protected void createCSV(OutputStream out, Collection<Result> results) 154 protected void createCSV(OutputStream out, Collection<Result> results)
141 throws UnsupportedEncodingException, IOException, StateException 155 throws UnsupportedEncodingException, IOException, StateException
142 { 156 {
143 Iterator iter = results.iterator(); 157 Iterator<Result> iter = results.iterator();
144 Result res = iter.hasNext() ? (Result) iter.next() : null; 158 Result res = iter.hasNext() ? iter.next() : null;
145 159
146 if (res == null) 160 if (res == null)
147 return; 161 return;
148 162
149 Profile profile = null; 163 Profile profile = null;
150 int dataid = res.getInteger("DATAID").intValue(); 164 int dataid = res.getInteger("DATAID").intValue();
151 165 DefaultExport export = null;
152 // on meshes 166 // on meshes
153 if (dataid == 2) { 167 if (dataid == 2) {
154 profile = new DefaultProfile( 168 profile = new DefaultProfile(
155 VERTICAL_MESH_CSV_COLUMN_LABEL, 169 VERTICAL_MESH_CSV_COLUMN_LABEL,
156 ',', 170 ',',
157 '"', 171 '"',
158 '"', 172 '"',
159 "CSV", 173 "CSV",
160 "ISO-8859-1"); 174 "ISO-8859-1");
175 export = new DefaultExport(
176 new DefaultDataCollector(VERTICAL_PROFILE_MESH_COLUMNS));
161 } 177 }
162 178
163 // on timeseries 179 // on timeseries
164 else if (dataid == 1) { 180 else if (dataid == 1) {
165 profile = new DefaultProfile( 181 profile = new DefaultProfile(
167 ',', 183 ',',
168 '"', 184 '"',
169 '"', 185 '"',
170 "CSV", 186 "CSV",
171 "ISO-8859-1"); 187 "ISO-8859-1");
188 export = new DefaultExport(
189 new DefaultDataCollector(VERTICAL_PROFILE_COLUMNS));
172 } 190 }
173 191
174 // on measurements 192 // on measurements
175 else { 193 else {
176 profile = new DefaultProfile( 194 profile = new DefaultProfile(
178 ',', 196 ',',
179 '"', 197 '"',
180 '"', 198 '"',
181 "CSV", 199 "CSV",
182 "ISO-8859-1"); 200 "ISO-8859-1");
183 } 201 export = new DefaultExport(
184 202 new DefaultDataCollector(VERTICAL_PROFILE_MEASUREMENT_COLUMNS));
185 DefaultExport export = new DefaultExport( 203 }
186 new DefaultDataCollector(VERTICAL_PROFILE_COLUMNS));
187 export.create(profile, out, results); 204 export.create(profile, out, results);
188 } 205 }
189 206
190 207
191 protected String createChartSubtitle(Locale locale, String uuid) { 208 protected String createChartSubtitle(Locale locale, String uuid) {

http://dive4elements.wald.intevation.org