changeset 7989:98e25342df73 facet-metadata

Add units as meta data to middle bed height facets.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 02 Jul 2014 12:32:59 +0200
parents 5acaf44062b5
children e3f2d8c006fb
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightData.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/MiddleBedHeight.java
diffstat 3 files changed, 34 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java	Wed Jul 02 12:31:57 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java	Wed Jul 02 12:32:59 2014 +0200
@@ -14,12 +14,8 @@
 import org.apache.log4j.Logger;
 
 import org.dive4elements.artifacts.Artifact;
-import org.dive4elements.artifacts.common.utils.DateUtils;
-
 import org.dive4elements.river.model.BedHeightSingle;
 import org.dive4elements.river.model.BedHeightSingleValue;
-import org.dive4elements.river.model.TimeInterval;
-
 import org.dive4elements.river.artifacts.access.BedHeightAccess;
 import org.dive4elements.river.artifacts.model.Calculation;
 import org.dive4elements.river.artifacts.model.CalculationResult;
@@ -117,7 +113,9 @@
             year,
             year,
             single.getEvaluationBy(),
-            single.getDescription());
+            single.getDescription(),
+            single.getCurElevationModel().getName(),
+            single.getOldElevationModel().getName());
 
         for (BedHeightSingleValue value: values) {
             if (value.getHeight() != null) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightData.java	Wed Jul 02 12:31:57 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightData.java	Wed Jul 02 12:32:59 2014 +0200
@@ -41,14 +41,19 @@
     private TDoubleArrayList soundingWidth;
     private TDoubleArrayList dataGap;
     private TDoubleArrayList width;
+    private String oldElevationModel;
+    private String curElevationModel;
     private ArrayList empty;
 
 
-    protected MiddleBedHeightData(int start, int end, String eval, String desc) {
+    protected MiddleBedHeightData(int start, int end, String eval, String desc,
+        String curElevationModel, String oldElevationModel) {
         this.startYear   = start;
         this.endYear     = end;
         this.evaluatedBy = eval;
         this.description = desc;
+        this.curElevationModel = curElevationModel;
+        this.oldElevationModel = oldElevationModel;
 
         this.km            = new TDoubleArrayList();
         this.middleHeight  = new TDoubleArrayList();
@@ -87,6 +92,13 @@
         return description;
     }
 
+    public String getCurElevationModel() {
+        return this.curElevationModel;
+    }
+
+    public String getOldElevationModel() {
+        return this.oldElevationModel;
+    }
 
     protected void addKM(double km) {
         this.km.add(km);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/MiddleBedHeight.java	Wed Jul 02 12:31:57 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/MiddleBedHeight.java	Wed Jul 02 12:32:59 2014 +0200
@@ -25,6 +25,8 @@
 import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightCalculation;
 import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightData;
 import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightFacet;
+import org.dive4elements.river.model.River;
+import org.dive4elements.river.model.Unit;
 
 
 /** State in which Middle Bed Heights are generated. */
@@ -47,6 +49,8 @@
         List<Facet> newFacets = new ArrayList<Facet>();
 
         BedHeightAccess access = new BedHeightAccess(artifact);
+        River river = access.getRiver();
+        Unit u = river.getWstUnit();
 
         CalculationResult res = old instanceof CalculationResult
             ? (CalculationResult) old
@@ -65,24 +69,34 @@
 
         for (MiddleBedHeightData d: data) {
             if (d.getStartYear() == d.getEndYear()) {
-                newFacets.add(new MiddleBedHeightFacet(
+                MiddleBedHeightFacet mf = new MiddleBedHeightFacet(
                     idx,
                     MIDDLE_BED_HEIGHT_SINGLE,
                     d.getDescription(),
                     ComputeType.ADVANCE,
                     id,
                     hash
-                ));
+                );
+                //TODO: I18N!
+                mf.addMetaData("Current elevation model", d.getCurElevationModel());
+                mf.addMetaData("Old elevation model", d.getOldElevationModel());
+                mf.addMetaData("Unit", u.getName());
+                newFacets.add(mf);
             }
             else {
-                newFacets.add(new MiddleBedHeightFacet(
+                MiddleBedHeightFacet mf = new MiddleBedHeightFacet(
                     idx,
                     MIDDLE_BED_HEIGHT_EPOCH,
                     d.getDescription(),
                     ComputeType.ADVANCE,
                     id,
                     hash
-                ));
+                );
+                //TODO: I18N!
+                mf.addMetaData("Current elevation model", d.getCurElevationModel());
+                mf.addMetaData("Old elevation model", d.getOldElevationModel());
+                mf.addMetaData("Unit", u.getName());
+                newFacets.add(mf);
             }
 
             idx++;

http://dive4elements.wald.intevation.org