Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java @ 9614:d889ffe2fb05
Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
author | mschaefer |
---|---|
date | Wed, 09 Oct 2019 19:17:06 +0200 |
parents | f8308db94634 |
children | 26e113e8224f 36d201244529 |
comparison
equal
deleted
inserted
replaced
9612:f8308db94634 | 9614:d889ffe2fb05 |
---|---|
72 | 72 |
73 public static final class Infrastructure implements Serializable { | 73 public static final class Infrastructure implements Serializable { |
74 | 74 |
75 private static final long serialVersionUID = 1L; | 75 private static final long serialVersionUID = 1L; |
76 | 76 |
77 private final String m_group; | |
78 | |
77 private final String m_type; | 79 private final String m_type; |
78 | 80 |
79 private final String m_part; | |
80 | |
81 private final AttributeKey m_riverside; | 81 private final AttributeKey m_riverside; |
82 | 82 |
83 private static final String FACET_FLOOD_DURATION_DESCRIPTION = "sinfo_facet_flood_duration"; | 83 private static final String FACET_FLOOD_DURATION_DESCRIPTION = "sinfo_facet_flood_duration"; |
84 | 84 |
85 private static final String FACET_ABSOLUTE_HEIGHT = "sinfo.flood_duration.absolute.height"; | 85 private static final String FACET_ABSOLUTE_HEIGHT = "sinfo.flood_duration.absolute.height"; |
86 | 86 |
87 public Infrastructure(final ResultRow row) { | 87 public Infrastructure(final ResultRow row) { |
88 this.m_group = String.valueOf(row.getValue(SInfoResultType.infrastructuregroup)); | |
88 this.m_type = String.valueOf(row.getValue(SInfoResultType.infrastructuretype)); | 89 this.m_type = String.valueOf(row.getValue(SInfoResultType.infrastructuretype)); |
89 this.m_part = String.valueOf(row.getValue(SInfoResultType.infrastructurepart)); | |
90 final String riversideStr = String.valueOf(row.getValue(SInfoResultType.riverside)); | 90 final String riversideStr = String.valueOf(row.getValue(SInfoResultType.riverside)); |
91 this.m_riverside = riversideStr.equals("null") ? AttributeKey.NONE : AttributeKey.valueOf(riversideStr); | 91 this.m_riverside = riversideStr.equals("null") ? AttributeKey.NONE : AttributeKey.valueOf(riversideStr); |
92 } | 92 } |
93 | 93 |
94 public AttributeKey getRiverside() { | 94 public AttributeKey getRiverside() { |
96 } | 96 } |
97 | 97 |
98 @Override | 98 @Override |
99 public int hashCode() { | 99 public int hashCode() { |
100 return new HashCodeBuilder() // | 100 return new HashCodeBuilder() // |
101 .append(this.m_group)// | |
101 .append(this.m_type)// | 102 .append(this.m_type)// |
102 .append(this.m_part)// | |
103 .append(this.m_riverside)// | 103 .append(this.m_riverside)// |
104 .toHashCode(); | 104 .toHashCode(); |
105 } | 105 } |
106 | 106 |
107 @Override | 107 @Override |
114 if (obj.getClass() != getClass()) | 114 if (obj.getClass() != getClass()) |
115 return false; | 115 return false; |
116 | 116 |
117 final Infrastructure other = (Infrastructure) obj; | 117 final Infrastructure other = (Infrastructure) obj; |
118 return new EqualsBuilder() // | 118 return new EqualsBuilder() // |
119 .append(this.m_group, other.m_group) // | |
119 .append(this.m_type, other.m_type) // | 120 .append(this.m_type, other.m_type) // |
120 .append(this.m_part, other.m_part) // | |
121 .append(this.m_riverside, other.m_riverside) // | 121 .append(this.m_riverside, other.m_riverside) // |
122 .isEquals(); | 122 .isEquals(); |
123 } | 123 } |
124 | 124 |
125 public String getFloodHeightLabel(final CallContext context) { | 125 public String getFloodHeightLabel(final CallContext context) { |
126 return Resources.getMsg(context.getMeta(), FACET_ABSOLUTE_HEIGHT, FACET_ABSOLUTE_HEIGHT) + " " + this.m_type + " - " + this.m_part + " (" | 126 return Resources.getMsg(context.getMeta(), FACET_ABSOLUTE_HEIGHT, FACET_ABSOLUTE_HEIGHT) |
127 + getLocalizedRiverside(context) + ")"; | 127 + " " + SInfoResultType.getInfrastructureLabel(context, this.m_group, this.m_type, this.m_riverside); |
128 } | 128 } |
129 | 129 |
130 public String getFloodDurationLabel(final CallContext context) { | 130 public String getFloodDurationLabel(final CallContext context) { |
131 return Resources.getMsg(context.getMeta(), FACET_FLOOD_DURATION_DESCRIPTION, FACET_FLOOD_DURATION_DESCRIPTION) + " " + this.m_type + " - " | 131 return Resources.getMsg(context.getMeta(), FACET_FLOOD_DURATION_DESCRIPTION, FACET_FLOOD_DURATION_DESCRIPTION) |
132 + this.m_part + " (" + getLocalizedRiverside(context) + ")"; | 132 + " " + SInfoResultType.getInfrastructureLabel(context, this.m_group, this.m_type, this.m_riverside); |
133 } | |
134 | |
135 private String getLocalizedRiverside(final CallContext callContext) { | |
136 return SInfoResultType.localizeRiverside(callContext, this.m_riverside); | |
137 } | 133 } |
138 } | 134 } |
139 | 135 |
140 private static final long serialVersionUID = 1L; | 136 private static final long serialVersionUID = 1L; |
141 | 137 |
143 | 139 |
144 private final String[] waterlevelLabels; | 140 private final String[] waterlevelLabels; |
145 | 141 |
146 private final int maxWaterlevelPdf = 3; | 142 private final int maxWaterlevelPdf = 3; |
147 | 143 |
148 private final Set<Infrastructure> m_infastructures; | 144 private final Set<Infrastructure> m_infrastructures; |
149 | 145 |
150 public interface ValueGetter { | 146 public interface ValueGetter { |
151 double getValue(DurationWaterlevel waterlevel); | 147 double getValue(DurationWaterlevel waterlevel); |
152 } | 148 } |
153 | 149 |
158 public FloodDurationCalculationResult(final String label, final String[] mainvalueLabels, final Collection<ResultRow> rows, final boolean isUseWspl, | 154 public FloodDurationCalculationResult(final String label, final String[] mainvalueLabels, final Collection<ResultRow> rows, final boolean isUseWspl, |
159 final Set<Infrastructure> infrastructures) { | 155 final Set<Infrastructure> infrastructures) { |
160 super(label, rows); | 156 super(label, rows); |
161 this.waterlevelLabels = mainvalueLabels; | 157 this.waterlevelLabels = mainvalueLabels; |
162 this.isUseWspl = isUseWspl; | 158 this.isUseWspl = isUseWspl; |
163 this.m_infastructures = infrastructures; | 159 this.m_infrastructures = infrastructures; |
164 } | 160 } |
165 | 161 |
166 public Set<Infrastructure> getInfastructureMap() { | 162 public Set<Infrastructure> getInfrastructureMap() { |
167 return this.m_infastructures; | 163 return this.m_infrastructures; |
168 } | 164 } |
169 | 165 |
170 /** | 166 /** |
171 * Collection of the result rows containing only the rows describing an infrastructure | 167 * Collection of the result rows containing only the rows describing an infrastructure |
172 */ | 168 */ |
176 | 172 |
177 final Collection<ResultRow> rows = super.getRows(); | 173 final Collection<ResultRow> rows = super.getRows(); |
178 | 174 |
179 final List<ResultRow> infrasOnlyRows = new ArrayList<>(); | 175 final List<ResultRow> infrasOnlyRows = new ArrayList<>(); |
180 for (final ResultRow row : rows) { | 176 for (final ResultRow row : rows) { |
181 if (row.getValue(SInfoResultType.infrastructuretype) != null && row.getValue(SInfoResultType.infrastructurepart) != null) | 177 if (row.getValue(SInfoResultType.infrastructuregroup) != null && row.getValue(SInfoResultType.infrastructuretype) != null) |
182 infrasOnlyRows.add(row); | 178 infrasOnlyRows.add(row); |
183 } | 179 } |
184 return Collections.unmodifiableCollection(infrasOnlyRows); | 180 return Collections.unmodifiableCollection(infrasOnlyRows); |
185 } | 181 } |
186 | 182 |
214 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDuration)); | 210 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDuration)); |
215 | 211 |
216 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDischarge)); | 212 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDischarge)); |
217 | 213 |
218 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructureHeight)); | 214 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructureHeight)); |
215 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuregroup)); | |
219 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuretype)); | 216 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuretype)); |
220 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructurepart)); | |
221 | 217 |
222 final List<DurationWaterlevel> waterlevelList = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel); | 218 final List<DurationWaterlevel> waterlevelList = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel); |
223 | 219 |
224 final int expectedSizetoGaugelabel = lines.size() + (waterlevelList.size() < 2 ? 4 : 12); // removing columns only works for fixed | 220 final int expectedSizetoGaugelabel = lines.size() + (waterlevelList.size() < 2 ? 4 : 12); // removing columns only works for fixed |
225 // indices | 221 // indices |
260 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | 256 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); |
261 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.riverside)); | 257 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.riverside)); |
262 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.floodDuration)); | 258 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.floodDuration)); |
263 header.add(exportContextCSV.msgUnitCSV(SInfoResultType.floodDischarge, SInfoResultType.floodDischarge.getUnit())); | 259 header.add(exportContextCSV.msgUnitCSV(SInfoResultType.floodDischarge, SInfoResultType.floodDischarge.getUnit())); |
264 header.add(exportContextCSV.msgUnitCSV(SInfoResultType.infrastructureHeight, river.getWstUnit())); | 260 header.add(exportContextCSV.msgUnitCSV(SInfoResultType.infrastructureHeight, river.getWstUnit())); |
261 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.infrastructuregroup)); | |
265 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.infrastructuretype)); | 262 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.infrastructuretype)); |
266 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.infrastructurepart)); | |
267 | 263 |
268 // add dynamic headers | 264 // add dynamic headers |
269 final int waterlevelCount = // results. | 265 final int waterlevelCount = // results. |
270 getWaterlevelCount(); | 266 getWaterlevelCount(); |
271 for (int i = 0; i < waterlevelCount; i++) { | 267 for (int i = 0; i < waterlevelCount; i++) { |
310 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); | 306 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); |
311 exportContextPDF.addJRMetadata(source, "riverside_header", SInfoResultType.riverside); | 307 exportContextPDF.addJRMetadata(source, "riverside_header", SInfoResultType.riverside); |
312 exportContextPDF.addJRMetadata(source, "inundationduration_header", SInfoResultType.floodDuration); | 308 exportContextPDF.addJRMetadata(source, "inundationduration_header", SInfoResultType.floodDuration); |
313 exportContextPDF.addJRMetadata(source, "inundationduration_q_header", SInfoResultType.floodDischarge); | 309 exportContextPDF.addJRMetadata(source, "inundationduration_q_header", SInfoResultType.floodDischarge); |
314 exportContextPDF.addJRMetadata(source, "infrastructure_height_header", SInfoResultType.infrastructureHeight); | 310 exportContextPDF.addJRMetadata(source, "infrastructure_height_header", SInfoResultType.infrastructureHeight); |
315 exportContextPDF.addJRMetadata(source, "infrastructure_type_header", SInfoResultType.infrastructuretype); | 311 // FIXME Tironi: report-keys ..type => ..group und ..part => ..type umbenennen zwecks Einheitlichkeit |
316 exportContextPDF.addJRMetadata(source, "infrastructure_part_header", SInfoResultType.infrastructurepart); | 312 exportContextPDF.addJRMetadata(source, "infrastructure_type_header", SInfoResultType.infrastructuregroup); |
313 exportContextPDF.addJRMetadata(source, "infrastructure_part_header", SInfoResultType.infrastructuretype); | |
317 | 314 |
318 for (int i = 1; i <= this.getWaterlevelCount(); i++) { | 315 for (int i = 1; i <= this.getWaterlevelCount(); i++) { |
319 | 316 |
320 final String appendIndex = "_" + Integer.toString(i); | 317 final String appendIndex = "_" + Integer.toString(i); |
321 exportContextPDF.addJRMetadata(source, getPdfHeader("w", i), exportContextPDF.msg(DurationWaterlevel.getHeaderWPdf(), appendIndex)); | 318 exportContextPDF.addJRMetadata(source, getPdfHeader("w", i), exportContextPDF.msg(DurationWaterlevel.getHeaderWPdf(), appendIndex)); |