comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java @ 368:6491000407dd

Added column labels for csv export of timeseries, vertical and horizontal profiles. gnv-artifacts/trunk@444 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 17 Dec 2009 10:20:05 +0000
parents 2f7a28f211c7
children bed9735adf84
comparison
equal deleted inserted replaced
367:8124e5de18b6 368:6491000407dd
100 100
101 protected String featureValuesName = "featureid"; 101 protected String featureValuesName = "featureid";
102 protected String parameterValuesName = "parameterid"; 102 protected String parameterValuesName = "parameterid";
103 protected String measuremenValueName = "measurementid"; 103 protected String measuremenValueName = "measurementid";
104 protected String dateValueName = "dateid"; 104 protected String dateValueName = "dateid";
105 105
106 public static final String [] TIMESERIES_CSV_PROFILE_NAMES = { 106 public static final String [] TIMESERIES_CSV_PROFILE_COLUMNS = {
107 "XORDINATE", 107 "XORDINATE",
108 "YORDINATE", 108 "YORDINATE",
109 "GROUP1", 109 "GROUP1",
110 "GROUP2", 110 "GROUP2",
111 "GROUP3" 111 "GROUP3"
112 }; 112 };
113 113
114
115 public static final String [] TIMESERIES_TIMESERIES_CSV_COLUMN_LABEL = {
116 "Date/Time",
117 "Value",
118 "ParameterID",
119 "MeasurementID",
120 "TimeseriesID"
121 };
122
123 public static final String [] TIMESERIES_MESH_CSV_COLUMN_LABEL = {
124 "Date/Time",
125 "Value",
126 "ParameterID",
127 "FeatureID",
128 "MeshID"
129 };
130
114 public static final String [] TIMESERIES_ODV_PROFILE_NAMES = { 131 public static final String [] TIMESERIES_ODV_PROFILE_NAMES = {
115 "CRUISE", 132 "CRUISE",
116 "STATION", 133 "STATION",
117 "TYPE", 134 "TYPE",
118 "SHAPE", 135 "SHAPE",
134 "Depth [m]", 151 "Depth [m]",
135 "Date/Time", 152 "Date/Time",
136 "Value", 153 "Value",
137 "Parameterid" 154 "Parameterid"
138 }; 155 };
139
140 /**
141 * Profile for exporting data to cvs
142 */
143 public static final Profile TIMESERIES_CSV_PROFILE =
144 new DefaultProfile(
145 null,
146 ',',
147 '"',
148 '"',
149 "CSV",
150 "ISO-8859-1");
151 156
152 /** 157 /**
153 * Profile for exporting data to odv 158 * Profile for exporting data to odv
154 * TODO Change TIMESERIES_PROFILE_NAMES, which belong to CSV exports 159 * TODO Change TIMESERIES_PROFILE_NAMES, which belong to CSV exports
155 */ 160 */
412 protected Collection getCleanedParameters(String uuid) { 417 protected Collection getCleanedParameters(String uuid) {
413 return getCleanedParameters(getParameters(uuid)); 418 return getCleanedParameters(getParameters(uuid));
414 } 419 }
415 420
416 421
417 /** 422 protected void createCSV(OutputStream out, Collection<Result> results)
418 * @param outputStream 423 throws UnsupportedEncodingException, IOException, StateException
419 * @param chartResult 424 {
420 * @throws UnsupportedEncodingException 425 Iterator iter = results.iterator();
421 * @throws IOException 426 Result res = iter.hasNext() ? (Result) iter.next() : null;
422 * @throws StateException 427
423 */ 428 if (res == null)
424 protected void createCSV(OutputStream outputStream, 429 return;
425 Collection<Result> chartResult) 430
426 throws UnsupportedEncodingException, 431 Profile profile = null;
427 IOException, 432 int dataid = res.getInteger("DATAID").intValue();
428 StateException { 433
429 DefaultExport export = new DefaultExport(new DefaultDataCollector( 434 // on meshes
430 TIMESERIES_CSV_PROFILE_NAMES)); 435 if (dataid == 2) {
431 436 profile = new DefaultProfile(
432 export.create(TIMESERIES_CSV_PROFILE, outputStream, chartResult); 437 TIMESERIES_MESH_CSV_COLUMN_LABEL,
433 } 438 ',',
439 '"',
440 '"',
441 "CSV",
442 "ISO-8859-1");
443 }
444
445 // on timeseries
446 else {
447 profile = new DefaultProfile(
448 TIMESERIES_TIMESERIES_CSV_COLUMN_LABEL,
449 ',',
450 '"',
451 '"',
452 "CSV",
453 "ISO-8859-1");
454 }
455
456 DefaultExport export = new DefaultExport(
457 new DefaultDataCollector(TIMESERIES_CSV_PROFILE_COLUMNS));
458 export.create(profile, out, results);
459 }
460
434 461
435 /** 462 /**
436 * TODO Result is not used at the moment. Change result with correct data. 463 * TODO Result is not used at the moment. Change result with correct data.
437 */ 464 */
438 protected void createODV(OutputStream outputStream, Collection result) 465 protected void createODV(OutputStream outputStream, Collection result)

http://dive4elements.wald.intevation.org