[PATCH] (issue1602) We don't distinguish between types since sometime but we want to have metadata at the facet

Wald Commits scm-commit at wald.intevation.org
Fri Apr 24 18:01:44 CEST 2015


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1429891278 -7200
# Node ID 4e8c80ff07e3fd4efa3bd8fbac3bd82bbecf86c3
# Parent  6b68777aaeab8c303b4a6c143ffc8342665f3b00
(issue1602) We don't distinguish between types since sometime but we want to have metadata at the facet.

diff -r 6b68777aaeab -r 4e8c80ff07e3 artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java	Fri Apr 24 17:54:12 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java	Fri Apr 24 18:01:18 2015 +0200
@@ -123,8 +123,7 @@
                     facet = new BedHeightSoundingWidthFacet(facetType, bedHName);
                 }
                 else {
-                    facet = new BedHeightFacet(
-                        facetType, bedHName, type);
+                    facet = new BedHeightFacet(facetType, bedHName);
                 }
 
 
diff -r 6b68777aaeab -r 4e8c80ff07e3 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java	Fri Apr 24 17:54:12 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java	Fri Apr 24 18:01:18 2015 +0200
@@ -16,6 +16,7 @@
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.artifacts.access.BedHeightAccess;
 import org.dive4elements.river.artifacts.model.BlackboardDataFacet;
 import org.dive4elements.river.artifacts.model.FacetTypes;
@@ -28,12 +29,9 @@
 
     private static final Logger log = Logger.getLogger(BedHeightFacet.class);
 
-    private String type;
-
-    public BedHeightFacet(String name, String description, String type) {
+    public BedHeightFacet(String name, String description) {
         this.name = name;
         this.description = description;
-        this.type = type;
         this.index = 0;
         this.metaData.put("X", "chart.longitudinal.section.xaxis.label");
         this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label");
@@ -50,43 +48,36 @@
     @Override
     public Object getData(Artifact artifact, CallContext context) {
         BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact);
-        if (type.equals("singlevalues")) {
-            /* Former doc (from BedHeightAccess):
-             * Return a {@link List} of {@link BedHeightValue}s
-             * at the range of the artifact
-             * @return List of {@link BedHeightValue}s */
-            BedHeight single = BedHeight.getBedHeightById(
-                    access.getHeightId());
-            List<BedHeightValue> bedheightValues =
-                BedHeightValue.getBedHeightValues(
-                    single,
-                    access.getFrom(true),
-                    access.getTo(true));
-            double[][] values = new double[2][bedheightValues.size()];
-            int i = 0;
-            for (BedHeightValue bedheightValue : bedheightValues) {
-                values[0][i] = bedheightValue.getStation();
-                values[1][i] = bedheightValue.getHeight();
-                i++;
-            }
-            return values;
+        BedHeight single = BedHeight.getBedHeightById(access.getHeightId());
+        List<BedHeightValue> bedheightValues =
+            BedHeightValue.getBedHeightValues(
+                single,
+                access.getFrom(true),
+                access.getTo(true));
+        double[][] values = new double[2][bedheightValues.size()];
+        int i = 0;
+        for (BedHeightValue bedheightValue : bedheightValues) {
+            values[0][i] = bedheightValue.getStation();
+            values[1][i] = bedheightValue.getHeight();
+            i++;
         }
-        else {
-            /* Former doc (from BedHeightAccess):
-             * Return the {@link BedHeight} at the height_id and time of the artifact
-             * @return {@link BedHeight} */
-            BedHeightData data = BedHeightFactory.getHeight(
-                access.getType(),
-                access.getHeightId());
-            //data.removeNaNs();
-            TDoubleArrayList stations= data.getStations();
-            double[][] values = new double[2][stations.size()];
-            for (int i = 0; i < stations.size(); i++) {
-                values[0][i] = stations.get(i);
-                values[1][i] = data.getHeight(i);
-            }
-            return values;
+
+        this.addMetaData(Resources.getMsg(
+                context.getMeta(),
+                "meta.bedheight.cur.elevation"),
+            single.getCurElevationModel().getName());
+        if (single.getOldElevationModel() != null) {
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.old.elevation"),
+                single.getOldElevationModel().getName());
         }
+        this.addMetaData(Resources.getMsg(
+                context.getMeta(),
+                "meta.bedheight.river.elevation"),
+            access.getRiver().getWstUnit().getName());
+
+        return values;
     }
 
     /**
@@ -95,7 +86,7 @@
      */
     @Override
     public BedHeightFacet deepCopy() {
-        BedHeightFacet copy = new BedHeightFacet(name, description, type);
+        BedHeightFacet copy = new BedHeightFacet(name, description);
         copy.set(this);
         return copy;
     }


More information about the Dive4Elements-commits mailing list