changeset 6837:9da2298ae380

(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)
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 15 Aug 2013 15:57:13 +0200
parents caf027fe0715
children a895eb07a7dc
files gwt-client/src/main/java/org/dive4elements/river/client/client/services/DischargeInfoService.java gwt-client/src/main/java/org/dive4elements/river/client/client/services/DischargeInfoServiceAsync.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/GaugeTimeRangePanel.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/range/DischargeInfoDataSource.java gwt-client/src/main/java/org/dive4elements/river/client/server/DischargeInfoServiceImpl.java gwt-client/src/main/java/org/dive4elements/river/client/server/DischargeInfoXML.java
diffstat 6 files changed, 23 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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 :
--- 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 :
--- 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());
 
--- 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;
     }
--- 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);
--- 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);

http://dive4elements.wald.intevation.org