changeset 8657:4054c7fce43e

(issue1755) Add problem / report handling to BedQualityCalculation
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 02 Apr 2015 15:48:48 +0200
parents 3a9ce890e4c7
children 3531f0cee5e1
files artifacts/doc/conf/artifacts/minfo.xml artifacts/doc/conf/generators/generators.xml artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties artifacts/src/main/resources/messages_de_DE.properties artifacts/src/main/resources/messages_en.properties
diffstat 8 files changed, 75 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/minfo.xml	Thu Apr 02 14:10:25 2015 +0200
+++ b/artifacts/doc/conf/artifacts/minfo.xml	Thu Apr 02 15:48:48 2015 +0200
@@ -496,6 +496,11 @@
                         <facet name="csv" description="facet.bed_quality_export.csv" />
                     </facets>
                 </outputmode>
+                <outputmode name="bed_quality_report" description="output.bed_quality_report" mime-type="text/xml" type="report">
+                    <facets>
+                        <facet name="report" description="facet.bed_quality.report" />
+                    </facets>
+                </outputmode>
             </outputmodes>
         </state>
 
--- a/artifacts/doc/conf/generators/generators.xml	Thu Apr 02 14:10:25 2015 +0200
+++ b/artifacts/doc/conf/generators/generators.xml	Thu Apr 02 15:48:48 2015 +0200
@@ -52,6 +52,7 @@
     <output-generator names="fix_report" class="org.dive4elements.river.exports.ReportGenerator"/>
     <output-generator names="extreme_curve_report" class="org.dive4elements.river.exports.ReportGenerator"/>
     <output-generator names="sedimentload_ls_report" class="org.dive4elements.river.exports.ReportGenerator"/>
+    <output-generator names="bed_quality_report" class="org.dive4elements.river.exports.ReportGenerator"/>
     <!-- AT exporter. -->
     <output-generator names="computed_dischargecurve_at_export" class="org.dive4elements.river.exports.ATExporter"/>
     <output-generator names="gauge_discharge_curve_at_export" class="org.dive4elements.river.exports.ATExporter"/>
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityCalculation.java	Thu Apr 02 14:10:25 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityCalculation.java	Thu Apr 02 15:48:48 2015 +0200
@@ -88,6 +88,31 @@
         return new CalculationResult();
     }
 
+    /** Adds non empty values to a result and adds Problems for empty ones.*/
+    protected void addValuesToResult(BedQualityResult result,
+                                     BedQualityResultValue[] values) {
+        for (BedQualityResultValue value: values) {
+            if (value.isEmpty()) {
+                if (value.isDiameterResult()) {
+                    log.debug("Adding diameter problem");
+                    addProblem("bedquality.missing.diameter." +
+                            value.getType(), value.getName().toUpperCase(),
+                            result.getDateRange().getFrom(),
+                            result.getDateRange().getTo());
+                } else {
+                    log.debug("Adding diameter problem");
+                    addProblem("bedquality.missing." + value.getName() + "." +
+                            value.getType(), result.getDateRange().getFrom(),
+                            result.getDateRange().getTo());
+                }
+            } else {
+                log.debug("Adding unproblematic result");
+                result.add(value);
+            }
+        }
+    }
+
+
     protected CalculationResult internalCalculate() {
 
         List<BedQualityResult> results = new LinkedList<BedQualityResult>();
@@ -111,14 +136,14 @@
             result.setDateRange(dr);
             if (!bedDiameter.isEmpty()) {
                 log.debug("Bed diameter is not empty + " + bedDiameter);
-                result.add(calculateBedParameter(bedMeasurements));
+                addValuesToResult(result, calculateBedParameter(bedMeasurements));
                 for (String bd : bedDiameter) {
-                    result.add (calculateBed(bedMeasurements, bd));
+                    addValuesToResult(result, calculateBed(bedMeasurements, bd));
                 }
             }
             if (!bedloadDiameter.isEmpty()) {
                 for (String bld : bedloadDiameter) {
-                    result.add(calculateBedload(loadMeasurements, bld));
+                    addValuesToResult(result, calculateBedload(loadMeasurements, bld));
                 }
             }
             results.add(result);
@@ -240,7 +265,7 @@
         return results;
     }
 
-    protected BedQualityResultValue calculateBedload(
+    protected BedQualityResultValue[] calculateBedload(
         QualityMeasurements qm,
         String diameter
     ) {
@@ -253,9 +278,10 @@
             location.add(km);
             avDiameter.add(mid * 1000);
         }
-        return new BedQualityResultValue(diameter,
+        return new BedQualityResultValue[] {
+            new BedQualityResultValue(diameter,
                 new double[][] {location.toNativeArray(), avDiameter.toNativeArray()},
-                "bedload");
+                "bedload")};
     }
 
     protected double calculateAverage(
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java	Thu Apr 02 14:10:25 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java	Thu Apr 02 15:48:48 2015 +0200
@@ -22,9 +22,11 @@
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.access.BedQualityAccess;
 import org.dive4elements.river.artifacts.model.CalculationResult;
+import org.dive4elements.river.artifacts.model.Calculation;
 import org.dive4elements.river.artifacts.model.DataFacet;
 import org.dive4elements.river.artifacts.model.DateRange;
 import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.ReportFacet;
 import org.dive4elements.river.artifacts.model.minfo.BedQualityDataFacet;
 import org.dive4elements.river.artifacts.model.minfo.BedQualityInterpolFacet;
 import org.dive4elements.river.artifacts.model.minfo.BedDiameterDataFacet;
@@ -105,6 +107,13 @@
             return res;
         }
 
+        Calculation report = res.getReport();
+
+        if (report != null && report.hasProblems()) {
+            facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
+            log.debug("Problems : " + report.problemsToString());
+        }
+
         BedQualityResult[] results = (BedQualityResult[]) res.getData();
 
         if (results == null || results.length == 0) {
--- a/artifacts/src/main/resources/messages.properties	Thu Apr 02 14:10:25 2015 +0200
+++ b/artifacts/src/main/resources/messages.properties	Thu Apr 02 15:48:48 2015 +0200
@@ -331,6 +331,13 @@
 facet.bedquality.interpol.suffix = - interpolated
 bedquality.toplayer = 0.0m - 0.3m
 bedquality.sublayer = 0.1m - 0.5m
+bedquality.missing.diameter.bedload = No bedload data found in {1,date} - {2,date} for diameter {0} for this range
+bedquality.missing.diameter.sublayer = No sediment data found in {1,date} - {2,date} for diameter {0} 0.0m - 0.3m for this range
+bedquality.missing.diameter.toplayer = No sediment data found in {1,date} - {2,date} for diameter {0} 0.1m - 0.5m for this range
+bedquality.missing.density.toplayer = Not enough data in {0,date} - {1,date} for density 0.0m - 0.3m calculation for this range
+bedquality.missing.density.sublayer = Not enough data in {0,date} - {1,date} for density 0.1m - 0.5m calculation for this range
+bedquality.missing.porosity.toplayer = Not enough data in {0,date} - {1,date} for porosity 0.0m - 0.3m calculation for this range
+bedquality.missing.porosity.sublayer = Not enough data in {0,date} - {1,date} for porosity 0.1m - 0.5m calculation for this range
 facet.bedheight.diff.year = Bedheight Difference {0}
 facet.bedheight.sounding_width = Sounding Width ({0})
 facet.bedheight.diff.sounding = sounding Width
--- a/artifacts/src/main/resources/messages_de.properties	Thu Apr 02 14:10:25 2015 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Thu Apr 02 15:48:48 2015 +0200
@@ -332,6 +332,13 @@
 facet.bedquality.interpol.suffix = - interpoliert
 bedquality.toplayer = 0,0m - 0,3m
 bedquality.sublayer = 0,1m - 0,5m
+bedquality.missing.diameter.bedload = F\u00fcr Geschiebedurchmesser {0} liegen auf der Berechnungsstrecke f\u00fcr {1,date} - {2,date} nicht genug Daten vor
+bedquality.missing.diameter.sublayer = F\u00fcr Sohldurchmesser {0} 0,0m - 0,3m liegen auf der Berechnungsstrecke f\u00fcr {1,date} - {2,date} nicht genug Daten vor
+bedquality.missing.diameter.toplayer = F\u00fcr Sohldurchmesser {0} 0,1m - 0,5m liegen auf der Berechnungsstrecke f\u00fcr {1,date} - {2,date} nicht genug Daten vor
+bedquality.missing.density.toplayer = Zur Berechnung der Dichte 0.0m - 0.3m liegen auf der Berechnungsstrecke f\u00fcr {0,date} - {1,date} nicht genug daten vor
+bedquality.missing.density.sublayer = Zur Berechnung der Dichte 0.1m - 0.5m liegen auf der Berechnungsstrecke f\u00fcr {0,date} - {1,date} nicht genug daten vor
+bedquality.missing.porosity.toplayer = Zur Berechnung der Porosit\u00e4t 0.0m - 0.3m liegen auf der Berechnungsstrecke f\u00fcr {0,date} - {1,date} nicht genug Daten vor
+bedquality.missing.porosity.sublayer = Zur Berechnung der Porosit\u00e4t 0.1m - 0.5m liegen auf der Berechnungsstrecke f\u00fcr {0,date} - {1,date} nicht genug Daten vor
 facet.bedheight.diff.year = Sohlh\u00f6hendifferenz {0}
 facet.bedheight.sounding_width = gepeilte Breite ({0})
 facet.bedheight.diff.morph1 = Morph. aktive Breite Minuend
--- a/artifacts/src/main/resources/messages_de_DE.properties	Thu Apr 02 14:10:25 2015 +0200
+++ b/artifacts/src/main/resources/messages_de_DE.properties	Thu Apr 02 15:48:48 2015 +0200
@@ -329,6 +329,13 @@
 facet.bedquality.interpol.suffix = - interpoliert
 bedquality.toplayer = 0,0m - 0,3m
 bedquality.sublayer = 0,1m - 0,5m
+bedquality.missing.diameter.bedload = F\u00fcr Geschiebedurchmesser {0} liegen auf der Berechnungsstrecke f\u00fcr {1,date} - {2,date} nicht genug Daten vor
+bedquality.missing.diameter.sublayer = F\u00fcr Sohldurchmesser {0} 0,0m - 0,3m liegen auf der Berechnungsstrecke f\u00fcr {1,date} - {2,date} nicht genug Daten vor
+bedquality.missing.diameter.toplayer = F\u00fcr Sohldurchmesser {0} 0,1m - 0,5m liegen auf der Berechnungsstrecke f\u00fcr {1,date} - {2,date} nicht genug Daten vor
+bedquality.missing.density.toplayer = Zur Berechnung der Dichte 0.0m - 0.3m liegen auf der Berechnungsstrecke f\u00fcr {0,date} nicht genug daten vor
+bedquality.missing.density.sublayer = Zur Berechnung der Dichte 0.1m - 0.5m liegen auf der Berechnungsstrecke f\u00fcr {0,date} nicht genug daten vor
+bedquality.missing.porosity.toplayer = Zur Berechnung der Porosit\u00e4t 0.0m - 0.3m liegen auf der Berechnungsstrecke f\u00fcr {0,date} nicht genug Daten vor
+bedquality.missing.porosity.sublayer = Zur Berechnung der Porosit\u00e4t 0.1m - 0.5m liegen auf der Berechnungsstrecke f\u00fcr {0,date} nicht genug Daten vor
 facet.bedheight.diff.year = Sohlh\u00f6hendifferenz {0}
 facet.bedheight.diff.year.raw = Sohlh\u00f6hendifferenz {0} (Rohdaten)
 facet.bedheight.sounding_width = gepeilte Breite ({0})
--- a/artifacts/src/main/resources/messages_en.properties	Thu Apr 02 14:10:25 2015 +0200
+++ b/artifacts/src/main/resources/messages_en.properties	Thu Apr 02 15:48:48 2015 +0200
@@ -333,6 +333,13 @@
 facet.bedquality.interpol.suffix = - interpolated
 bedquality.toplayer = 0.0m - 0.3m
 bedquality.sublayer = 0.1m - 0.5m
+bedquality.missing.diameter.bedload = No bedload data found in {1,date} for diameter {0} for this range
+bedquality.missing.diameter.sublayer = No sediment data found in {1,date} for diameter {0} 0.0m - 0.3m for this range
+bedquality.missing.diameter.toplayer = No sediment data found in {1,date} for diameter {0} 0.1m - 0.5m for this range
+bedquality.missing.density.toplayer = Not enough data in {0,date} - {1,date} for density 0.0m - 0.3m calculation for this range
+bedquality.missing.density.sublayer = Not enough data in {0,date} - {1,date} for density 0.1m - 0.5m calculation for this range
+bedquality.missing.porosity.toplayer = Not enough data in {0,date} - {1,date} for porosity 0.0m - 0.3m calculation for this range
+bedquality.missing.porosity.sublayer = Not enough data in {0,date} - {1,date} for porosity 0.1m - 0.5m calculation for this range
 facet.bedheight.diff.year = Bedheight Difference {0}
 facet.bedheight.sounding_width = Sounding Width ({0})
 facet.bedheight.diff.sounding = sounding Width

http://dive4elements.wald.intevation.org