[PATCH 2 of 2] bundu wst time range globalErrorMsg to client - no error thrown
Wald Commits
scm-commit at wald.intevation.org
Thu Aug 16 11:40:34 CEST 2018
# HG changeset patch
# User gernotbelger
# Date 1534412428 -7200
# Node ID 0fb76f2d4e5bffd1462d08efffbecfba61929491
# Parent fe7edef5af47ffe8346036f0de30f5dace5dfd79
bundu wst time range globalErrorMsg to client - no error thrown
diff -r fe7edef5af47 -r 0fb76f2d4e5b gwt-client/src/main/java/org/dive4elements/river/client/client/services/DynamicMainValuesTimeRangeDeterminationService.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/services/DynamicMainValuesTimeRangeDeterminationService.java Thu Aug 16 10:04:54 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/services/DynamicMainValuesTimeRangeDeterminationService.java Thu Aug 16 11:40:28 2018 +0200
@@ -9,7 +9,7 @@
package org.dive4elements.river.client.client.services;
import org.dive4elements.river.client.shared.exceptions.ServerException;
-import org.dive4elements.river.client.shared.model.GaugeInfoObject;
+import org.dive4elements.river.client.shared.model.GaugeInfoResult;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@@ -27,6 +27,6 @@
*
* @throws ServerException
*/
- GaugeInfoObject[] getGaugeInfo(String locale, String river, final String[] gauges, int startYear, int endYear) throws ServerException;
+ GaugeInfoResult getGaugeInfo(String locale, String river, final String[] gauges, int startYear, int endYear) throws ServerException;
}
\ No newline at end of file
diff -r fe7edef5af47 -r 0fb76f2d4e5b gwt-client/src/main/java/org/dive4elements/river/client/client/services/DynamicMainValuesTimeRangeDeterminationServiceAsync.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/services/DynamicMainValuesTimeRangeDeterminationServiceAsync.java Thu Aug 16 10:04:54 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/services/DynamicMainValuesTimeRangeDeterminationServiceAsync.java Thu Aug 16 11:40:28 2018 +0200
@@ -9,7 +9,7 @@
*/
package org.dive4elements.river.client.client.services;
-import org.dive4elements.river.client.shared.model.GaugeInfoObject;
+import org.dive4elements.river.client.shared.model.GaugeInfoResult;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -17,5 +17,5 @@
* @author Domenico Nardi Tironi
*/
public interface DynamicMainValuesTimeRangeDeterminationServiceAsync {
- void getGaugeInfo(String locale, String river, final String[] gauges, int startDate, int endDate, AsyncCallback<GaugeInfoObject[]> callback);
+ void getGaugeInfo(String locale, String river, final String[] gauges, int startDate, int endDate, AsyncCallback<GaugeInfoResult> cb);
}
\ No newline at end of file
diff -r fe7edef5af47 -r 0fb76f2d4e5b gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractWQAdaptedInputPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractWQAdaptedInputPanel.java Thu Aug 16 10:04:54 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractWQAdaptedInputPanel.java Thu Aug 16 11:40:28 2018 +0200
@@ -474,7 +474,7 @@
if (wqi == null) {
// this.wTables.get(gaugeIdx).setLoadingDataMessage(""); (keine W-tables vorhanden - wo W-Table benutzt werden, gibt es
// ein Popup)
- final String emptyMsg = gauge.getErrorMessage();
+ final String emptyMsg = gauge.getErrorMsg();
final QDTable table = this.qdTables.get(gaugeIdx);
table.setEmptyMessage(emptyMsg == null ? "" : emptyMsg);
table.redraw();
@@ -492,7 +492,7 @@
}
}
if (gauge != null)
- AbstractWQAdaptedInputPanel.this.doubleArrayPanels.get(gaugeIdx).setError(gauge.getErrorMessage());
+ AbstractWQAdaptedInputPanel.this.doubleArrayPanels.get(gaugeIdx).setError(gauge.getErrorMsg());
}
public void resetLoadingMessageOfQTable(final String msg) {
diff -r fe7edef5af47 -r 0fb76f2d4e5b gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/BunduWstWQPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/BunduWstWQPanel.java Thu Aug 16 10:04:54 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/BunduWstWQPanel.java Thu Aug 16 11:40:28 2018 +0200
@@ -29,6 +29,7 @@
import org.dive4elements.river.client.shared.model.DefaultData;
import org.dive4elements.river.client.shared.model.DefaultDataItem;
import org.dive4elements.river.client.shared.model.GaugeInfoObject;
+import org.dive4elements.river.client.shared.model.GaugeInfoResult;
import org.dive4elements.river.client.shared.model.WQDataItem;
import org.dive4elements.river.client.shared.model.WQInfoObject;
@@ -393,7 +394,7 @@
// Gauge ranges overlap, move start and end a bit closer
// to each other.
- final AsyncCallback<GaugeInfoObject[]> cb = new AsyncCallback<GaugeInfoObject[]>() {
+ final AsyncCallback<GaugeInfoResult> cb = new AsyncCallback<GaugeInfoResult>() {
@Override
public void onFailure(final Throwable caught) {
GWT.log("Could not recieve wq informations.");
@@ -405,17 +406,27 @@
}
@Override
- public void onSuccess(final GaugeInfoObject[] result) {
+ public void onSuccess(final GaugeInfoResult result) {
// TODO Auto-generated method stub
- final int num = result != null ? result.length : 0;
+ final String globalErrorMsg = result.getGlobalErrorMsg();
+ if (!globalErrorMsg.equals("")) {
+ resetLoadingMessageOfQTable("");
+ // disable weiter-knopf
+ getSubmitBtn().disable();
+ SC.warn(globalErrorMsg);
+ }
+
+ final GaugeInfoObject[] gauges = result.getGaugeInfoObjects();
+
+ final int num = gauges != null ? gauges.length : 0;
GWT.log("Received timeranges for gauges");
if (num == 0) {
return;
}
- for (int i = 0; i < result.length; i++) {
- final GaugeInfoObject gauge = result[i];
+ for (int i = 0; i < gauges.length; i++) {
+ final GaugeInfoObject gauge = gauges[i];
// Gauge ranges overlap, move start and end a bit closer
// to each other.
final Double[] range = getGaugeNamesRange().get(gauge.getName());
@@ -435,11 +446,11 @@
GWT.log("Received " + num + " wq informations (" + fi + ".");
addWQInfo(wqi, fi, gauge);
- if (fi == (result.length - 1))
+ if (fi == (gauges.length - 1) && globalErrorMsg.equals(""))
getSubmitBtn().enable();
}
};
- callMainValuesService(locale, river, range[0] + rDiff, range[1] - rDiff, gauge.getStartTime(), gauge.getStopTime(), cb);
+ callMainValuesService(locale, river, range[0] + rDiff, range[1] - rDiff, gauge.getStartdate(), gauge.getEnddate(), cb);
}
}
diff -r fe7edef5af47 -r 0fb76f2d4e5b gwt-client/src/main/java/org/dive4elements/river/client/server/DynamicMainValuesTimeRangeDeterminationServiceImpl.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/DynamicMainValuesTimeRangeDeterminationServiceImpl.java Thu Aug 16 10:04:54 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/DynamicMainValuesTimeRangeDeterminationServiceImpl.java Thu Aug 16 11:40:28 2018 +0200
@@ -20,7 +20,8 @@
import org.dive4elements.river.client.client.services.DynamicMainValuesTimeRangeDeterminationService;
import org.dive4elements.river.client.shared.exceptions.ServerException;
import org.dive4elements.river.client.shared.model.GaugeInfoObject;
-import org.dive4elements.river.client.shared.model.GaugeInfoObjectImpl;
+import org.dive4elements.river.client.shared.model.GaugeInfoResult;
+import org.dive4elements.river.client.shared.model.GaugeInfoResultImpl;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -36,19 +37,14 @@
private static final String XPATH_ROOT = "dynamic-mainvalues-input";
private String globalErrorMsg = null;
- private GaugeInfoObject[] callService(final String serviceName, final Document input, final String locale) throws ServerException {
+ private GaugeInfoResult callService(final String serviceName, final Document input, final String locale) throws ServerException {
final String url = getServletContext().getInitParameter("server-url");
final HttpClient client = new HttpClientImpl(url, locale);
try {
final Document result = client.callService(url, serviceName, input);
- final GaugeInfoObject[] objects = extractDates(result);
- if (!this.globalErrorMsg.equals(""))
- throw new ServerException(this.globalErrorMsg);
- // log.debug("Extract wq info objects now.");
- return objects;
-
+ return extractDates(result);
}
catch (final ConnectionException ce) {
// log.error(ce, ce);
@@ -57,9 +53,10 @@
throw new ServerException("error_no_wqinput_found");
}
- private GaugeInfoObject[] extractDates(final Document result) throws ServerException {
+ private GaugeInfoResult extractDates(final Document result) throws ServerException {
final List<GaugeInfoObject> results = new ArrayList<GaugeInfoObject>();
final NodeList list = result.getChildNodes();
+ final List<GaugeInfoObject> gauges = new ArrayList<GaugeInfoObject>();
if (list != null && list.getLength() == 1) {
// log.warn("No wq info found.");
@@ -74,13 +71,16 @@
final NamedNodeMap map = node.getAttributes();
final String gaugeName = getStringFromMap("name", map);
final String error = getStringFromMap("error-message", map);
- final GaugeInfoObject gi = new GaugeInfoObjectImpl(gaugeName, error, getDateFromMap("date-from", map), getDateFromMap("date-to", map));
- results.add(gi);
+ final GaugeInfoObject gi = new GaugeInfoObject(gaugeName, error, getDateFromMap("date-from", map), getDateFromMap("date-to", map));
+ // results.add(gi);
+ gauges.add(gi);
}
}
}
- return results.toArray(new GaugeInfoObject[results.size()]);
+
+ return new GaugeInfoResultImpl(this.globalErrorMsg, gauges.toArray(new GaugeInfoObject[gauges.size()]));
+
}
private Date getDateFromMap(final String attrName, final NamedNodeMap map) {
@@ -98,7 +98,7 @@
}
@Override
- public GaugeInfoObject[] getGaugeInfo(final String locale, final String river, final String[] gauges, final int startYear, final int endYear)
+ public GaugeInfoResult getGaugeInfo(final String locale, final String river, final String[] gauges, final int startYear, final int endYear)
throws ServerException {
final Document input = createInput(river, gauges, startYear, endYear);
diff -r fe7edef5af47 -r 0fb76f2d4e5b gwt-client/src/main/java/org/dive4elements/river/client/shared/model/GaugeInfoObject.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/GaugeInfoObject.java Thu Aug 16 10:04:54 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.client.shared.model;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
- */
-public interface GaugeInfoObject extends Serializable {
-
- String getName();
-
- String getErrorMessage();
-
- Date getStartTime();
-
- Date getStopTime();
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r fe7edef5af47 -r 0fb76f2d4e5b gwt-client/src/main/java/org/dive4elements/river/client/shared/model/GaugeInfoObjectImpl.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/GaugeInfoObjectImpl.java Thu Aug 16 10:04:54 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.client.shared.model;
-
-import java.util.Date;
-
-/**
- * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
- */
-public class GaugeInfoObjectImpl implements GaugeInfoObject {
-
- private static final long serialVersionUID = 1L;
-
- protected String name;
-
- protected String errorMsg;
-
- Date startTime;
-
- Date stopTime;
-
- public GaugeInfoObjectImpl() {
- }
-
- public GaugeInfoObjectImpl(final String name, final String errorMsg, final Date startTime, final Date stopTime) {
- this.name = name;
- this.errorMsg = errorMsg;
- this.startTime = startTime;
- this.stopTime = stopTime;
- }
-
- @Override
- public Date getStopTime() {
- return this.stopTime;
- }
-
- @Override
- public Date getStartTime() {
- return this.startTime;
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- @Override
- public String getErrorMessage() {
- return this.errorMsg;
- }
-
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r fe7edef5af47 -r 0fb76f2d4e5b gwt-client/src/main/java/org/dive4elements/river/client/shared/model/GaugeInfoResult.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/GaugeInfoResult.java Thu Aug 16 11:40:28 2018 +0200
@@ -0,0 +1,22 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.client.shared.model;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public interface GaugeInfoResult extends Serializable {
+
+ String getGlobalErrorMsg();
+
+ GaugeInfoObject[] getGaugeInfoObjects();
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r fe7edef5af47 -r 0fb76f2d4e5b gwt-client/src/main/java/org/dive4elements/river/client/shared/model/GaugeInfoResultImpl.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/GaugeInfoResultImpl.java Thu Aug 16 11:40:28 2018 +0200
@@ -0,0 +1,43 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.client.shared.model;
+
+/**
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public class GaugeInfoResultImpl implements GaugeInfoResult {
+
+ private static final long serialVersionUID = 1L;
+
+ GaugeInfoObject[] gauges; // NO LIST, SERIALIZE-Problem// = new ArrayList<GaugeInfoObject>();
+
+ String globalErrorMsg;
+
+ public GaugeInfoResultImpl() {
+
+ }
+
+ public GaugeInfoResultImpl(final String globalErrorMsg, final GaugeInfoObject[] gauges) {
+ this.globalErrorMsg = globalErrorMsg;
+ this.gauges = gauges;
+ }
+
+ @Override
+ public String getGlobalErrorMsg() {
+
+ return this.globalErrorMsg;
+ }
+
+ @Override
+ public GaugeInfoObject[] getGaugeInfoObjects() {
+
+ return this.gauges;
+ }
+
+}
More information about the Dive4Elements-commits
mailing list