# HG changeset patch # User Ingo Weinzierl # Date 1319538577 0 # Node ID 4c65c5b60a86bf7136816a1780aaa339b994552b # Parent 9981ba2ee13ab22b4171ceaeaabdb0d1af65bba8 First step of refactoring the map creation - implemented a MapOutputService. flys-client/trunk@3066 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 9981ba2ee13a -r 4c65c5b60a86 flys-client/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/client/client/ui/Toolbar.java: New. An diff -r 9981ba2ee13a -r 4c65c5b60a86 flys-client/src/main/java/de/intevation/flys/client/client/services/MapOutputService.java --- /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 Ingo Weinzierl + */ +@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 : diff -r 9981ba2ee13a -r 4c65c5b60a86 flys-client/src/main/java/de/intevation/flys/client/client/services/MapOutputServiceAsync.java --- /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 Ingo Weinzierl + */ +public interface MapOutputServiceAsync { + + public void doOut( + Collection collection, + String serverUrl, + AsyncCallback callback); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 9981ba2ee13a -r 4c65c5b60a86 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java --- 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() { + public void onFailure(Throwable caught) { + GWT.log("MAP ERROR: " + caught.getMessage()); + } + + public void onSuccess(Void v) { + GWT.log("MAP SUCCESS!"); + } + } + ); + initLayout(); initLayers(); initBarriers(); diff -r 9981ba2ee13a -r 4c65c5b60a86 flys-client/src/main/java/de/intevation/flys/client/server/MapOutputServiceImpl.java --- /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 : diff -r 9981ba2ee13a -r 4c65c5b60a86 flys-client/src/main/webapp/WEB-INF/web.xml --- 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 @@ + MapOutputService + /flys/map + + + + MapOutputService + de.intevation.flys.client.server.MapOutputServiceImpl + + + ChartOutputService /flys/chart