changeset 8062:8489565ff563

Sedimen load: Added bundle for fraction results.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 30 Jul 2014 16:50:26 +0200 (2014-07-30)
parents 0000ed802cad
children 41d9014bfa02
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java
diffstat 2 files changed, 89 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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. */
--- /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 :

http://dive4elements.wald.intevation.org