[PATCH 1 of 6] (issue1353) Add river name to query for discharge Info

Wald Commits scm-commit at wald.intevation.org
Thu Aug 15 16:51:13 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1376575033 -7200
# Node ID 9da2298ae38081336bfb890841272099ee06f9a1
# Parent  caf027fe07152377d321b51426c0406183375b2b
(issue1353) Add river name to query for discharge Info

    The previous assumption was that the official number is unique
    for a gauge. This assumption is broken by having multiple variants
    of a river in the database, like Donau (schleusenkanäle)

diff -r caf027fe0715 -r 9da2298ae380 gwt-client/src/main/java/org/dive4elements/river/client/client/services/DischargeInfoService.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/services/DischargeInfoService.java	Thu Aug 15 15:50:42 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/services/DischargeInfoService.java	Thu Aug 15 15:57:13 2013 +0200
@@ -28,7 +28,8 @@
      */
     DischargeInfoObject[] getDischargeInfo(
         String locale,
-        long gauge)
+        long gauge,
+        String river)
     throws ServerException;
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r caf027fe0715 -r 9da2298ae380 gwt-client/src/main/java/org/dive4elements/river/client/client/services/DischargeInfoServiceAsync.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/services/DischargeInfoServiceAsync.java	Thu Aug 15 15:50:42 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/services/DischargeInfoServiceAsync.java	Thu Aug 15 15:57:13 2013 +0200
@@ -21,6 +21,7 @@
     void getDischargeInfo(
         String locale,
         long gauge,
+        String river,
         AsyncCallback<DischargeInfoObject[]> cb);
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r caf027fe0715 -r 9da2298ae380 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/GaugeTimeRangePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/GaugeTimeRangePanel.java	Thu Aug 15 15:50:42 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/GaugeTimeRangePanel.java	Thu Aug 15 15:57:13 2013 +0200
@@ -105,7 +105,8 @@
 
         Config config = Config.getInstance();
         String url = config.getServerUrl();
-        yearTable.setDataSource(new DischargeInfoDataSource(url, gauge));
+        String river = artifact.getArtifactDescription().getRiver();
+        yearTable.setDataSource(new DischargeInfoDataSource(url, gauge, river));
 
         helperContainer.addMember(createHelperPanel());
 
diff -r caf027fe0715 -r 9da2298ae380 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/range/DischargeInfoDataSource.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/range/DischargeInfoDataSource.java	Thu Aug 15 15:50:42 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/range/DischargeInfoDataSource.java	Thu Aug 15 15:57:13 2013 +0200
@@ -20,7 +20,7 @@
     public static final String XPATH_DISCHARGE_DEFAULT = "/discharges/discharge";
 
 
-    public DischargeInfoDataSource(String url, long gauge) {
+    public DischargeInfoDataSource(String url, long gauge, String river) {
         setDataFormat(DSDataFormat.XML);
         setRecordXPath(XPATH_DISCHARGE_DEFAULT);
 
@@ -37,15 +37,16 @@
             "end", FieldType.TEXT, "end");
 
         setFields(desc, bfgid, start, end);
-        setDataURL(getServiceURL(url, gauge));
+        setDataURL(getServiceURL(url, gauge, river));
     }
 
 
-    protected String getServiceURL(String server, long gauge) {
+    protected String getServiceURL(String server, long gauge, String river) {
         String url = GWT.getModuleBaseURL();
         url += "dischargeinfoxml";
         url += "?server=" + server;
         url += "&gauge=" + String.valueOf(gauge);
+        url += "&river=" + river;
 
         return url;
     }
diff -r caf027fe0715 -r 9da2298ae380 gwt-client/src/main/java/org/dive4elements/river/client/server/DischargeInfoServiceImpl.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/DischargeInfoServiceImpl.java	Thu Aug 15 15:50:42 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/DischargeInfoServiceImpl.java	Thu Aug 15 15:57:13 2013 +0200
@@ -48,9 +48,11 @@
     public static final String XPATH_DISTANCES = "art:discharges/art:discharge";
 
 
+    @Override
     public DischargeInfoObject[] getDischargeInfo(
         String locale,
-        long gauge)
+        long gauge,
+        String river)
     throws ServerException
     {
         logger.info("DichargeInfoServiceImpl.getDischargeInfo");
@@ -67,6 +69,10 @@
         Element gaugeEl = ec.create("gauge");
         gaugeEl.setTextContent(String.valueOf(gauge));
 
+        Element riverEl = ec.create("river");
+        riverEl.setTextContent(river);
+
+        gaugeEl.appendChild(riverEl);
         doc.appendChild(gaugeEl);
 
         HttpClient client = new HttpClientImpl(url, locale);
diff -r caf027fe0715 -r 9da2298ae380 gwt-client/src/main/java/org/dive4elements/river/client/server/DischargeInfoXML.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/DischargeInfoXML.java	Thu Aug 15 15:50:42 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/DischargeInfoXML.java	Thu Aug 15 15:57:13 2013 +0200
@@ -50,6 +50,8 @@
 
         String gauge = req.getParameter("gauge");
 
+        String river = req.getParameter("river");
+
         Document doc = XMLUtils.newDocument();
 
         XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
@@ -60,6 +62,11 @@
         Element gaugeEl = ec.create("gauge");
         gaugeEl.setTextContent(gauge);
 
+        if (river != null && !river.isEmpty()) {
+            riverEl.setTextContent(river);
+            gaugeEl.appendChild(riverEl);
+        }
+
         doc.appendChild(gaugeEl);
 
         HttpClient client = new HttpClientImpl(url);


More information about the Dive4elements-commits mailing list