diff 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
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java	Wed Oct 09 16:17:16 2019 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java	Wed Oct 09 19:17:06 2019 +0200
@@ -74,10 +74,10 @@
 
         private static final long serialVersionUID = 1L;
 
+        private final String m_group;
+
         private final String m_type;
 
-        private final String m_part;
-
         private final AttributeKey m_riverside;
 
         private static final String FACET_FLOOD_DURATION_DESCRIPTION = "sinfo_facet_flood_duration";
@@ -85,8 +85,8 @@
         private static final String FACET_ABSOLUTE_HEIGHT = "sinfo.flood_duration.absolute.height";
 
         public Infrastructure(final ResultRow row) {
+            this.m_group = String.valueOf(row.getValue(SInfoResultType.infrastructuregroup));
             this.m_type = String.valueOf(row.getValue(SInfoResultType.infrastructuretype));
-            this.m_part = String.valueOf(row.getValue(SInfoResultType.infrastructurepart));
             final String riversideStr = String.valueOf(row.getValue(SInfoResultType.riverside));
             this.m_riverside = riversideStr.equals("null") ? AttributeKey.NONE : AttributeKey.valueOf(riversideStr);
         }
@@ -98,8 +98,8 @@
         @Override
         public int hashCode() {
             return new HashCodeBuilder() //
+                    .append(this.m_group)//
                     .append(this.m_type)//
-                    .append(this.m_part)//
                     .append(this.m_riverside)//
                     .toHashCode();
         }
@@ -116,24 +116,20 @@
 
             final Infrastructure other = (Infrastructure) obj;
             return new EqualsBuilder() //
+                    .append(this.m_group, other.m_group) //
                     .append(this.m_type, other.m_type) //
-                    .append(this.m_part, other.m_part) //
                     .append(this.m_riverside, other.m_riverside) //
                     .isEquals();
         }
 
         public String getFloodHeightLabel(final CallContext context) {
-            return Resources.getMsg(context.getMeta(), FACET_ABSOLUTE_HEIGHT, FACET_ABSOLUTE_HEIGHT) + " " + this.m_type + " - " + this.m_part + " ("
-                    + getLocalizedRiverside(context) + ")";
+            return Resources.getMsg(context.getMeta(), FACET_ABSOLUTE_HEIGHT, FACET_ABSOLUTE_HEIGHT)
+                    + " " + SInfoResultType.getInfrastructureLabel(context, this.m_group, this.m_type, this.m_riverside);
         }
 
         public String getFloodDurationLabel(final CallContext context) {
-            return Resources.getMsg(context.getMeta(), FACET_FLOOD_DURATION_DESCRIPTION, FACET_FLOOD_DURATION_DESCRIPTION) + " " + this.m_type + " - "
-                    + this.m_part + " (" + getLocalizedRiverside(context) + ")";
-        }
-
-        private String getLocalizedRiverside(final CallContext callContext) {
-            return SInfoResultType.localizeRiverside(callContext, this.m_riverside);
+            return Resources.getMsg(context.getMeta(), FACET_FLOOD_DURATION_DESCRIPTION, FACET_FLOOD_DURATION_DESCRIPTION)
+                    + " " + SInfoResultType.getInfrastructureLabel(context, this.m_group, this.m_type, this.m_riverside);
         }
     }
 
@@ -145,7 +141,7 @@
 
     private final int maxWaterlevelPdf = 3;
 
-    private final Set<Infrastructure> m_infastructures;
+    private final Set<Infrastructure> m_infrastructures;
 
     public interface ValueGetter {
         double getValue(DurationWaterlevel waterlevel);
@@ -160,11 +156,11 @@
         super(label, rows);
         this.waterlevelLabels = mainvalueLabels;
         this.isUseWspl = isUseWspl;
-        this.m_infastructures = infrastructures;
+        this.m_infrastructures = infrastructures;
     }
 
-    public Set<Infrastructure> getInfastructureMap() {
-        return this.m_infastructures;
+    public Set<Infrastructure> getInfrastructureMap() {
+        return this.m_infrastructures;
     }
 
     /**
@@ -178,7 +174,7 @@
 
         final List<ResultRow> infrasOnlyRows = new ArrayList<>();
         for (final ResultRow row : rows) {
-            if (row.getValue(SInfoResultType.infrastructuretype) != null && row.getValue(SInfoResultType.infrastructurepart) != null)
+            if (row.getValue(SInfoResultType.infrastructuregroup) != null && row.getValue(SInfoResultType.infrastructuretype) != null)
                 infrasOnlyRows.add(row);
         }
         return Collections.unmodifiableCollection(infrasOnlyRows);
@@ -216,8 +212,8 @@
         lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDischarge));
 
         lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructureHeight));
+        lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuregroup));
         lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuretype));
-        lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructurepart));
 
         final List<DurationWaterlevel> waterlevelList = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel);
 
@@ -262,8 +258,8 @@
         header.add(exportContextCSV.formatCsvHeader(SInfoResultType.floodDuration));
         header.add(exportContextCSV.msgUnitCSV(SInfoResultType.floodDischarge, SInfoResultType.floodDischarge.getUnit()));
         header.add(exportContextCSV.msgUnitCSV(SInfoResultType.infrastructureHeight, river.getWstUnit()));
+        header.add(exportContextCSV.formatCsvHeader(SInfoResultType.infrastructuregroup));
         header.add(exportContextCSV.formatCsvHeader(SInfoResultType.infrastructuretype));
-        header.add(exportContextCSV.formatCsvHeader(SInfoResultType.infrastructurepart));
 
         // add dynamic headers
         final int waterlevelCount = // results.
@@ -312,8 +308,9 @@
         exportContextPDF.addJRMetadata(source, "inundationduration_header", SInfoResultType.floodDuration);
         exportContextPDF.addJRMetadata(source, "inundationduration_q_header", SInfoResultType.floodDischarge);
         exportContextPDF.addJRMetadata(source, "infrastructure_height_header", SInfoResultType.infrastructureHeight);
-        exportContextPDF.addJRMetadata(source, "infrastructure_type_header", SInfoResultType.infrastructuretype);
-        exportContextPDF.addJRMetadata(source, "infrastructure_part_header", SInfoResultType.infrastructurepart);
+        // FIXME Tironi: report-keys ..type => ..group und ..part => ..type umbenennen zwecks Einheitlichkeit
+        exportContextPDF.addJRMetadata(source, "infrastructure_type_header", SInfoResultType.infrastructuregroup);
+        exportContextPDF.addJRMetadata(source, "infrastructure_part_header", SInfoResultType.infrastructuretype);
 
         for (int i = 1; i <= this.getWaterlevelCount(); i++) {
 

http://dive4elements.wald.intevation.org