Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java @ 9195:a4121ec450d6
'ca.'-issue
ExportContextCSV+PDF separated
uinfo.inundationduration url export
author | gernotbelger |
---|---|
date | Fri, 29 Jun 2018 14:52:54 +0200 |
parents | 9b2e46090099 |
children | 740d65e4aa14 |
comparison
equal
deleted
inserted
replaced
9191:f692f5a0536a | 9195:a4121ec450d6 |
---|---|
11 | 11 |
12 import java.util.ArrayList; | 12 import java.util.ArrayList; |
13 import java.util.Collection; | 13 import java.util.Collection; |
14 | 14 |
15 import org.dive4elements.river.artifacts.common.ExportContextCSV; | 15 import org.dive4elements.river.artifacts.common.ExportContextCSV; |
16 import org.dive4elements.river.artifacts.common.ExportContextPDF; | |
16 import org.dive4elements.river.artifacts.common.GeneralResultType; | 17 import org.dive4elements.river.artifacts.common.GeneralResultType; |
18 import org.dive4elements.river.artifacts.common.IExportContext; | |
17 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | 19 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; |
18 import org.dive4elements.river.artifacts.common.ResultRow; | 20 import org.dive4elements.river.artifacts.common.ResultRow; |
19 import org.dive4elements.river.artifacts.sinfo.common.AbstractTkhCalculationResult; | 21 import org.dive4elements.river.artifacts.sinfo.common.AbstractTkhCalculationResult; |
20 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; | 22 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
21 import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo; | 23 import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo; |
26 * Contains the results of a {@link FloodDurationCalculation}. | 28 * Contains the results of a {@link FloodDurationCalculation}. |
27 * | 29 * |
28 * @author Gernot Belger | 30 * @author Gernot Belger |
29 */ | 31 */ |
30 | 32 |
31 final class FlowDepthCalculationResult extends AbstractTkhCalculationResult<FlowDepthCalculationResults> { | 33 final class FlowDepthCalculationResult extends AbstractTkhCalculationResult { |
32 | 34 |
33 private static final long serialVersionUID = 1L; | 35 private static final long serialVersionUID = 1L; |
34 | 36 |
35 private enum ExportMode { // TODO; nicht ständig kopieren | 37 private enum ExportMode { // TODO; nicht ständig kopieren |
36 pdf, csv | 38 pdf, csv |
51 public BedHeightInfo getSounding() { | 53 public BedHeightInfo getSounding() { |
52 return this.sounding; | 54 return this.sounding; |
53 } | 55 } |
54 | 56 |
55 @Override | 57 @Override |
56 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final FlowDepthCalculationResults results, final RiverInfo river) { | 58 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { |
57 // getLog().info("FlowDepthExporter.writeCSVHeader"); | 59 // getLog().info("FlowDepthExporter.writeCSVHeader"); |
58 | 60 |
59 final Collection<String> header = new ArrayList<>(11); | 61 final Collection<String> header = new ArrayList<>(11); |
60 | 62 |
61 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | 63 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); |
77 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | 79 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); |
78 | 80 |
79 } | 81 } |
80 | 82 |
81 @Override | 83 @Override |
82 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV, final FlowDepthCalculationResults results) { | 84 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { |
83 | 85 |
84 exportContextCSV.writeCSVSoundingMetadata(this.sounding); | 86 exportContextCSV.writeCSVSoundingMetadata(this.sounding); |
85 | 87 |
86 exportContextCSV.writeBlankLine();// .writeNext(new String[] { "" }); // break line | 88 exportContextCSV.writeBlankLine();// .writeNext(new String[] { "" }); // break line |
87 | 89 |
95 protected String getJasperFile() { | 97 protected String getJasperFile() { |
96 return JASPER_FILE; | 98 return JASPER_FILE; |
97 } | 99 } |
98 | 100 |
99 @Override | 101 @Override |
100 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final FlowDepthCalculationResults results, final ResultRow row) { | 102 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { |
101 return formatRow(ExportMode.csv, exportContextCSV, results, row); | 103 return formatRow(ExportMode.csv, exportContextCSV, row); |
102 } | 104 } |
103 | 105 |
104 @Override | 106 @Override |
105 protected String[] formatPDFRow(final ExportContextCSV exportContextPDF, final FlowDepthCalculationResults results, final ResultRow row) { | 107 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { |
106 | 108 |
107 return formatRow(ExportMode.pdf, exportContextPDF, results, row); | 109 return formatRow(ExportMode.pdf, exportContextPDF, row); |
108 } | 110 } |
109 | 111 |
110 @Override | 112 @Override |
111 protected void addJRTableHeader(final ExportContextCSV exportContextPDF, final MetaAndTableJRDataSource source, final FlowDepthCalculationResults results) { | 113 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { |
112 | 114 |
113 /* column headings */ | 115 /* column headings */ |
114 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); | 116 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); |
115 exportContextPDF.addJRMetadata(source, "flowdepth_header", SInfoResultType.flowdepth); | 117 exportContextPDF.addJRMetadata(source, "flowdepth_header", SInfoResultType.flowdepth); |
116 exportContextPDF.addJRMetadata(source, "flowdepth_tkh_header", SInfoResultType.flowdepthtkh); | 118 exportContextPDF.addJRMetadata(source, "flowdepth_tkh_header", SInfoResultType.flowdepthtkh); |
122 exportContextPDF.addJRMetadata(source, "bedheight_header", SInfoResultType.meanBedHeight); | 124 exportContextPDF.addJRMetadata(source, "bedheight_header", SInfoResultType.meanBedHeight); |
123 exportContextPDF.addJRMetadata(source, "sounding_name_header", SInfoResultType.soundingLabel); | 125 exportContextPDF.addJRMetadata(source, "sounding_name_header", SInfoResultType.soundingLabel); |
124 exportContextPDF.addJRMetadata(source, "location_header", SInfoResultType.location); | 126 exportContextPDF.addJRMetadata(source, "location_header", SInfoResultType.location); |
125 } | 127 } |
126 | 128 |
127 private String[] formatRow(final ExportMode mode, final ExportContextCSV exportContextCSV, final FlowDepthCalculationResults results, final ResultRow row) { | 129 private String[] formatRow(final ExportMode mode, final IExportContext exportContext, final ResultRow row) { |
128 | 130 |
129 final Collection<String> lines = new ArrayList<>(11); | 131 final Collection<String> lines = new ArrayList<>(11); |
130 | 132 |
131 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); | 133 lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); |
132 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.flowdepth)); | 134 lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepth)); |
135 final FlowDepthCalculationResults results = exportContext.getResults(); | |
133 | 136 |
134 if (mode == ExportMode.pdf || results.isUseTkh()) { | 137 if (mode == ExportMode.pdf || results.isUseTkh()) { |
135 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.flowdepthtkh)); | 138 lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthtkh)); |
136 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.tkh)); | 139 lines.add(exportContext.formatRowValue(row, SInfoResultType.tkh)); |
137 } | 140 } |
138 | 141 |
139 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.waterlevel)); | 142 lines.add(exportContext.formatRowValue(row, SInfoResultType.waterlevel)); |
140 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.discharge)); | 143 lines.add(exportContext.formatRowValue(row, SInfoResultType.discharge)); |
141 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.waterlevelLabel)); | 144 lines.add(exportContext.formatRowValue(row, SInfoResultType.waterlevelLabel)); |
142 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.gaugeLabel)); | 145 lines.add(exportContext.formatRowValue(row, SInfoResultType.gaugeLabel)); |
143 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.meanBedHeight)); | 146 lines.add(exportContext.formatRowValue(row, SInfoResultType.meanBedHeight)); |
144 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.soundingLabel)); | 147 lines.add(exportContext.formatRowValue(row, SInfoResultType.soundingLabel)); |
145 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.location)); | 148 lines.add(exportContext.formatRowValue(row, SInfoResultType.location)); |
146 | 149 |
147 return lines.toArray(new String[lines.size()]); | 150 return lines.toArray(new String[lines.size()]); |
148 } | 151 } |
149 | 152 |
150 } | 153 } |