[PATCH] Sedimen load: Added bundle for fraction results

Wald Commits scm-commit at wald.intevation.org
Wed Jul 30 16:50:32 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1406731826 -7200
# Node ID 8489565ff563e08c7911778a2cebfae0d46e96c9
# Parent  0000ed802cadf7135f207c91d9b8fc829786a19e
Sedimen load: Added bundle for fraction results.

diff -r 0000ed802cad -r 8489565ff563 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Wed Jul 23 18:19:15 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Wed Jul 30 16:50:26 2014 +0200
@@ -245,6 +245,8 @@
             return error("minfo.sediment.load.no.data");
         }
 
+        SedimentLoadDataResult sldr = new SedimentLoadDataResult();
+
         boolean isKmUp = isKmUp();
         Set<Integer> missingFractions = new TreeSet<Integer>();
 
@@ -268,13 +270,14 @@
                         gf.getDescription());
                     continue;
                 }
-                // TODO: Generate result data set for calculation.
                 // TODO: Optionally transform units.
+                SedimentLoadDataResult.Fraction sldrf =
+                    new SedimentLoadDataResult.Fraction(gf.getDescription(), result);
+                sldr.addFraction(sldrf);
             }
         }
         // TODO: Generate messages for missing fractions.
-        // TODO: Bundle sub results.
-        return null;
+        return new CalculationResult(sldr, this);
     }
 
     private CalculationResult calculateEpochs() {
@@ -285,6 +288,8 @@
             return error("minfo.sediment.load.no.data");
         }
 
+        SedimentLoadDataResult sldr = new SedimentLoadDataResult();
+
         boolean isKmUp = isKmUp();
         Set<Integer> missingFractions = new TreeSet<Integer>();
 
@@ -309,13 +314,14 @@
                         gf.getDescription());
                     continue;
                 }
-                // TODO: Generate result data set for calculation.
                 // TODO: Optionally transform units.
+                SedimentLoadDataResult.Fraction sldrf =
+                    new SedimentLoadDataResult.Fraction(gf.getDescription(), result);
+                sldr.addFraction(sldrf);
             }
         }
         // TODO: Generate messages for missing fractions.
-        // TODO: Bundle sub results.
-        return null;
+        return new CalculationResult(sldr, this);
     }
 
     private CalculationResult calculateOffEpochs() {
@@ -326,6 +332,8 @@
             return error("minfo.sediment.load.no.data");
         }
 
+        SedimentLoadDataResult sldr = new SedimentLoadDataResult();
+
         boolean isKmUp = isKmUp();
         Set<Integer> missingFractions = new TreeSet<Integer>();
 
@@ -347,14 +355,14 @@
                         gf.getDescription());
                     continue;
                 }
-                // TODO: Generate result data set for calculation.
                 // TODO: Optionally transform units.
+                SedimentLoadDataResult.Fraction sldrf =
+                    new SedimentLoadDataResult.Fraction(gf.getDescription(), result);
+                sldr.addFraction(sldrf);
             }
         }
         // TODO: Generate messages for missing fractions.
-        // TODO: Bundle sub results.
-        // TODO: Implement me!
-        return null;
+        return new CalculationResult(sldr, this);
     }
 
     /** Figure out flow direction of river. */
diff -r 0000ed802cad -r 8489565ff563 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java	Wed Jul 30 16:50:26 2014 +0200
@@ -0,0 +1,71 @@
+/* Copyright (C) 2016 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+package org.dive4elements.river.artifacts.model.minfo;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SedimentLoadDataResult
+implements   Serializable
+{
+
+    public static class Fraction implements Serializable {
+        private String      name;
+        private double [][] data;
+
+        public Fraction() {
+        }
+
+        public Fraction(String name, double [][] data) {
+            this.name = name;
+            this.data = data;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public double [][] getData() {
+            return data;
+        }
+
+        public void setData(double [][] data) {
+            this.data = data;
+        }
+
+    } // class Fraction
+
+    private List<Fraction> fractions;
+
+    public SedimentLoadDataResult() {
+        fractions = new ArrayList<Fraction>();
+    }
+
+    public void addFraction(Fraction fraction) {
+        fractions.add(fraction);
+    }
+
+    public List<Fraction> getFractions() {
+        return fractions;
+    }
+
+    public Fraction getFractionByName(String name) {
+        for (Fraction fraction: fractions) {
+            if (fraction.getName().equals(name)) {
+                return fraction;
+            }
+        }
+        return null;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :


More information about the Dive4Elements-commits mailing list