changeset 8273:5c3b36b519d0

Add metadata to bedheight facets in bed height differences.
author "Tom Gottfried <tom@intevation.de>"
date Tue, 16 Sep 2014 11:33:08 +0200
parents c57b0400ac98
children b0d7b0d79d6e
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFilterFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFilterFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffYearResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/DifferencesState.java
diffstat 7 files changed, 104 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java	Mon Sep 15 15:38:16 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java	Tue Sep 16 11:33:08 2014 +0200
@@ -44,7 +44,7 @@
             if (pair[0].getYear() == null || pair[1].getYear() == null) {
                 addProblem("beddiff.missing.year");
             }
-            results[i] = calculateYearDifference(pair);
+            results[i] = calculateYearDifference(pair, heightIds[i]);
         }
 
         return new CalculationResult(results, this);
@@ -59,7 +59,8 @@
     }
 
     private BedDiffYearResult calculateYearDifference(
-            BedHeightSingleData[] pair
+        BedHeightSingleData[] pair,
+        int[] ids
         ) {
         log.debug("BedDiffCalculation.calculateYearDifference");
         BedHeightSingleData s1 = pair[0];
@@ -125,7 +126,9 @@
             s1.getYear(),
             s2.getYear(),
             s1.getName(),
-            s2.getName());
+            s2.getName(),
+            ids[0],
+            ids[1]);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFacet.java	Mon Sep 15 15:38:16 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFacet.java	Tue Sep 16 11:33:08 2014 +0200
@@ -4,7 +4,12 @@
 import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
+
+import org.dive4elements.river.model.BedHeightSingle;
+
 import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.artifacts.model.CalculationResult;
 import org.dive4elements.river.artifacts.model.DataFacet;
 import org.dive4elements.river.artifacts.model.FacetTypes;
@@ -40,6 +45,22 @@
 
         if (resultData != null && resultData.length > index) {
             BedDiffYearResult data = resultData[index];
+
+            BedHeightSingle first = BedHeightSingle.getBedHeightSingleById(
+                data.getIdFirst());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.cur.elevation"),
+                first.getCurElevationModel().getName());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.old.elevation"),
+                first.getOldElevationModel().getName());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.river.elevation"),
+                new RiverAccess(flys).getRiver().getWstUnit().getName());
+
             return data.getHeights1Data();
         }
         return null;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFilterFacet.java	Mon Sep 15 15:38:16 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightMinFilterFacet.java	Tue Sep 16 11:33:08 2014 +0200
@@ -13,6 +13,9 @@
 import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
+
+import org.dive4elements.river.model.BedHeightSingle;
+
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.access.RiverAccess;
 import org.dive4elements.river.artifacts.context.RiverContext;
@@ -64,6 +67,22 @@
             this.metaData.put(
                 Resources.getMsg(context.getMeta(),
                     "chart.subtitle.radius", new Object[] { radius }), "");
+
+            BedHeightSingle first = BedHeightSingle.getBedHeightSingleById(
+                oldData.getIdFirst());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.cur.elevation"),
+                first.getCurElevationModel().getName());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.old.elevation"),
+                first.getOldElevationModel().getName());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.river.elevation"),
+                access.getRiver().getWstUnit().getName());
+
             return heights;
         }
         return null;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFacet.java	Mon Sep 15 15:38:16 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFacet.java	Tue Sep 16 11:33:08 2014 +0200
@@ -4,7 +4,12 @@
 import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
+
+import org.dive4elements.river.model.BedHeightSingle;
+
 import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.artifacts.model.CalculationResult;
 import org.dive4elements.river.artifacts.model.DataFacet;
 import org.dive4elements.river.artifacts.model.FacetTypes;
@@ -40,6 +45,22 @@
 
         if (resultData != null && resultData.length > index) {
             BedDiffYearResult data = resultData[index];
+
+            BedHeightSingle second = BedHeightSingle.getBedHeightSingleById(
+                data.getIdSecond());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.cur.elevation"),
+                second.getCurElevationModel().getName());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.old.elevation"),
+                second.getOldElevationModel().getName());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.river.elevation"),
+                new RiverAccess(flys).getRiver().getWstUnit().getName());
+
             return data.getHeights2Data();
         }
         return null;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFilterFacet.java	Mon Sep 15 15:38:16 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFilterFacet.java	Tue Sep 16 11:33:08 2014 +0200
@@ -13,6 +13,9 @@
 import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
+
+import org.dive4elements.river.model.BedHeightSingle;
+
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.access.RiverAccess;
 import org.dive4elements.river.artifacts.context.RiverContext;
@@ -64,6 +67,22 @@
             this.metaData.put(
                 Resources.getMsg(context.getMeta(),
                     "chart.subtitle.radius", new Object[] { radius }), "");
+
+            BedHeightSingle second = BedHeightSingle.getBedHeightSingleById(
+                oldData.getIdSecond());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.cur.elevation"),
+                second.getCurElevationModel().getName());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.old.elevation"),
+                second.getOldElevationModel().getName());
+            this.addMetaData(Resources.getMsg(
+                    context.getMeta(),
+                    "meta.bedheight.river.elevation"),
+                access.getRiver().getWstUnit().getName());
+
             return heights;
         }
         return null;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffYearResult.java	Mon Sep 15 15:38:16 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffYearResult.java	Tue Sep 16 11:33:08 2014 +0200
@@ -24,6 +24,8 @@
     protected Integer end;
     protected String nameFirst;
     protected String nameSecond;
+    protected int idFirst;
+    protected int idSecond;
 
     public BedDiffYearResult () {
         super();
@@ -54,7 +56,9 @@
         Integer start,
         Integer end,
         String nameFirst,
-        String nameSecond
+        String nameSecond,
+        int idFirst,
+        int idSecond
     ) {
         super(kms, differences, heights1, heights2);
         this.diffsPerYear = diffsPerYear;
@@ -66,6 +70,8 @@
         this.end = end;
         this.nameFirst = nameFirst;
         this.nameSecond = nameSecond;
+        this.idFirst = idFirst;
+        this.idSecond = idSecond;
     }
 
     public TDoubleArrayList getBedHeights() {
@@ -114,6 +120,16 @@
         return this.nameSecond;
     }
 
+    /** Get id of the first BedHeight (minuend). */
+    public int getIdFirst() {
+        return this.idFirst;
+    }
+
+    /** Get id of the second BedHeight (subtrahend). */
+    public int getIdSecond() {
+        return this.idSecond;
+    }
+
     public void addMorphWidth1(double value) {
         this.morphWidth1.add(value);
     }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/DifferencesState.java	Mon Sep 15 15:38:16 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/DifferencesState.java	Tue Sep 16 11:33:08 2014 +0200
@@ -226,7 +226,7 @@
                     ComputeType.ADVANCE,
                     stateId,
                     hash));
-                 newFacets.add(new BedDiffHeightSubFilterFacet(
+                newFacets.add(new BedDiffHeightSubFilterFacet(
                     idx,
                     BED_DIFFERENCE_YEAR_HEIGHT2_FILTERED,
                     createBedDiffHeightDescription(

http://dive4elements.wald.intevation.org