changeset 8174:4b2b7593815c

Make sedimentload loadable as old calculation.
author Tom Gottfried <tom@intevation.de>
date Tue, 02 Sep 2014 14:46:20 +0200
parents 16be0ceee25b
children d2673ca68e70
files artifacts/doc/conf/meta-data.xml artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDataCalculate.java
diffstat 4 files changed, 8 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Mon Sep 01 17:50:22 2014 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Tue Sep 02 14:46:20 2014 +0200
@@ -1017,7 +1017,7 @@
                     <dc:attribute name="description" value="${facet_description}"/>
                     <dc:attribute name="ids" value="${facet_num}"/>
                     <dc:attribute name="artifact-id" value="${a_gid}"/>
-                    <dc:attribute name="out" value="sedimentload_ls"/>
+                    <dc:attribute name="out" value="${out_name}"/>
                   </dc:element>
                 </dc:for-each>
               </load>
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java	Mon Sep 01 17:50:22 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java	Tue Sep 02 14:46:20 2014 +0200
@@ -92,7 +92,6 @@
 
     @Override
     public Object getData(Artifact artifact, CallContext context) {
-        logger.debug("Get data for sediment load with fraction: " + fraction);
 
         D4EArtifact flys = (D4EArtifact) artifact;
 
@@ -105,21 +104,15 @@
 
         SedimentLoadDataResult sdResult = (SedimentLoadDataResult) payload;
 
-        List<Fraction> fractions = sdResult.getFractionsByNameAndPeriod(
-            fraction, period
-        );
-        if (fractions == null) {
-            logger.warn("No result for fraction '" + fraction +
+        List<Fraction> fractions = sdResult.getFractions();
+
+        if (fractions.size() < index + 1) {
+            logger.error("No result for fraction '" + fraction +
                         "' and period '" + period + "'");
             return null;
         }
 
-        if (fractions.size() > 1) {
-            logger.error("Multiple results for fraction '" + fraction +
-                        "' and period '" + period + "'");
-        }
-
-        return fractions.get(0).getData();
+        return fractions.get(index).getData();
 
         /* Are gaps neccessary now?
         for (int x = 0; x < values[0].length-1; x++) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java	Mon Sep 01 17:50:22 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java	Tue Sep 02 14:46:20 2014 +0200
@@ -83,18 +83,5 @@
         return result.isEmpty() ? null : result;
     }
 
-    public List<Fraction> getFractionsByNameAndPeriod(
-            String name,
-            String period
-        ) {
-        List<Fraction> result = new ArrayList<Fraction>();
-        for (Fraction fraction: fractions) {
-            if (fraction.getName().equals(name) &&
-                fraction.getPeriod().equals(period)) {
-                result.add(fraction);
-            }
-        }
-        return result.isEmpty() ? null : result;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDataCalculate.java	Mon Sep 01 17:50:22 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDataCalculate.java	Tue Sep 02 14:46:20 2014 +0200
@@ -119,9 +119,10 @@
         for (Fraction fract: sdRes.getFractions()) {
             logger.debug("Adding facet for fraction '" + fract.getName() +
                          "' and period '" + fract.getPeriod() + "'");
-            facets.add(new SedimentLoadDataFacet(i++, fract.getName(),
+            facets.add(new SedimentLoadDataFacet(i, fract.getName(),
                           unit, fract.getPeriod(),
                           ComputeType.ADVANCE, id, hash, context));
+            i++;
         }
 
         facets.add(

http://dive4elements.wald.intevation.org