8996
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
|
2 * Software engineering by |
|
3 * Björnsen Beratende Ingenieure GmbH |
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
|
5 * |
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
|
8 * documentation coming with Dive4Elements River for details. |
|
9 */ |
|
10 package org.dive4elements.river.artifacts.uinfo.vegetationzones; |
|
11 |
|
12 import java.util.ArrayList; |
|
13 import java.util.Collection; |
|
14 |
|
15 import org.apache.log4j.Logger; |
|
16 import org.dive4elements.river.artifacts.common.GeneralResultType; |
|
17 import org.dive4elements.river.artifacts.common.ResultRow; |
|
18 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
|
19 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
|
20 import org.dive4elements.river.artifacts.uinfo.commons.AbstractUInfoExporter; |
|
21 |
|
22 import au.com.bytecode.opencsv.CSVWriter; |
|
23 |
|
24 /** |
|
25 * @author Domenico Nardi Tironi |
|
26 * |
|
27 */ |
|
28 public class VegetationZonesExporter extends AbstractUInfoExporter<VegetationZonesCalculationResult, VegetationZonesCalculationResults> { |
|
29 |
|
30 /** The log used in this exporter. */ |
|
31 private static Logger log = Logger.getLogger(VegetationZonesExporter.class); |
|
32 |
|
33 private static final String JASPER_FILE = "/jasper/uinfo.vegetationzones.jasper"; |
|
34 |
|
35 @Override |
|
36 protected Logger getLog() { |
|
37 return log; |
|
38 } |
|
39 |
|
40 @Override |
|
41 protected void writeCSVGlobalMetadata(final CSVWriter writer, final VegetationZonesCalculationResults results) { |
|
42 log.info("SalixLineExporter.writeCSVMeta"); |
|
43 super.writeCSVGlobalMetadataDefaults(writer, results); |
|
44 } |
|
45 |
|
46 /** |
|
47 * Write the header, with different headings depending on whether at a |
|
48 * gauge or at a location. |
|
49 * |
|
50 * @param river |
|
51 * @param useTkh |
|
52 */ |
|
53 @Override |
|
54 protected void writeCSVHeader(final CSVWriter writer, final VegetationZonesCalculationResults results, final RiverInfo river) { |
|
55 log.info("FlowDepthExporter.writeCSVHeader"); |
|
56 |
|
57 final Collection<String> header = new ArrayList<>(11); |
|
58 |
|
59 header.add(msg(GeneralResultType.station.getCsvHeader())); |
|
60 header.add(msgUnit(SInfoResultType.flowdepth.getCsvHeader(), SInfoResultType.flowdepth.getUnit())); |
|
61 |
|
62 header.add(msgUnit(SInfoResultType.waterlevel.getCsvHeader(), river.getWstUnit())); |
|
63 header.add(msgUnit(SInfoResultType.discharge.getCsvHeader(), SInfoResultType.discharge.getUnit())); |
|
64 header.add(msg(SInfoResultType.waterlevelLabel.getCsvHeader())); |
|
65 header.add(msg(SInfoResultType.gaugeLabel.getCsvHeader())); |
|
66 header.add(msgUnit(SInfoResultType.meanBedHeight.getCsvHeader(), river.getWstUnit())); |
|
67 header.add(msg(SInfoResultType.soundingLabel.getCsvHeader())); |
|
68 header.add(msg(SInfoResultType.location.getCsvHeader())); |
|
69 |
|
70 writer.writeNext(header.toArray(new String[header.size()])); |
|
71 } |
|
72 |
|
73 /** |
|
74 * Format a row of a flow depth result into an array of string, both used by csv and pdf |
|
75 * |
|
76 * @param pdf |
|
77 * |
|
78 * @param useTkh |
|
79 */ |
|
80 @Override |
|
81 protected String[] formatRow(final VegetationZonesCalculationResults results, final ResultRow row, final ExportMode mode) { |
|
82 |
|
83 final Collection<String> lines = new ArrayList<>(11); |
|
84 |
|
85 lines.add(row.exportValue(this.context, GeneralResultType.station)); |
|
86 lines.add(row.exportValue(this.context, SInfoResultType.flowdepth)); |
|
87 |
|
88 lines.add(row.exportValue(this.context, SInfoResultType.waterlevel)); |
|
89 lines.add(row.exportValue(this.context, SInfoResultType.discharge)); |
|
90 lines.add(row.exportValue(this.context, SInfoResultType.waterlevelLabel)); |
|
91 lines.add(row.exportValue(this.context, SInfoResultType.gaugeLabel)); |
|
92 lines.add(row.exportValue(this.context, SInfoResultType.meanBedHeight)); |
|
93 lines.add(row.exportValue(this.context, SInfoResultType.soundingLabel)); |
|
94 lines.add(row.exportValue(this.context, SInfoResultType.location)); |
|
95 |
|
96 return lines.toArray(new String[lines.size()]); |
|
97 } |
|
98 |
|
99 @Override |
|
100 protected String getJasperFile() { |
|
101 // TODO Auto-generated method stub |
|
102 return JASPER_FILE; |
|
103 } |
|
104 |
|
105 @Override |
|
106 protected void writeCSVResultMetadata(final CSVWriter writer, final VegetationZonesCalculationResults results, |
|
107 final VegetationZonesCalculationResult result) { |
|
108 // TODO Auto-generated method stub |
|
109 |
|
110 } |
|
111 |
|
112 } |