Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationHistoricalResult.java @ 9249:600e1ac42049
Historical Result
author | gernotbelger |
---|---|
date | Thu, 12 Jul 2018 14:15:36 +0200 |
parents | |
children | 72b3270e1568 |
comparison
equal
deleted
inserted
replaced
9248:9e6b70cce337 | 9249:600e1ac42049 |
---|---|
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.text.NumberFormat; | |
13 import java.util.Collection; | |
14 | |
15 import org.dive4elements.river.artifacts.common.ExportContextCSV; | |
16 import org.dive4elements.river.artifacts.common.IExportContext; | |
17 import org.dive4elements.river.artifacts.common.ResultRow; | |
18 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
19 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; | |
20 import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType; | |
21 | |
22 /** | |
23 * @author Domenico Nardi Tironi | |
24 */ | |
25 final class SalixLineCalculationHistoricalResult extends SalixLineCalculationNoScenarioResult { | |
26 | |
27 private static final long serialVersionUID = 1L; | |
28 | |
29 public SalixLineCalculationHistoricalResult(final String label, final WstInfo wst, final Collection<ResultRow> rows) { | |
30 super(label, wst, rows); | |
31 | |
32 } | |
33 | |
34 @Override | |
35 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { | |
36 | |
37 final Collection<String> header = super.writeNoScenarioHeader(exportContextCSV); | |
38 | |
39 header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salixlinehist)); | |
40 header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salix_line_scenario_dwspl)); | |
41 | |
42 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
43 } | |
44 | |
45 @Override | |
46 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { | |
47 writeHistoricalViewCSVMetadata(exportContextCSV); | |
48 exportContextCSV.writeBlankLine(); | |
49 | |
50 } | |
51 | |
52 @Override | |
53 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { | |
54 | |
55 return formatRow(exportContextCSV, row); | |
56 } | |
57 | |
58 private String[] formatRow(final IExportContext context, final ResultRow row) { | |
59 | |
60 final Collection<String> lines = super.getNoScenarioFormat(row, context); | |
61 | |
62 if (context instanceof ExportContextCSV) { // enum gespart - pdf-export hat ja nur die drei spalten | |
63 final NumberFormat formatter = ((ExportContextCSV) context).getSalixScenFormatter(); | |
64 | |
65 lines.add(context.formatRowValue(row, UInfoResultType.salixlinehist)); | |
66 lines.add(context.formatRowValue(row, UInfoResultType.salix_line_scenario_dwspl)); | |
67 | |
68 } | |
69 return lines.toArray(new String[lines.size()]); | |
70 } | |
71 | |
72 // TODO: move to historical class and delete here | |
73 private void writeHistoricalViewCSVMetadata(final ExportContextCSV exportContextCSV) { | |
74 final String main = "uinfo.export.csv.meta.header.salix.historical"; | |
75 // "##Historische Betrachtung" | |
76 exportContextCSV.writeCSVMetaEntry(main); | |
77 | |
78 final String mainSub = "uinfo.export.csv.meta.header.salix"; | |
79 // "# Szenariotyp: " | |
80 exportContextCSV.writeCSVMetaEntry(mainSub + ".szenariotyp"); | |
81 // "# Teilabschnitt: " | |
82 exportContextCSV.writeCSVMetaEntry(mainSub + ".teilabschnitt"); | |
83 | |
84 // "# Art des Zeitraums: " | |
85 exportContextCSV.writeCSVMetaEntry(main + ".zeitart"); | |
86 // "# Historischer Zeitpunkt: " | |
87 exportContextCSV.writeCSVMetaEntry(main + ".zeitpunkt"); | |
88 } | |
89 } |