Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/CollisionCalcOverviewResult.java @ 9487:504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
author | mschaefer |
---|---|
date | Tue, 18 Sep 2018 12:21:17 +0200 |
parents | d194c5b24bf8 |
children |
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; | |
9487
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
14 import java.util.List; |
9150 | 15 |
9265 | 16 import org.apache.commons.collections.Predicate; |
9150 | 17 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; |
18 import org.dive4elements.river.artifacts.common.ExportContextCSV; | |
9195 | 19 import org.dive4elements.river.artifacts.common.ExportContextPDF; |
9150 | 20 import org.dive4elements.river.artifacts.common.GeneralResultType; |
9204
4f411c6ee3ae
Individual facets/themes for single years i the S-Info collisions output
mschaefer
parents:
9195
diff
changeset
|
21 import org.dive4elements.river.artifacts.common.IResultType; |
9150 | 22 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; |
23 import org.dive4elements.river.artifacts.common.ResultRow; | |
9487
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
24 import org.dive4elements.river.artifacts.model.DateRange; |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
25 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
9150 | 26 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
27 | |
28 /** | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
29 * Contains the results of a {@link CollisionCalculation}. |
9150 | 30 * |
31 * @author Gernot Belger | |
32 */ | |
9195 | 33 final public class CollisionCalcOverviewResult extends AbstractCalculationExportableResult { |
9150 | 34 |
35 private static final long serialVersionUID = 1L; | |
36 | |
37 private static final String JASPER_FILE = "/jasper/templates/sinfo.collision.overview.jrxml"; | |
38 | |
9487
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
39 private final boolean isEpochs; |
9204
4f411c6ee3ae
Individual facets/themes for single years i the S-Info collisions output
mschaefer
parents:
9195
diff
changeset
|
40 |
9487
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
41 private final List<DateRange> years; |
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
42 |
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
43 public CollisionCalcOverviewResult(final String label, final boolean isEpochs, final Collection<DateRange> years, final Collection<ResultRow> rows) { |
9150 | 44 super(label, rows); |
9487
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
45 this.isEpochs = isEpochs; |
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
46 this.years = new ArrayList<>(years); |
9204
4f411c6ee3ae
Individual facets/themes for single years i the S-Info collisions output
mschaefer
parents:
9195
diff
changeset
|
47 } |
4f411c6ee3ae
Individual facets/themes for single years i the S-Info collisions output
mschaefer
parents:
9195
diff
changeset
|
48 |
9487
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
49 public boolean getIsEpochs() { |
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
50 return this.isEpochs; |
9204
4f411c6ee3ae
Individual facets/themes for single years i the S-Info collisions output
mschaefer
parents:
9195
diff
changeset
|
51 } |
4f411c6ee3ae
Individual facets/themes for single years i the S-Info collisions output
mschaefer
parents:
9195
diff
changeset
|
52 |
9487
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
53 public List<DateRange> getYears() { |
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
54 return this.years; |
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
55 } |
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
56 |
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
57 public double[][] getStationPointsByYear(final IResultType type, final String years) { |
9204
4f411c6ee3ae
Individual facets/themes for single years i the S-Info collisions output
mschaefer
parents:
9195
diff
changeset
|
58 |
9265 | 59 final Predicate filter = new Predicate() { |
60 @Override | |
61 public boolean evaluate(final Object object) { | |
62 final ResultRow row = (ResultRow) object; | |
9487
504f63512379
Sinfo collisions: calculation of multiple epochs, avoiding duplicate collision events in the details report
mschaefer
parents:
9432
diff
changeset
|
63 return row.getValue(SInfoResultType.years).toString().equals(years); |
9265 | 64 } |
65 }; | |
9204
4f411c6ee3ae
Individual facets/themes for single years i the S-Info collisions output
mschaefer
parents:
9195
diff
changeset
|
66 |
9265 | 67 return getPoints(GeneralResultType.station, type, filter); |
9150 | 68 } |
69 | |
70 @Override | |
9195 | 71 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { |
9172 | 72 // do nothing so far |
9150 | 73 } |
74 | |
75 @Override | |
9195 | 76 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { |
9171 | 77 final int colSize = 3; |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9265
diff
changeset
|
78 exportContextCSV.writeTitleForTabs("sinfo.export.csv.title.collision.overview", 3); // Voraussetzung für Tabs ist, dass der Titel vor den Headern |
9204
4f411c6ee3ae
Individual facets/themes for single years i the S-Info collisions output
mschaefer
parents:
9195
diff
changeset
|
79 // geschrieben wird. |
9171 | 80 // Das ist etwas doof. |
9150 | 81 |
9171 | 82 final Collection<String> header = new ArrayList<>(colSize); |
9150 | 83 |
84 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
85 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.years)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
86 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.collisionCount)); |
9150 | 87 |
9171 | 88 exportContextCSV.writeCSVLine(header.toArray(new String[colSize])); |
9150 | 89 } |
90 | |
91 @Override | |
9195 | 92 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { |
93 return formatRow(exportContextCSV, row); | |
9150 | 94 } |
95 | |
96 @Override | |
9195 | 97 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { |
98 | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
99 final Collection<String> lines = new ArrayList<>(3); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
100 |
9195 | 101 lines.add(exportContextPDF.formatRowValue(row, GeneralResultType.station)); |
102 lines.add(exportContextPDF.formatRowValue(row, SInfoResultType.years)); | |
103 lines.add(exportContextPDF.formatRowValue(row, SInfoResultType.collisionCount)); | |
104 | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
105 return lines.toArray(new String[lines.size()]); |
9150 | 106 } |
107 | |
9195 | 108 private String[] formatRow(final ExportContextCSV exportContextCSV, final ResultRow row) { |
9150 | 109 |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
110 final Collection<String> lines = new ArrayList<>(3); |
9150 | 111 |
112 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
113 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.years)); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
114 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.collisionCount)); |
9150 | 115 |
116 return lines.toArray(new String[lines.size()]); | |
117 } | |
118 | |
119 @Override | |
120 protected String getJasperFile() { | |
121 return JASPER_FILE; | |
122 } | |
123 | |
124 @Override | |
9195 | 125 protected void addJRTableHeader(final ExportContextPDF exportContext, final MetaAndTableJRDataSource source) { |
9150 | 126 |
127 /* column headings */ | |
9195 | 128 exportContext.addJRMetadata(source, "station_header", GeneralResultType.station); |
129 exportContext.addJRMetadata(source, "collision_years_header", SInfoResultType.years); | |
130 exportContext.addJRMetadata(source, "collision_count_header", SInfoResultType.collisionCount); | |
9150 | 131 } |
132 } |