changeset 1365:4c65c5b60a86

First step of refactoring the map creation - implemented a MapOutputService. flys-client/trunk@3066 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 25 Oct 2011 10:29:37 +0000
parents 9981ba2ee13a
children d0eb2202ffbe
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/services/MapOutputService.java flys-client/src/main/java/de/intevation/flys/client/client/services/MapOutputServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java flys-client/src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java flys-client/src/main/webapp/WEB-INF/web.xml
diffstat 6 files changed, 138 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Oct 24 13:35:30 2011 +0000
+++ b/flys-client/ChangeLog	Tue Oct 25 10:29:37 2011 +0000
@@ -1,3 +1,19 @@
+2011-10-25  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/services/MapOutputServiceAsync.java,
+	  src/main/java/de/intevation/flys/client/client/services/MapOutputService.java,
+	  src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java:
+	  New (but not finished yet). This service calls the out() REST resource
+	  of an ArtifactCollection and should (work in progress) return a map
+	  configuration which will be used to initialize an OpenLayers map.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java:
+	  Call the MapOutputService while instantiating a new MapOutputTab but
+	  there is no code that handles the response yet (because the service
+	  currently doesn't return a value).
+
+	* src/main/webapp/WEB-INF/web.xml: Registered the new MapOutputService.
+
 2011-10-24  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/Toolbar.java: New. An
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/MapOutputService.java	Tue Oct 25 10:29:37 2011 +0000
@@ -0,0 +1,21 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.Collection;
+
+
+/**
+ * This interface describes the service to add an existing artifact to an
+ * existing collection.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+@RemoteServiceRelativePath("map")
+public interface MapOutputService extends RemoteService {
+
+    void doOut(Collection collection, String serverUrl) throws ServerException;
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/MapOutputServiceAsync.java	Tue Oct 25 10:29:37 2011 +0000
@@ -0,0 +1,18 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import de.intevation.flys.client.shared.model.Collection;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public interface MapOutputServiceAsync {
+
+    public void doOut(
+        Collection collection,
+        String     serverUrl,
+        AsyncCallback<Void> callback);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java	Mon Oct 24 13:35:30 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java	Tue Oct 25 10:29:37 2011 +0000
@@ -43,6 +43,8 @@
 import de.intevation.flys.client.client.Config;
 import de.intevation.flys.client.client.services.StepForwardService;
 import de.intevation.flys.client.client.services.StepForwardServiceAsync;
+import de.intevation.flys.client.client.services.MapOutputService;
+import de.intevation.flys.client.client.services.MapOutputServiceAsync;
 import de.intevation.flys.client.client.event.RedrawRequestHandler;
 import de.intevation.flys.client.client.event.RedrawRequestEvent;
 import de.intevation.flys.client.client.ui.CollectionView;
@@ -62,6 +64,9 @@
     protected StepForwardServiceAsync feedService =
         GWT.create(StepForwardService.class);
 
+    protected MapOutputServiceAsync mapService =
+        GWT.create(MapOutputService.class);
+
     protected MapToolbar controlPanel;
     protected ThemePanel themePanel;
     protected Widget     mapPanel;
@@ -79,6 +84,18 @@
 
         floodMap = new FloodMap(getSrid(), getMaxExtent());
 
+        mapService.doOut(collection,  "http://localhost:8181",
+            new AsyncCallback<Void>() {
+                public void onFailure(Throwable caught) {
+                    GWT.log("MAP ERROR: " + caught.getMessage());
+                }
+
+                public void onSuccess(Void v) {
+                    GWT.log("MAP SUCCESS!");
+                }
+            }
+        );
+
         initLayout();
         initLayers();
         initBarriers();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java	Tue Oct 25 10:29:37 2011 +0000
@@ -0,0 +1,56 @@
+package de.intevation.flys.client.server;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+import org.w3c.dom.Document;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+import de.intevation.artifacts.common.utils.ClientProtocolUtils;
+import de.intevation.artifacts.common.utils.XMLUtils;
+
+import de.intevation.artifacts.httpclient.http.HttpClient;
+import de.intevation.artifacts.httpclient.http.HttpClientImpl;
+import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.Collection;
+
+import de.intevation.flys.client.client.services.MapOutputService;
+
+
+public class MapOutputServiceImpl
+extends      RemoteServiceServlet
+implements   MapOutputService
+{
+
+    public void doOut(Collection collection, String serverUrl)
+    throws ServerException
+    {
+        System.out.println("MapOutputServiceImpl.doGet");
+
+        String uuid = collection.identifier();
+
+        try {
+            Document request = ClientProtocolUtils.newOutCollectionDocument(
+                uuid, "floodmap", "floodmap");
+
+            HttpClient client = new HttpClientImpl(serverUrl);
+            InputStream    is = client.collectionOut(request, uuid, "floodmap");
+
+            Document response = XMLUtils.parseDocument(is);
+
+            // TODO parse response document and return a MapConfig object
+        }
+        catch (ConnectionException e) {
+            e.printStackTrace();
+            System.err.println(e.getMessage());
+        }
+        catch (IOException ioe) {
+            ioe.printStackTrace();
+            System.err.println(ioe.getMessage());
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/webapp/WEB-INF/web.xml	Mon Oct 24 13:35:30 2011 +0000
+++ b/flys-client/src/main/webapp/WEB-INF/web.xml	Tue Oct 25 10:29:37 2011 +0000
@@ -173,6 +173,16 @@
   </servlet>
 
   <servlet-mapping>
+    <servlet-name>MapOutputService</servlet-name>
+    <url-pattern>/flys/map</url-pattern>
+  </servlet-mapping>
+
+  <servlet>
+    <servlet-name>MapOutputService</servlet-name>
+    <servlet-class>de.intevation.flys.client.server.MapOutputServiceImpl</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
     <servlet-name>ChartOutputService</servlet-name>
     <url-pattern>/flys/chart</url-pattern>
   </servlet-mapping>

http://dive4elements.wald.intevation.org