Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcDetailResult.java @ 9157:f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
author | mschaefer |
---|---|
date | Tue, 19 Jun 2018 14:19:32 +0200 |
parents | 23945061daec |
children | f1be005f0c46 |
rev | line source |
---|---|
9150 | 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.sinfo.collision; | |
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.GeneralResultType; | |
18 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | |
19 import org.dive4elements.river.artifacts.common.ResultRow; | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
20 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
9150 | 21 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
22 | |
23 /** | |
24 * Contains the results of a {@link FloodDurationCalculation}. | |
25 * | |
26 * @author Gernot Belger | |
27 */ | |
28 final class CollisionCalcDetailResult extends AbstractCalculationExportableResult<CollisionCalculationResults> { | |
29 | |
30 private static final long serialVersionUID = 1L; | |
31 private static final String JASPER_FILE = "/jasper/templates/sinfo.collision.detail.jrxml"; | |
32 | |
33 public CollisionCalcDetailResult(final String label, final Collection<ResultRow> rows) { | |
34 super(label, rows); | |
35 } | |
36 | |
37 @Override | |
38 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results) { | |
39 // TODO Auto-generated method stub | |
40 // final WstInfo wst = result.getWst(); | |
41 // exportContext.writeCSVWaterlevelMetadata(writer, wst); | |
42 // if hasMetadata... | |
43 exportContextCSV.writeBlankLine(); | |
44 } | |
45 | |
46 @Override | |
47 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final RiverInfo river) { | |
48 | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
49 final Collection<String> header = new ArrayList<>(6); |
9150 | 50 |
51 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
52 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.date)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
53 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.collisionGaugeW)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
54 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
55 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.discharge)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
56 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.dischargeZone)); |
9150 | 57 |
58 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
59 } | |
60 | |
61 @Override | |
62 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final ResultRow row) { | |
63 return formatRow(exportContextCSV, results, row); | |
64 } | |
65 | |
66 @Override | |
67 protected String[] formatPDFRow(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final ResultRow row) { | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
68 /* |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
69 * final Collection<String> lines = new ArrayList<>(6); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
70 * lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
71 * return lines.toArray(new String[lines.size()]); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
72 */ |
9150 | 73 return formatRow(exportContextCSV, results, row); |
74 } | |
75 | |
76 private String[] formatRow(final ExportContextCSV exportContextCSV, final CollisionCalculationResults results, final ResultRow row) { | |
77 | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
78 final Collection<String> lines = new ArrayList<>(6); |
9150 | 79 |
80 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
81 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.date)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
82 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.collisionGaugeW)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
83 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.gaugeLabel)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
84 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.discharge)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
85 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.dischargeZone)); |
9150 | 86 |
87 return lines.toArray(new String[lines.size()]); | |
88 } | |
89 | |
90 @Override | |
91 protected String getJasperFile() { | |
92 return JASPER_FILE; | |
93 } | |
94 | |
95 @Override | |
96 protected void addJRTableHeader(final ExportContextCSV exportContextCSV, final MetaAndTableJRDataSource source, final CollisionCalculationResults results) { | |
97 | |
98 /* column headings */ | |
99 exportContextCSV.addJRMetadata(source, "station_header", GeneralResultType.station); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
100 exportContextCSV.addJRMetadata(source, "date_header", GeneralResultType.date); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
101 exportContextCSV.addJRMetadata(source, "gaugew_header", SInfoResultType.collisionGaugeW); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
102 exportContextCSV.addJRMetadata(source, "gaugelabel_header", SInfoResultType.gaugeLabel); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
103 exportContextCSV.addJRMetadata(source, "discharge_header", SInfoResultType.discharge); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
104 exportContextCSV.addJRMetadata(source, "dischargezone_header", SInfoResultType.dischargeZone); |
9150 | 105 } |
106 } |