[PATCH] Make sedimentload loadable as old calculation

Wald Commits scm-commit at wald.intevation.org
Tue Sep 2 14:46:24 CEST 2014


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1409661980 -7200
# Node ID 4b2b7593815ce7929f8b95d64d37db27ab449934
# Parent  16be0ceee25bbd420ef4489b1513c094f5b3bd10
Make sedimentload loadable as old calculation.

diff -r 16be0ceee25b -r 4b2b7593815c artifacts/doc/conf/meta-data.xml
--- 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>
diff -r 16be0ceee25b -r 4b2b7593815c artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java
--- 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++) {
diff -r 16be0ceee25b -r 4b2b7593815c artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java
--- 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 :
diff -r 16be0ceee25b -r 4b2b7593815c artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDataCalculate.java
--- 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(


More information about the Dive4Elements-commits mailing list