changeset 5916:d6bf8353e0fc

Historical discharge curves: Do not add calculation relevant curve into list of available curves.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 07 May 2013 19:07:08 +0200
parents 4fafe8d147b2
children c73977be1795
files artifacts/src/main/java/org/dive4elements/river/artifacts/services/DischargeInfoService.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/GaugeTimerangeState.java
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/DischargeInfoService.java	Tue May 07 18:19:57 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/DischargeInfoService.java	Tue May 07 19:07:08 2013 +0200
@@ -50,13 +50,15 @@
         GlobalContext globalContext,
         CallMeta      callMeta
     ) {
-        logger.debug("DischargeInfoService.process");
-        logger.debug(XMLUtils.toString(data));
+        if (logger.isDebugEnabled()) {
+            logger.debug("DischargeInfoService.process");
+            logger.debug(XMLUtils.toString(data));
+        }
 
         String gaugeNumber = XMLUtils.xpathString(
             data, GAUGE_XPATH, ArtifactNamespaceContext.INSTANCE);
 
-        if(gaugeNumber == null ||
+        if (gaugeNumber == null ||
            (gaugeNumber = gaugeNumber.trim()).length() == 0) {
             logger.warn("No gauge specified. Cannot return discharge info.");
             return XMLUtils.newDocument();
@@ -74,6 +76,10 @@
         }
 
         Gauge gauge = Gauge.getGaugeByOfficialNumber(gn);
+        if (gauge == null) {
+            logger.warn("No such gauge found.");
+            return XMLUtils.newDocument();
+        }
 
         logger.debug("Found gauge: " + gauge.getName());
 
@@ -87,6 +93,8 @@
         List<DischargeTable> tables = gauge.getDischargeTables();
         Collections.sort(tables);
 
+        logger.debug("# of tables:" + tables.size());
+
         Element all = result.createElement("discharges");
         for (DischargeTable dt: tables) {
             if (dt.getKind() == DischargeTables.MASTER) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/GaugeTimerangeState.java	Tue May 07 18:19:57 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/GaugeTimerangeState.java	Tue May 07 19:07:08 2013 +0200
@@ -47,7 +47,7 @@
                 "SELECT min(start_time) as min, max(stop_time) as max " +
                         "FROM time_intervals WHERE id in " +
                         "(SELECT time_interval_id FROM discharge_tables " +
-                "WHERE gauge_id =:gid)");
+                "WHERE kind <> 0 and gauge_id =:gid)");
 
         query.addScalar("min", StandardBasicTypes.CALENDAR);
         query.addScalar("max", StandardBasicTypes.CALENDAR);

http://dive4elements.wald.intevation.org