Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java @ 256:5e1c1b7d6516
Added table and service for calculation output to UI.
flys-client/trunk@1868 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 09 May 2011 14:29:53 +0000 |
parents | |
children | 5091675676d6 |
line wrap: on
line source
package de.intevation.flys.client.server; import java.util.List; import java.io.Reader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import org.w3c.dom.Document; import org.w3c.dom.Element; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import au.com.bytecode.opencsv.CSVReader; import de.intevation.artifacts.common.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifacts.httpclient.http.HttpClient; import de.intevation.artifacts.httpclient.http.HttpClientImpl; import de.intevation.flys.client.shared.exceptions.ServerException; import de.intevation.flys.client.client.services.CSVExportService; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class CSVExportServiceImpl extends RemoteServiceServlet implements CSVExportService { public static final String ERROR_NO_EXPORT_FOUND = "error_no_export_found"; public List getCSV( String url, String locale, String uuid, String name) throws ServerException { System.out.println("CSVExportServiceImpl.getCSV"); Document requestDoc = XMLUtils.newDocument(); XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( requestDoc, ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX); if (name.startsWith("output.")) { name = name.substring(name.indexOf(".") + 1); } Element action = ec.create("art:action"); action.setAttribute("art:type", "csv"); action.setAttribute("art:name", name); requestDoc.appendChild(action); HttpClient client = new HttpClientImpl(url, locale); try { InputStream in = client.collectionOut(requestDoc, uuid, "export"); Reader reader = new InputStreamReader (in, "UTF-8"); CSVReader csvReader = new CSVReader (reader); String[] line; List l = csvReader.readAll (); return l; } catch (IOException ce) { System.err.println(ce.getLocalizedMessage()); } throw new ServerException(ERROR_NO_EXPORT_FOUND); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :