[PATCH 08 of 12] issue1542: Make WQInfoObjects and server provide start and end date for mainvalues, display in table

Wald Commits scm-commit at wald.intevation.org
Tue Nov 12 17:18:47 CET 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1384272711 -3600
# Node ID 2ca1f3991e17b56211c480932f258d446d43e0cb
# Parent  7597bae608b3150a2a8067a8409c4d76db552cf0
issue1542: Make WQInfoObjects and server provide start and end date for mainvalues, display in table.

diff -r 7597bae608b3 -r 2ca1f3991e17 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/WTable.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/WTable.java	Tue Nov 12 17:10:38 2013 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/WTable.java	Tue Nov 12 17:11:51 2013 +0100
@@ -47,6 +47,14 @@
         name.setType(ListGridFieldType.TEXT);
         name.setWidth("*");
 
+        ListGridField startTime = new ListGridField("starttime", MESSAGE.starttime());
+        startTime.setType(ListGridFieldType.DATE);
+        startTime.setWidth("50");
+
+        ListGridField stopTime = new ListGridField("stoptime", MESSAGE.stoptime());
+        stopTime.setType(ListGridFieldType.DATE);
+        stopTime.setWidth("50");
+
         ListGridField type = new ListGridField("type", MESSAGE.type());
         type.setType(ListGridFieldType.TEXT);
         type.setWidth("50");
@@ -77,7 +85,7 @@
         select.setWidth(70);
         select.setCellIcon(baseUrl + MESSAGE.markerGreen());
 
-        setFields(select, name, type, value);
+        setFields(select, name, type, value, startTime, stopTime);
         hideField("select");
     }
 
diff -r 7597bae608b3 -r 2ca1f3991e17 gwt-client/src/main/java/org/dive4elements/river/client/server/WQInfoServiceImpl.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/WQInfoServiceImpl.java	Tue Nov 12 17:10:38 2013 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/WQInfoServiceImpl.java	Tue Nov 12 17:11:51 2013 +0100
@@ -10,7 +10,9 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Calendar;
 import java.util.Comparator;
+import java.util.Date;
 import java.util.List;
 
 import javax.xml.xpath.XPathConstants;
@@ -198,13 +200,32 @@
         String official = XMLUtils.xpathString(
             node, "@official", ArtifactNamespaceContext.INSTANCE);
 
+        String starttime = XMLUtils.xpathString(
+            node, "@starttime", ArtifactNamespaceContext.INSTANCE);
+
+        String stoptime = XMLUtils.xpathString(
+            node, "@stoptime", ArtifactNamespaceContext.INSTANCE);
+
         if (name != null && type != null) {
             try {
+                Calendar cal = Calendar.getInstance();
+                java.util.Date start = null;
+                java.util.Date stop = null;
+                if (!starttime.equals("")) {
+                    cal.setTimeInMillis(Long.parseLong(starttime));
+                    start = cal.getTime();
+                }
+                if (!stoptime.equals("")) {
+                    cal.setTimeInMillis(Long.parseLong(stoptime));
+                    stop = cal.getTime();
+                }
                 return new WQInfoObjectImpl(
                     name,
                     type,
                     new Double(value),
-                    official != null && official.equalsIgnoreCase("true"));
+                    official != null && official.equalsIgnoreCase("true"),
+                    start,
+                    stop);
             }
             catch (NumberFormatException nfe) {
                 logger.warn(nfe.getLocalizedMessage());
diff -r 7597bae608b3 -r 2ca1f3991e17 gwt-client/src/main/java/org/dive4elements/river/client/shared/model/WQInfoRecord.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/WQInfoRecord.java	Tue Nov 12 17:10:38 2013 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/WQInfoRecord.java	Tue Nov 12 17:11:51 2013 +0100
@@ -8,6 +8,7 @@
 
 package org.dive4elements.river.client.shared.model;
 
+import java.util.Date;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
 
 
@@ -34,6 +35,8 @@
         setName(info.getName());
         setType(info.getType());
         setValue(info.getValue());
+        setStartTime(info.getStartTime());
+        setStopTime(info.getStopTime());
         setOfficial(info.isOfficial() ? "X" : "");
     }
 
@@ -66,6 +69,22 @@
         return getAttributeAsDouble("value");
     }
 
+    public void setStartTime(Date value) {
+        setAttribute("starttime", value);
+    }
+
+    public Date getStartTime() {
+        return getAttributeAsDate("starttime");
+    }
+
+    public void setStopTime(Date value) {
+        setAttribute("stoptime", value);
+    }
+
+    public Date getStopTime() {
+        return getAttributeAsDate("stoptime");
+    }
+
     public void setOfficial(String value) {
         setAttribute("official", value);
     }


More information about the Dive4elements-commits mailing list