teichmann@5861: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5861: * Software engineering by Intevation GmbH teichmann@5861: * teichmann@5993: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5861: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5993: * documentation coming with Dive4Elements River for details. teichmann@5861: */ teichmann@5861: teichmann@5835: package org.dive4elements.river.client.client.ui.range; ingo@782: ingo@782: import com.google.gwt.core.client.GWT; tom@8865: import com.google.gwt.http.client.URL; ingo@782: ingo@782: import com.smartgwt.client.data.DataSource; ingo@782: import com.smartgwt.client.data.DataSourceField; ingo@782: import com.smartgwt.client.types.DSDataFormat; ingo@782: import com.smartgwt.client.types.FieldType; ingo@782: ingo@782: ingo@782: public class DistanceInfoDataSource extends DataSource { ingo@782: ingo@782: public static final String XPATH_DISTANCE_DEFAULT = "/distances/distance"; ingo@782: ingo@782: ingo@782: public DistanceInfoDataSource(String url, String river, String filter) { ingo@782: setDataFormat(DSDataFormat.XML); ingo@782: setRecordXPath(XPATH_DISTANCE_DEFAULT); ingo@782: ingo@782: DataSourceField desc = new DataSourceField( ingo@782: "description", FieldType.TEXT, "description"); ingo@782: ingo@782: DataSourceField from = new DataSourceField( ingo@782: "from", FieldType.TEXT, "from"); ingo@782: ingo@782: DataSourceField to = new DataSourceField( ingo@782: "to", FieldType.TEXT, "to"); ingo@782: ingo@782: DataSourceField side = new DataSourceField( ingo@782: "riverside", FieldType.TEXT, "riverside"); ingo@782: ingo@782: DataSourceField top = new DataSourceField( ingo@782: "top", FieldType.TEXT, "top"); ingo@782: ingo@782: DataSourceField bottom = new DataSourceField( ingo@782: "bottom", FieldType.TEXT, "bottom"); ingo@782: ingo@782: setFields(desc, from, to, side, top, bottom); ingo@782: setDataURL(getServiceURL(url, river, filter)); ingo@782: } ingo@782: ingo@782: tom@8865: protected String getServiceURL( tom@8865: String server, tom@8865: String river, tom@8865: String filter tom@8865: ) { tom@8865: String url = URL.encode(GWT.getModuleBaseURL() tom@8865: + "distanceinfoxml" tom@8865: + "?server=" + server tom@8865: + "&river=" + river tom@8865: + "&filter=" + filter); ingo@782: ingo@782: return url; ingo@782: } ingo@782: } ingo@782: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :