changeset 7520:b8faaac71507

issue1658: Adjuste facet descriptions to include unit.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 04 Nov 2013 17:24:33 +0100
parents 0d45b1d6e432
children ea3e78a7f4e4
files artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java
diffstat 2 files changed, 50 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java	Mon Nov 04 17:15:20 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java	Mon Nov 04 17:24:33 2013 +0100
@@ -161,7 +161,8 @@
             boolean unitIsTA =
                 SedimentLoadFactory.getSedimentYieldUnitName(id).startsWith("t");
 
-            name += " " + (unitIsTA)
+            name += " ";
+            name += (unitIsTA)
                 ? Resources.getMsg(callMeta, "state.minfo.sediment.load.t_per_a", "(t/a)")
                 : Resources.getMsg(callMeta, "state.minfo.sediment.load.m3_per_a", "(m^3/a)");
 
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java	Mon Nov 04 17:15:20 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java	Mon Nov 04 17:24:33 2013 +0100
@@ -192,12 +192,22 @@
         return res;
     }
 
-    protected void generateYearFacets(CallContext context, List<Facet> newFacets,
-        SedimentLoadResult[] results, String stateId, String hash) {
-        logger.debug("SedimentLoadCalculate.generateFacets");
+    private String facetNameInfo(SedimentLoadResult result, String unit) {
+        return " - " + result.getStartYear() + " " + unit;
+    }
+
+
+    protected void generateYearFacets(CallContext context,
+        List<Facet> newFacets,
+        SedimentLoadResult[] results, String stateId, String hash
+    ) {
+        logger.debug("SedimentLoadCalculate.generateFacets " + access.getUnit());
 
         CallMeta meta = context.getMeta();
         boolean isUnitTA = access.getUnit().startsWith("t");
+        String unit = (isUnitTA)
+            ? Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.t_per_a", "(t/a)")
+            : Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.m3_per_a", "(m^3/a)");
 
 //      newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
         for (int idx = 0; idx < results.length; idx++) {
@@ -212,7 +222,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_COARSE,
                         I18N_FACET_SEDIMENTLOAD_COARSE) +
-                        " - " + res.getStartYear(),
+                        facetNameInfo(res, unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -227,7 +237,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SAND,
                         I18N_FACET_SEDIMENTLOAD_SAND) +
-                        " - " + res.getStartYear(),
+                        facetNameInfo(res, unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -242,7 +252,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE,
                         I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE) +
-                        " - " + res.getStartYear(),
+                        facetNameInfo(res, unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -256,8 +266,8 @@
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSAND,
-                        I18N_FACET_SEDIMENTLOAD_SUSPSAND)
-                        + " - " + res.getStartYear(),
+                        I18N_FACET_SEDIMENTLOAD_SUSPSAND) +
+                        facetNameInfo(res, unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -272,7 +282,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSANDBED,
                         I18N_FACET_SEDIMENTLOAD_SUSPSANDBED) +
-                        " - " + res.getStartYear(),
+                        facetNameInfo(res, unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -287,7 +297,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT,
                         I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT) +
-                        " - " + res.getStartYear(),
+                        facetNameInfo(res, unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -303,7 +313,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_TOTAL,
                         I18N_FACET_SEDIMENTLOAD_TOTAL) +
-                        " - " + res.getStartYear(),
+                        facetNameInfo(res, unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -311,6 +321,10 @@
         }
     }
 
+    private String epochFacetNameInfo(SedimentLoadResult result, String unit) {
+        return " - " + result.getStartYear() + "-" + result.getEndYear() + " " + unit;
+    }
+
     protected void generateEpochFacets(
         CallContext context,
         List<Facet> newFacets,
@@ -318,14 +332,16 @@
         String stateId,
         String hash
     ) {
-        logger.debug("SedimentLoadCalculate.generateEpochFacets");
+        logger.debug("SedimentLoadCalculate.generateEpochFacets ");
 
         CallMeta meta = context.getMeta();
         boolean isUnitTA = access.getUnit().startsWith("t");
+        String unit = (isUnitTA)
+            ? Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.t_per_a", "(t/a)")
+            : Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.m3_per_a", "(m^3/a)");
 
 //      newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
-        for (int idx = 0; idx < results.length; idx++) {
-            SedimentLoadResult res = results[idx];
+        for (int idx = 0; idx < results.length; idx++) {            SedimentLoadResult res = results[idx];
             if (res.hasCoarseData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
@@ -336,7 +352,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_COARSE,
                         I18N_FACET_SEDIMENTLOAD_COARSE) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -351,7 +367,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SAND,
                         I18N_FACET_SEDIMENTLOAD_SAND) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -381,7 +397,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSAND,
                         I18N_FACET_SEDIMENTLOAD_SUSPSAND)
-                        + " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        + epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -396,7 +412,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSANDBED,
                         I18N_FACET_SEDIMENTLOAD_SUSPSANDBED) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -411,7 +427,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT,
                         I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -427,7 +443,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD,
                         I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -442,7 +458,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_TOTAL,
                         I18N_FACET_SEDIMENTLOAD_TOTAL) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -461,6 +477,9 @@
 
         CallMeta meta = context.getMeta();
         boolean isUnitTA = access.getUnit().startsWith("t");
+        String unit = (isUnitTA)
+            ? Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.t_per_a", "(t/a)")
+            : Resources.getMsg(context.getMeta(), "state.minfo.sediment.load.m3_per_a", "(m^3/a)");
 
 //      newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
         for (int idx = 0; idx < results.length; idx++) {
@@ -475,7 +494,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_COARSE,
                         I18N_FACET_SEDIMENTLOAD_COARSE) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -490,7 +509,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SAND,
                         I18N_FACET_SEDIMENTLOAD_SAND) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -505,7 +524,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE,
                         I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -520,7 +539,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSAND,
                         I18N_FACET_SEDIMENTLOAD_SUSPSAND) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -535,7 +554,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSANDBED,
                         I18N_FACET_SEDIMENTLOAD_SUSPSANDBED) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -550,7 +569,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT,
                         I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -566,7 +585,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD,
                         I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
@@ -581,7 +600,7 @@
                         meta,
                         I18N_FACET_SEDIMENTLOAD_TOTAL,
                         I18N_FACET_SEDIMENTLOAD_TOTAL) +
-                        " - " + res.getStartYear() + "-" + res.getEndYear(),
+                        epochFacetNameInfo(res,unit),
                     ComputeType.ADVANCE,
                     stateId,
                     hash));

http://dive4elements.wald.intevation.org