Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationNoScenarioResult.java @ 9243:da0bdbcd6f09
salix.supraRegional+Regional results
author | gernotbelger |
---|---|
date | Wed, 11 Jul 2018 13:36:18 +0200 |
parents | artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationResult.java@a4121ec450d6 |
children | 72b3270e1568 |
comparison
equal
deleted
inserted
replaced
9242:2ea7b61797d3 | 9243:da0bdbcd6f09 |
---|---|
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.salix; | |
11 | |
12 import java.util.ArrayList; | |
13 import java.util.Collection; | |
14 | |
15 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; | |
16 import org.dive4elements.river.artifacts.common.ExportContextCSV; | |
17 import org.dive4elements.river.artifacts.common.ExportContextPDF; | |
18 import org.dive4elements.river.artifacts.common.GeneralResultType; | |
19 import org.dive4elements.river.artifacts.common.IExportContext; | |
20 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | |
21 import org.dive4elements.river.artifacts.common.ResultRow; | |
22 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
23 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; | |
24 import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType; | |
25 | |
26 /** | |
27 * @author Domenico Nardi Tironi | |
28 */ | |
29 class SalixLineCalculationNoScenarioResult extends AbstractCalculationExportableResult { | |
30 | |
31 private static final long serialVersionUID = 1L; | |
32 private static final String JASPER_FILE = "/jasper/templates/uinfo.salixline.jrxml"; | |
33 | |
34 public SalixLineCalculationNoScenarioResult(final String label, final WstInfo wst, final Collection<ResultRow> rows) { | |
35 super(label, rows); | |
36 } | |
37 | |
38 @Override | |
39 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { | |
40 final Collection<String> header = writeNoScenarioHeader(exportContextCSV); | |
41 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
42 | |
43 } | |
44 | |
45 protected final Collection<String> writeNoScenarioHeader(final ExportContextCSV exportContextCSV) { | |
46 final Collection<String> header = new ArrayList<>(); | |
47 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
48 header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salixline)); | |
49 header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salix_delta_mw)); | |
50 return header; | |
51 } | |
52 | |
53 @Override | |
54 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { | |
55 | |
56 return formatRow(exportContextCSV, row); | |
57 } | |
58 | |
59 @Override | |
60 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { | |
61 | |
62 return formatRow(exportContextPDF, row); | |
63 } | |
64 | |
65 @Override | |
66 protected String getJasperFile() { | |
67 | |
68 return this.JASPER_FILE; | |
69 } | |
70 | |
71 @Override | |
72 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { | |
73 | |
74 /* additional column headings */ | |
75 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); | |
76 exportContextPDF.addJRMetadata(source, "salix_line", UInfoResultType.salixline); | |
77 exportContextPDF.addJRMetadata(source, "salix_delta_mw", UInfoResultType.salix_delta_mw); | |
78 | |
79 } | |
80 | |
81 private String[] formatRow(final IExportContext context, final ResultRow row) { | |
82 | |
83 final Collection<String> lines = getNoScenarioFormat(row, context); | |
84 | |
85 // // ?? | |
86 // // wenn "historisch" gewählt wurde, nur "historisch" anzeigen; sonst für jeden scen-wert ne neue Spalte und "hist" | |
87 // // ausblenden!...!..!! | |
88 // lines.add(context.formatRowValue(row, UInfoResultType.salixlinehist)); | |
89 // lines.add(context.formatRowValue(row, UInfoResultType.salixlinescen)); | |
90 | |
91 return lines.toArray(new String[lines.size()]); | |
92 } | |
93 | |
94 protected final Collection<String> getNoScenarioFormat(final ResultRow row, final IExportContext context) { | |
95 final Collection<String> lines = new ArrayList<>(); | |
96 lines.add(context.formatRowValue(row, GeneralResultType.station)); | |
97 lines.add(context.formatRowValue(row, UInfoResultType.salixline)); | |
98 lines.add(context.formatRowValue(row, UInfoResultType.salix_delta_mw)); | |
99 | |
100 return lines; | |
101 | |
102 } | |
103 | |
104 protected final void writeRegionalCommonCSVMeta(final ExportContextCSV exportContextCSV) { | |
105 final String main = "uinfo.export.csv.meta.header.salix"; | |
106 // "# Szenariotyp: " | |
107 exportContextCSV.writeCSVMetaEntry(main + ".szenariotyp"); | |
108 // "# Teilabschnitt: " | |
109 exportContextCSV.writeCSVMetaEntry(main + ".teilabschnitt"); | |
110 // "# Mittelwasserspiegellagenänderung: " | |
111 exportContextCSV.writeCSVMetaEntry(main + ".mwspiegellaenderung"); | |
112 } | |
113 | |
114 @Override | |
115 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { | |
116 // do nothing. subclass may override | |
117 | |
118 } | |
119 | |
120 // private void writeHistoricalViewCSVMetadata(final ExportContextCSV exportContextCSV) { | |
121 // final String main = "uinfo.export.csv.meta.header.salix.historical"; | |
122 // // "##Historische Betrachtung" | |
123 // exportContextCSV.writeCSVMetaEntry(main); | |
124 // | |
125 // final String mainSub = "uinfo.export.csv.meta.header.salix"; | |
126 // // "# Szenariotyp: " | |
127 // exportContextCSV.writeCSVMetaEntry(mainSub + ".szenariotyp"); | |
128 // // "# Teilabschnitt: " | |
129 // exportContextCSV.writeCSVMetaEntry(mainSub + ".teilabschnitt"); | |
130 // | |
131 // // "# Art des Zeitraums: " | |
132 // exportContextCSV.writeCSVMetaEntry(main + ".zeitart"); | |
133 // // "# Historischer Zeitpunkt: " | |
134 // exportContextCSV.writeCSVMetaEntry(main + ".zeitpunkt"); | |
135 // } | |
136 } |