annotate flys-client/src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java @ 4668:87c938d082d6

Added facet for filtered flow velocity and removed filter from default facet.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 13 Dec 2012 15:54:49 +0100
parents f7b3d5833f3b
children
rev   line source
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.io.InputStream;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.io.IOException;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
1510
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
6 import java.util.Map;
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
7
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import org.w3c.dom.Document;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
10 import org.apache.log4j.Logger;
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
11
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import de.intevation.artifacts.common.utils.ClientProtocolUtils;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.artifacts.common.utils.XMLUtils;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import de.intevation.artifacts.httpclient.http.HttpClient;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import de.intevation.flys.client.shared.exceptions.ServerException;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import de.intevation.flys.client.shared.model.Collection;
1376
28eb4dfe2cbf Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1370
diff changeset
23 import de.intevation.flys.client.shared.model.MapConfig;
1510
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
24 import de.intevation.flys.client.shared.model.OutputMode;
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import de.intevation.flys.client.client.services.MapOutputService;
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 public class MapOutputServiceImpl
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 extends RemoteServiceServlet
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 implements MapOutputService
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 {
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
33 private static final Logger logger =
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
34 Logger.getLogger(MapOutputServiceImpl.class);
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
35
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
36
1376
28eb4dfe2cbf Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1370
diff changeset
37 public static final String ERROR_NO_MAP_CONFIG = "error_no_map_config";
28eb4dfe2cbf Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1370
diff changeset
38
1510
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
39 public static final String ERROR_NO_MAP_OUTPUT_TYPE = "error_no_map_output_type";
1376
28eb4dfe2cbf Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1370
diff changeset
40
28eb4dfe2cbf Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1370
diff changeset
41 public MapConfig doOut(Collection collection)
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 throws ServerException
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
44 logger.info("MapOutputServiceImpl.doOut");
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
1370
9085cffbb7c4 Made the URL of Artifact server available via ServletContext parameter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
46 String url = getServletContext().getInitParameter("server-url");
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 String uuid = collection.identifier();
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
1510
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
49 Map<String, OutputMode> modes = collection.getOutputModes();
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
50 String requestMode = "";
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
51 if (modes.containsKey("floodmap")) {
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
52 requestMode = "floodmap";
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
53 }
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
54 else if (modes.containsKey("map")) {
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
55 requestMode = "map";
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
56 }
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
57 else {
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
58 throw new ServerException(ERROR_NO_MAP_OUTPUT_TYPE);
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
59 }
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
60
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 try {
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 Document request = ClientProtocolUtils.newOutCollectionDocument(
1510
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
63 uuid, requestMode, requestMode);
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64
1370
9085cffbb7c4 Made the URL of Artifact server available via ServletContext parameter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
65 HttpClient client = new HttpClientImpl(url);
1510
f7b3d5833f3b Updated the MapOutputService to be able to request the new output type 'map'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1376
diff changeset
66 InputStream is = client.collectionOut(request, uuid, requestMode);
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 Document response = XMLUtils.parseDocument(is);
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
1376
28eb4dfe2cbf Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1370
diff changeset
70 return MapHelper.parseConfig(response);
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 }
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 catch (ConnectionException e) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
73 logger.error(e, e);
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 }
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 catch (IOException ioe) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1365
diff changeset
76 logger.error(ioe, ioe);
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 }
1376
28eb4dfe2cbf Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1370
diff changeset
78
28eb4dfe2cbf Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1370
diff changeset
79 throw new ServerException(ERROR_NO_MAP_CONFIG);
1365
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 }
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 }
4c65c5b60a86 First step of refactoring the map creation - implemented a MapOutputService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org