[PATCH 4 of 4] issue1658: Adjuste facet descriptions to include unit
Wald Commits
scm-commit at wald.intevation.org
Mon Nov 4 17:25:00 CET 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1383582273 -3600
# Node ID b8faaac715078783e1f461bae7107e0b953ab40b
# Parent 0d45b1d6e432438c54eb22b875aa9a2445fce78d
issue1658: Adjuste facet descriptions to include unit.
diff -r 0d45b1d6e432 -r b8faaac71507 artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java
--- 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)");
diff -r 0d45b1d6e432 -r b8faaac71507 artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java
--- 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,137 @@
meta,
I18N_FACET_SEDIMENTLOAD_SAND,
I18N_FACET_SEDIMENTLOAD_SAND) +
- " - " + res.getStartYear(),
+ facetNameInfo(res, unit),
+ ComputeType.ADVANCE,
+ stateId,
+ hash));
+ }
+ if (res.hasFineMiddleData()) {
+ newFacets.add(new SedimentLoadFacet(
+ idx,
+ (isUnitTA)
+ ?SEDIMENT_LOAD_TA_FINEMIDDLE
+ :SEDIMENT_LOAD_M3A_FINEMIDDLE,
+ Resources.getMsg(
+ meta,
+ I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE,
+ I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE) +
+ facetNameInfo(res, unit),
+ ComputeType.ADVANCE,
+ stateId,
+ hash));
+ }
+ if (res.hasSuspSandData()) {
+ newFacets.add(new SedimentLoadFacet(
+ idx,
+ (isUnitTA)
+ ?SEDIMENT_LOAD_TA_SUSP_SAND
+ :SEDIMENT_LOAD_M3A_SUSP_SAND,
+ Resources.getMsg(
+ meta,
+ I18N_FACET_SEDIMENTLOAD_SUSPSAND,
+ I18N_FACET_SEDIMENTLOAD_SUSPSAND) +
+ facetNameInfo(res, unit),
+ ComputeType.ADVANCE,
+ stateId,
+ hash));
+ }
+ if (res.hasSuspSandBedData()) {
+ newFacets.add(new SedimentLoadFacet(
+ idx,
+ (isUnitTA)
+ ?SEDIMENT_LOAD_TA_SUSP_SAND_BED
+ :SEDIMENT_LOAD_M3A_SUSP_SAND_BED,
+ Resources.getMsg(
+ meta,
+ I18N_FACET_SEDIMENTLOAD_SUSPSANDBED,
+ I18N_FACET_SEDIMENTLOAD_SUSPSANDBED) +
+ facetNameInfo(res, unit),
+ ComputeType.ADVANCE,
+ stateId,
+ hash));
+ }
+ if (res.hasSuspSedimentData()) {
+ newFacets.add(new SedimentLoadFacet(
+ idx,
+ (isUnitTA)
+ ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT
+ :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT,
+ Resources.getMsg(
+ meta,
+ I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT,
+ I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT) +
+ facetNameInfo(res, unit),
+ ComputeType.ADVANCE,
+ stateId,
+ hash));
+
+ }
+ if (res.hasTotalData()) {
+ newFacets.add(new SedimentLoadFacet(
+ idx,
+ (isUnitTA)
+ ?SEDIMENT_LOAD_TA_TOTAL
+ :SEDIMENT_LOAD_M3A_TOTAL,
+ Resources.getMsg(
+ meta,
+ I18N_FACET_SEDIMENTLOAD_TOTAL,
+ I18N_FACET_SEDIMENTLOAD_TOTAL) +
+ facetNameInfo(res, unit),
+ ComputeType.ADVANCE,
+ stateId,
+ hash));
+ }
+ }
+ }
+
+ private String epochFacetNameInfo(SedimentLoadResult result, String unit) {
+ return " - " + result.getStartYear() + "-" + result.getEndYear() + " " + unit;
+ }
+
+ protected void generateEpochFacets(
+ CallContext context,
+ List<Facet> newFacets,
+ SedimentLoadResult[] results,
+ String stateId,
+ String hash
+ ) {
+ 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];
+ if (res.hasCoarseData()) {
+ newFacets.add(new SedimentLoadFacet(
+ idx,
+ (isUnitTA)
+ ?SEDIMENT_LOAD_TA_COARSE
+ :SEDIMENT_LOAD_M3A_COARSE,
+ Resources.getMsg(
+ meta,
+ I18N_FACET_SEDIMENTLOAD_COARSE,
+ I18N_FACET_SEDIMENTLOAD_COARSE) +
+ epochFacetNameInfo(res,unit),
+ ComputeType.ADVANCE,
+ stateId,
+ hash));
+ }
+ if (res.hasSandData()) {
+ newFacets.add(new SedimentLoadFacet(
+ idx,
+ (isUnitTA)
+ ?SEDIMENT_LOAD_TA_SAND
+ :SEDIMENT_LOAD_M3A_SAND,
+ Resources.getMsg(
+ meta,
+ I18N_FACET_SEDIMENTLOAD_SAND,
+ I18N_FACET_SEDIMENTLOAD_SAND) +
+ epochFacetNameInfo(res,unit),
ComputeType.ADVANCE,
stateId,
hash));
@@ -257,7 +397,7 @@
meta,
I18N_FACET_SEDIMENTLOAD_SUSPSAND,
I18N_FACET_SEDIMENTLOAD_SUSPSAND)
- + " - " + res.getStartYear(),
+ + epochFacetNameInfo(res,unit),
ComputeType.ADVANCE,
stateId,
hash));
@@ -267,12 +407,12 @@
idx,
(isUnitTA)
?SEDIMENT_LOAD_TA_SUSP_SAND_BED
- :SEDIMENT_LOAD_M3A_SUSP_SAND_BED,
+ :SEDIMENT_LOAD_M3A_SUSP_SAND,
Resources.getMsg(
meta,
I18N_FACET_SEDIMENTLOAD_SUSPSANDBED,
I18N_FACET_SEDIMENTLOAD_SUSPSANDBED) +
- " - " + res.getStartYear(),
+ epochFacetNameInfo(res,unit),
ComputeType.ADVANCE,
stateId,
hash));
@@ -287,131 +427,7 @@
meta,
I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT,
I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT) +
- " - " + res.getStartYear(),
- ComputeType.ADVANCE,
- stateId,
- hash));
-
- }
- if (res.hasTotalData()) {
- newFacets.add(new SedimentLoadFacet(
- idx,
- (isUnitTA)
- ?SEDIMENT_LOAD_TA_TOTAL
- :SEDIMENT_LOAD_M3A_TOTAL,
- Resources.getMsg(
- meta,
- I18N_FACET_SEDIMENTLOAD_TOTAL,
- I18N_FACET_SEDIMENTLOAD_TOTAL) +
- " - " + res.getStartYear(),
- ComputeType.ADVANCE,
- stateId,
- hash));
- }
- }
- }
-
- protected void generateEpochFacets(
- CallContext context,
- List<Facet> newFacets,
- SedimentLoadResult[] results,
- String stateId,
- String hash
- ) {
- logger.debug("SedimentLoadCalculate.generateEpochFacets");
-
- CallMeta meta = context.getMeta();
- boolean isUnitTA = access.getUnit().startsWith("t");
-
-// newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
- for (int idx = 0; idx < results.length; idx++) {
- SedimentLoadResult res = results[idx];
- if (res.hasCoarseData()) {
- newFacets.add(new SedimentLoadFacet(
- idx,
- (isUnitTA)
- ?SEDIMENT_LOAD_TA_COARSE
- :SEDIMENT_LOAD_M3A_COARSE,
- Resources.getMsg(
- meta,
- I18N_FACET_SEDIMENTLOAD_COARSE,
- I18N_FACET_SEDIMENTLOAD_COARSE) +
- " - " + res.getStartYear() + "-" + res.getEndYear(),
- ComputeType.ADVANCE,
- stateId,
- hash));
- }
- if (res.hasSandData()) {
- newFacets.add(new SedimentLoadFacet(
- idx,
- (isUnitTA)
- ?SEDIMENT_LOAD_TA_SAND
- :SEDIMENT_LOAD_M3A_SAND,
- Resources.getMsg(
- meta,
- I18N_FACET_SEDIMENTLOAD_SAND,
- I18N_FACET_SEDIMENTLOAD_SAND) +
- " - " + res.getStartYear() + "-" + res.getEndYear(),
- ComputeType.ADVANCE,
- stateId,
- hash));
- }
- if (res.hasFineMiddleData()) {
- newFacets.add(new SedimentLoadFacet(
- idx,
- (isUnitTA)
- ?SEDIMENT_LOAD_TA_FINEMIDDLE
- :SEDIMENT_LOAD_M3A_FINEMIDDLE,
- Resources.getMsg(
- meta,
- I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE,
- I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE) +
- " - " + res.getStartYear(),
- ComputeType.ADVANCE,
- stateId,
- hash));
- }
- if (res.hasSuspSandData()) {
- newFacets.add(new SedimentLoadFacet(
- idx,
- (isUnitTA)
- ?SEDIMENT_LOAD_TA_SUSP_SAND
- :SEDIMENT_LOAD_M3A_SUSP_SAND,
- Resources.getMsg(
- meta,
- I18N_FACET_SEDIMENTLOAD_SUSPSAND,
- I18N_FACET_SEDIMENTLOAD_SUSPSAND)
- + " - " + res.getStartYear() + "-" + res.getEndYear(),
- ComputeType.ADVANCE,
- stateId,
- hash));
- }
- if (res.hasSuspSandBedData()) {
- newFacets.add(new SedimentLoadFacet(
- idx,
- (isUnitTA)
- ?SEDIMENT_LOAD_TA_SUSP_SAND_BED
- :SEDIMENT_LOAD_M3A_SUSP_SAND,
- Resources.getMsg(
- meta,
- I18N_FACET_SEDIMENTLOAD_SUSPSANDBED,
- I18N_FACET_SEDIMENTLOAD_SUSPSANDBED) +
- " - " + res.getStartYear() + "-" + res.getEndYear(),
- ComputeType.ADVANCE,
- stateId,
- hash));
- }
- if (res.hasSuspSedimentData()) {
- newFacets.add(new SedimentLoadFacet(
- idx,
- (isUnitTA)
- ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT
- :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT,
- Resources.getMsg(
- 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));
More information about the Dive4elements-commits
mailing list