Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
255:e4f0bef52689 | 256:5e1c1b7d6516 |
---|---|
1 package de.intevation.flys.client.server; | |
2 | |
3 import java.util.List; | |
4 | |
5 import java.io.Reader; | |
6 import java.io.InputStream; | |
7 import java.io.InputStreamReader; | |
8 import java.io.IOException; | |
9 | |
10 import org.w3c.dom.Document; | |
11 import org.w3c.dom.Element; | |
12 | |
13 import com.google.gwt.user.server.rpc.RemoteServiceServlet; | |
14 | |
15 import au.com.bytecode.opencsv.CSVReader; | |
16 | |
17 import de.intevation.artifacts.common.ArtifactNamespaceContext; | |
18 import de.intevation.artifacts.common.utils.XMLUtils; | |
19 | |
20 import de.intevation.artifacts.httpclient.http.HttpClient; | |
21 import de.intevation.artifacts.httpclient.http.HttpClientImpl; | |
22 | |
23 import de.intevation.flys.client.shared.exceptions.ServerException; | |
24 import de.intevation.flys.client.client.services.CSVExportService; | |
25 | |
26 | |
27 /** | |
28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
29 */ | |
30 public class CSVExportServiceImpl | |
31 extends RemoteServiceServlet | |
32 implements CSVExportService | |
33 { | |
34 public static final String ERROR_NO_EXPORT_FOUND = | |
35 "error_no_export_found"; | |
36 | |
37 public List getCSV( | |
38 String url, | |
39 String locale, | |
40 String uuid, | |
41 String name) | |
42 throws ServerException | |
43 { | |
44 System.out.println("CSVExportServiceImpl.getCSV"); | |
45 | |
46 Document requestDoc = XMLUtils.newDocument(); | |
47 | |
48 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( | |
49 requestDoc, | |
50 ArtifactNamespaceContext.NAMESPACE_URI, | |
51 ArtifactNamespaceContext.NAMESPACE_PREFIX); | |
52 | |
53 if (name.startsWith("output.")) { | |
54 name = name.substring(name.indexOf(".") + 1); | |
55 } | |
56 | |
57 Element action = ec.create("art:action"); | |
58 action.setAttribute("art:type", "csv"); | |
59 action.setAttribute("art:name", name); | |
60 | |
61 requestDoc.appendChild(action); | |
62 | |
63 HttpClient client = new HttpClientImpl(url, locale); | |
64 try { | |
65 InputStream in = client.collectionOut(requestDoc, uuid, "export"); | |
66 Reader reader = new InputStreamReader (in, "UTF-8"); | |
67 CSVReader csvReader = new CSVReader (reader); | |
68 String[] line; | |
69 List l = csvReader.readAll (); | |
70 return l; | |
71 } | |
72 catch (IOException ce) { | |
73 System.err.println(ce.getLocalizedMessage()); | |
74 } | |
75 | |
76 throw new ServerException(ERROR_NO_EXPORT_FOUND); | |
77 } | |
78 } | |
79 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |