Mercurial > dive4elements > river
changeset 4115:0cc2c3d89a9d
#900 Added complete start and end date to the discharge info service and display on in the client side.
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 12 Oct 2012 09:27:18 +0200 |
parents | ae5119da92cd |
children | 4ffeccc5b5a1 f6c73ee1b7f1 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeInfoService.java flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/range/DischargeInfoDataSource.java |
diffstat | 5 files changed, 73 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Thu Oct 11 14:54:10 2012 +0200 +++ b/flys-artifacts/ChangeLog Fri Oct 12 09:27:18 2012 +0200 @@ -1,3 +1,8 @@ +2012-10-12 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/services/DischargeInfoService.java: + Insert the date as time millis for each discharge curve. + 2012-10-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/model/sq/Measurements.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeInfoService.java Thu Oct 11 14:54:10 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeInfoService.java Fri Oct 12 09:27:18 2012 +0200 @@ -43,6 +43,7 @@ CallMeta callMeta ) { logger.debug("DischargeInfoService.process"); + logger.debug(XMLUtils.toString(data)); String gaugeNumber = XMLUtils.xpathString( data, GAUGE_XPATH, ArtifactNamespaceContext.INSTANCE); @@ -97,28 +98,20 @@ Date startTime = ti.getStartTime(); Date stopTime = ti.getStopTime(); - // Get the year for start end end date. - int startYear; - int stopYear; - Calendar c = new GregorianCalendar(); if (startTime != null) { - c.setTime(startTime); - startYear = c.get(Calendar.YEAR); + discharge.setAttribute("start", String.valueOf(startTime.getTime())); } else { - startYear = -1; + discharge.setAttribute("start", "-1"); } + if (stopTime != null) { - c.setTime(stopTime); - stopYear = c.get(Calendar.YEAR); + discharge.setAttribute("end", String.valueOf(stopTime.getTime())); } else { - stopYear = -1; + discharge.setAttribute("end", "-1"); } - discharge.setAttribute("start", String.valueOf(startYear)); - discharge.setAttribute("end", String.valueOf(stopYear)); - all.appendChild(discharge); } result.appendChild(all);
--- a/flys-client/ChangeLog Thu Oct 11 14:54:10 2012 +0200 +++ b/flys-client/ChangeLog Fri Oct 12 09:27:18 2012 +0200 @@ -1,3 +1,14 @@ +2012-10-12 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java: + Parse modified date of discharge curves (adapted date format) and + display date as human readable string instead of milli seconds since + 1970. + + * src/main/java/de/intevation/flys/client/client/ui/range/DischargeInfoDataSource.java: + Set field type from 'INTEGER' to 'TEXT' for start and end date. Is there + no type for LONG?? + 2012-10-09 Christian Lins <christian.lins@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/LinkSelection.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java Thu Oct 11 14:54:10 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java Fri Oct 12 09:27:18 2012 +0200 @@ -1,40 +1,35 @@ package de.intevation.flys.client.client.ui; -import java.util.List; import java.util.ArrayList; import java.util.Date; +import java.util.List; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.DateTimeFormat; - +import com.smartgwt.client.data.Record; import com.smartgwt.client.types.ListGridFieldType; - -import com.smartgwt.client.data.Record; -import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.DateRangeItem; -import com.smartgwt.client.widgets.Label; - -import com.smartgwt.client.widgets.layout.VLayout; -import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; -import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import com.smartgwt.client.widgets.grid.events.RecordClickHandler; -import com.smartgwt.client.widgets.grid.events.RecordClickEvent; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; -import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.Config; - -import de.intevation.flys.client.shared.model.DataList; -import de.intevation.flys.client.shared.model.DataItem; +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.ui.range.DischargeInfoDataSource; import de.intevation.flys.client.shared.model.ArtifactDescription; import de.intevation.flys.client.shared.model.Data; -import de.intevation.flys.client.shared.model.RangeData; +import de.intevation.flys.client.shared.model.DataItem; +import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.LongRangeData; - -import de.intevation.flys.client.client.ui.range.DischargeInfoDataSource; +import de.intevation.flys.client.shared.model.RangeData; /** * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> @@ -53,7 +48,6 @@ yearTable = new ListGrid(); yearTable.setAutoFetchData(true); yearTable.setShowHeaderContextMenu(false); - } public Canvas create(DataList data) { @@ -171,14 +165,10 @@ @Override public void setLower(String lower) { try { - DateTimeFormat dtf = - DateTimeFormat.getFormat("yyyy"); - Date dy = dtf.parse(lower); - dy.setMonth(0); - dy.setDate(1); - dateRange.setFromDate(dy); + long value = Long.valueOf(lower); + dateRange.setFromDate(new Date(value)); } - catch(IllegalArgumentException iae) { + catch (NumberFormatException nfe) { GWT.log("could not parse lower date."); //TODO: Messagebox with error. } @@ -188,20 +178,29 @@ @Override public void setUpper(String upper) { try { - DateTimeFormat dtf = - DateTimeFormat.getFormat("yyyy"); - Date dy = dtf.parse(upper); - dy.setMonth(0); - dy.setDate(1); - dateRange.setToDate(dy); + long value = Long.valueOf(upper); + dateRange.setToDate(new Date(value)); } - catch(IllegalArgumentException iae) { + catch (NumberFormatException nfe) { GWT.log("could not parse upper date."); //TODO: Messagebox with error. } } + protected String buildDateString(String raw) { + if (raw == null || raw.length() == 0) { + return ""; + } + + long value = Long.valueOf(raw); + Date date = new Date(value); + DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat(); + + return dtf.format(date); + } + + protected ListGrid initYearTable() { String baseUrl = GWT.getHostPageBaseURL(); @@ -216,13 +215,21 @@ public String format( Object value, ListGridRecord record, - int rowNum, int colNum) { - if (value == null) return null; - if (value.toString().equals("-1")) { + int rowNum, int colNum + ) { + if (value == null) { + return null; + } + else if (value.toString().equals("-1")) { return ""; } + else if (colNum == 3 || colNum == 4) { + return buildDateString(value.toString()); + } + else { return value.toString(); - } + } + } }; @@ -266,13 +273,13 @@ ListGridField start = new ListGridField("start", MESSAGES.start_year()); start.setType(ListGridFieldType.INTEGER); - start.setWidth(50); + start.setWidth(100); start.setCellFormatter(cf); ListGridField end = new ListGridField("end", MESSAGES.end_year()); end.setType(ListGridFieldType.INTEGER); - end.setWidth(50); + end.setWidth(100); end.setCellFormatter(cf); yearTable.setFields(addstart, addend, desc, start, end);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/range/DischargeInfoDataSource.java Thu Oct 11 14:54:10 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/range/DischargeInfoDataSource.java Fri Oct 12 09:27:18 2012 +0200 @@ -1,11 +1,14 @@ package de.intevation.flys.client.client.ui.range; +import java.util.Date; + import com.google.gwt.core.client.GWT; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.FieldType; +import com.smartgwt.client.util.DateDisplayFormatter; public class DischargeInfoDataSource extends DataSource { @@ -21,10 +24,10 @@ "description", FieldType.TEXT, "description"); DataSourceField start = new DataSourceField( - "start", FieldType.INTEGER, "start"); + "start", FieldType.TEXT, "start"); DataSourceField end = new DataSourceField( - "end", FieldType.INTEGER, "end"); + "end", FieldType.TEXT, "end"); setFields(desc, start, end); setDataURL(getServiceURL(url, gauge));