changeset 7557:2ca1f3991e17

issue1542: Make WQInfoObjects and server provide start and end date for mainvalues, display in table.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 12 Nov 2013 17:11:51 +0100
parents 7597bae608b3
children 31a6b09854a6
files gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/WTable.java gwt-client/src/main/java/org/dive4elements/river/client/server/WQInfoServiceImpl.java gwt-client/src/main/java/org/dive4elements/river/client/shared/model/WQInfoRecord.java
diffstat 3 files changed, 50 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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");
     }
 
--- 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());
--- 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);
     }

http://dive4elements.wald.intevation.org