changeset 8109:2707c3aa1aa7

(issue1681) Handle different grain fraction kinds
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 20 Aug 2014 13:17:03 +0200
parents cafcd64efbbf
children 4e7c8e7ac3c0
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSFacet.java
diffstat 1 files changed, 27 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSFacet.java	Wed Aug 20 12:59:01 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSFacet.java	Wed Aug 20 13:17:03 2014 +0200
@@ -59,7 +59,7 @@
 
     /* Aheinecke we probably need to get the kind and split this up here
      * in some way */
-    private static final String NAME = SEDIMENT_LOAD_TA_STATIC;
+    private static final String NAME = "sedimentload";
 
     public SedimentLoadLSFacet() {
     }
@@ -120,17 +120,38 @@
             return;
         }
         logger.debug("Setting up SedimentLoadLSFacet for id: " + id);
-        logger.debug("GrainFraction: " + theLoad.getGrainFraction().getName());
+        if (theLoad.getGrainFraction() != null) {
+            logger.debug("GrainFraction: " + theLoad.getGrainFraction().getName());
+        }
         logger.debug("Kind: " + theLoad.getKind());
         logger.debug("Unit: " + theLoad.getUnit().getName());
 
-        /* TODO: Name is important. We have to add the Grain Fraction and the
-         * unit in here so that theming is done correctly and unit is correct.*/
+        /* Name has the pattern sedimentload.<unit>.<grainfraction_name>
+         * this is partly done for backwards compatibility and theming.
+         * See issue 1681 for details. */
         name = NAME;
+
+        if (theLoad.getUnit().getName().equals("m3/a")) {
+            /* unit_id is NOT NULL */
+            name += ".m3a";
+        } else {
+            name += ".ta";
+        }
+
+        String gfName;
+        if (theLoad.getGrainFraction() != null) {
+            gfName =  theLoad.getGrainFraction().getName();
+        } else {
+            gfName = "unknown";
+        }
+        name += "." + gfName;
+
+        logger.debug("Created facet: " + name);
+
         description = Resources.getMsg(
                 callMeta,
-                "facet.sedimentload",
-                "Sedimentload",
+                "facet.sedimentload.dc." + gfName,
+                "Error: please add l10n for facet.sedimentload.dc." + gfName,
                 new Object[] { desc });
         ((D4EArtifact)artifact).addStringData("load_id", idStr);
     }

http://dive4elements.wald.intevation.org