[PATCH 07 of 10] Add units as meta data to middle bed height facets

Wald Commits scm-commit at wald.intevation.org
Wed Jul 2 12:41:08 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1404297179 -7200
# Branch facet-metadata
# Node ID 98e25342df737032de9668b3bce45d4caae30651
# Parent  5acaf44062b52488d4d67efbd238dfd7d9ada138
Add units as meta data to middle bed height facets.

diff -r 5acaf44062b5 -r 98e25342df73 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java
--- 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) {
diff -r 5acaf44062b5 -r 98e25342df73 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightData.java
--- 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);
diff -r 5acaf44062b5 -r 98e25342df73 artifacts/src/main/java/org/dive4elements/river/artifacts/states/MiddleBedHeight.java
--- 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++;


More information about the Dive4Elements-commits mailing list