changeset 2244:7335c526befd

Added an error report for historical discharge curves. flys-artifacts/trunk@3893 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 03 Feb 2012 11:45:22 +0000
parents d70a04cad84d
children 16598bd04f70
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 9 files changed, 50 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Feb 03 10:45:12 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Feb 03 11:45:22 2012 +0000
@@ -1,3 +1,24 @@
+2012-02-03  Ingo Weinzierl <ingo@intevation.de>
+
+	* doc/conf/artifacts/winfo.xml: Registered a ReportFacet for historical
+	  discharge curve report.
+
+	* doc/conf/conf.xml: Registered a ReportGenerator for historical discharge
+	  curves.
+
+	* src/main/java/de/intevation/flys/artifacts/model/Calculation6.java: Add
+	  problems if we were not able to find a Q for a given W.
+
+	* src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java:
+	  Generate a ReportFacet if there were problems during calculcation.
+
+	* src/main/resources/messages.properties,
+	  src/main/resources/messages_de_DE.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages_de.properties: Added error messages for the
+	  case that we were not able to find a Q for a given W while calculating
+	  historical discharge curve data.
+
 2012-02-03  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java:
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Fri Feb 03 10:45:12 2012 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Fri Feb 03 11:45:22 2012 +0000
@@ -489,7 +489,7 @@
                 </outputmode>
                 <outputmode name="historical_discharge_report" description="output.historical_discharge_report" mime-type="text/xml" type="report">
                     <facets>
-                        <!-- TODO ADD FACETS -->
+                        <facet name="report" description="facet.historical_discharge.report"/>
                     </facets>
                 </outputmode>
             </outputmodes>
--- a/flys-artifacts/doc/conf/conf.xml	Fri Feb 03 10:45:12 2012 +0000
+++ b/flys-artifacts/doc/conf/conf.xml	Fri Feb 03 11:45:22 2012 +0000
@@ -186,6 +186,7 @@
         <output-generator name="computed_dischargecurve_report">de.intevation.flys.exports.ReportGenerator</output-generator>
         <output-generator name="durationcurve_report">de.intevation.flys.exports.ReportGenerator</output-generator>
         <output-generator name="wsplgen_report">de.intevation.flys.exports.ReportGenerator</output-generator>
+        <output-generator name="historical_discharge_report">de.intevation.flys.exports.ReportGenerator</output-generator>
         <!-- AT exporter. -->
         <output-generator name="computed_dischargecurve_at_export">de.intevation.flys.exports.ATExporter</output-generator>
     </output-generators>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java	Fri Feb 03 10:45:12 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java	Fri Feb 03 11:45:22 2012 +0000
@@ -122,12 +122,15 @@
         for (double value: values) {
             logger.debug("Prepare data for value: " + value);
 
-            String name = mode == MODE_W ? "W=" + value : "Q=" + value;
-            WQTimerange wqt = new WQTimerange(name);
+            String      name = mode == MODE_W ? "W=" + value : "Q=" + value;
+            WQTimerange wqt  = null;
 
             for (DischargeTable dt: dts) {
                 TimeInterval ti = dt.getTimeInterval();
 
+                Date start = ti.getStartTime();
+                Date end   = ti.getStopTime();
+
                 Timerange t = new Timerange(ti.getStartTime(),ti.getStopTime());
                 double    w;
                 double    q;
@@ -135,6 +138,12 @@
                 if (mode == MODE_W) {
                     w = value;
                     q = findValueForW(dt, w);
+
+                    if (Double.isNaN(q)) {
+                        logger.warn("Cannot find Q for W: " + w);
+                        addProblem("cannot.find.hist.q.for.w", w, start, end);
+                        continue;
+                    }
                 }
                 else {
                     q = value;
@@ -145,10 +154,16 @@
                     logger.debug("Q=" + q + " | W=" + w);
                 }
 
+                if (wqt == null) {
+                    wqt = new WQTimerange(name);
+                }
+
                 wqt.add(w, q, t);
             }
 
-            wqts.add(wqt);
+            if (wqt != null) {
+                wqts.add(wqt);
+            }
         }
 
         return (WQTimerange[]) wqts.toArray(new WQTimerange[wqts.size()]);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java	Fri Feb 03 10:45:12 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java	Fri Feb 03 11:45:22 2012 +0000
@@ -18,6 +18,7 @@
 import de.intevation.flys.artifacts.model.CalculationResult;
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.HistoricalDischargeFacet;
+import de.intevation.flys.artifacts.model.ReportFacet;
 import de.intevation.flys.artifacts.model.WQTimerange;
 
 
@@ -73,6 +74,10 @@
 
         prepareFacets(facets, data);
 
+        if (res.getReport().hasProblems()) {
+            facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
+        }
+
         return res;
     }
 
--- a/flys-artifacts/src/main/resources/messages.properties	Fri Feb 03 10:45:12 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Fri Feb 03 11:45:22 2012 +0000
@@ -157,6 +157,7 @@
 cannot.create.wq.relation = Cannot create W/Q relation.
 cannot.create.index.q.relation = Cannot create index/Q relation.
 relating.w.w.failed = Relating W with W failed.
+cannot.find.hist.q.for.w = Cannot find Q for W = {0,number,#.##} in timerange {1, date} - {2, date}
 
 no.river.selected = No river selected.
 no.gauge.selected = No gauge selected.
--- a/flys-artifacts/src/main/resources/messages_de.properties	Fri Feb 03 10:45:12 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Fri Feb 03 11:45:22 2012 +0000
@@ -157,6 +157,7 @@
 cannot.create.wq.relation = W/Q-Beziehung konnte nicht ermittelt werden.
 cannot.create.index.q.relation = Spaltenindex/Q-Beziehung konnte nicht erstellt werden.
 relating.w.w.failed = Relating W with W failed.
+cannot.find.hist.q.for.w = Konnte zu W = {0,number,#.##} im Zeitraum ({1,date} - {2,date}) kein Abfluss ermitteln.
 
 no.river.selected = Kein Gew\u00e4sser ausgew\u00e4hlt.
 no.gauge.selected = Kein Pegel ausgew\u00e4hlt.
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Feb 03 10:45:12 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_de_DE.properties	Fri Feb 03 11:45:22 2012 +0000
@@ -157,6 +157,7 @@
 cannot.create.wq.relation = W/Q-Beziehung konnte nicht ermittelt werden.
 cannot.create.index.q.relation = Spaltenindex/Q-Beziehung konnte nicht erstellt werden.
 relating.w.w.failed = Relating W with W failed.
+cannot.find.hist.q.for.w = Konnte zu W = {0,number,#.##} im Zeitraum ({1,date} - {2,date}) kein Abfluss ermitteln.
 
 no.river.selected = Kein Gew\u00e4sser ausgew\u00e4hlt.
 no.gauge.selected = Kein Pegel ausgew\u00e4hlt.
--- a/flys-artifacts/src/main/resources/messages_en.properties	Fri Feb 03 10:45:12 2012 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Fri Feb 03 11:45:22 2012 +0000
@@ -153,6 +153,7 @@
 cannot.create.wq.relation = Cannot create W/Q relation.
 cannot.create.index.q.relation = Cannot create index/Q relation.
 relating.w.w.failed = Relating W with W failed.
+cannot.find.hist.q.for.w = Cannot find Q for W = {0,number,#.##} in timerange {1, date} - {2, date}
 
 no.river.selected = No river selected.
 no.gauge.selected = No gauge selected.

http://dive4elements.wald.intevation.org