Mercurial > dive4elements > gnv-client
changeset 976:d1ed5c51c0de
Checkin of changes which are necessary for the checkin of Revision 1139.
gnv/trunk@1146 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 01 Jun 2010 17:46:03 +0000 |
parents | 5779220ebb80 |
children | 2444da07e487 |
files | gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/WMSAction.java gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java |
diffstat | 4 files changed, 87 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv/ChangeLog Tue Jun 01 17:40:54 2010 +0000 +++ b/gnv/ChangeLog Tue Jun 01 17:46:03 2010 +0000 @@ -1,3 +1,15 @@ +2010-06-01 Tim Englich <tim.englich@intevation.de> + + + Checkin of changes which are necessary for the checkin of Revision 1139. + + * src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java (selectArtifactFactory), + * src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java (selectedArtifactFactory): + Added functions for getting and setting a Mapservice to the SessionModel. + + * src/main/java/de/intevation/gnv/action/WMSAction.java : + Integrated the possibility to read all Layes from Metafile. + 2010-06-01 Tim Englich <tim.englich@intevation.de> Providing functionality to read an WMS-Capabilities-Documnet and list all
--- a/gnv/src/main/java/de/intevation/gnv/action/WMSAction.java Tue Jun 01 17:40:54 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/WMSAction.java Tue Jun 01 17:46:03 2010 +0000 @@ -1,22 +1,6 @@ package de.intevation.gnv.action; -import de.intevation.gnv.action.sessionmodel.DiagrammOptions; -import de.intevation.gnv.action.sessionmodel.SessionModel; -import de.intevation.gnv.action.sessionmodel.SessionModelFactory; - -import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient; -import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; - -import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; -import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter; -import de.intevation.gnv.artifactdatabase.objects.InputParameter; -import de.intevation.gnv.artifactdatabase.objects.OutputMode; -import de.intevation.gnv.artifactdatabase.objects.OutputParameter; - -import de.intevation.gnv.util.XMLUtils; - import java.text.DateFormat; - import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -26,12 +10,28 @@ import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; - import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; -import org.w3c.dom.Document; +import de.intevation.gnv.action.sessionmodel.DiagrammOptions; +import de.intevation.gnv.action.sessionmodel.SessionModel; +import de.intevation.gnv.action.sessionmodel.SessionModelFactory; +import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient; +import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; +import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; +import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter; +import de.intevation.gnv.artifactdatabase.objects.InputParameter; +import de.intevation.gnv.artifactdatabase.objects.OutputMode; +import de.intevation.gnv.artifactdatabase.objects.OutputParameter; +import de.intevation.gnv.artifactdatabase.objects.map.DefaultLayer; +import de.intevation.gnv.artifactdatabase.objects.map.DefaultMapService; +import de.intevation.gnv.artifactdatabase.objects.map.Layer; +import de.intevation.gnv.artifactdatabase.objects.map.MapService; +import de.intevation.gnv.util.XMLUtils; /** * This controller is used to publish the results of the current artifact as @@ -50,11 +50,14 @@ public static final String XPATH_MAPSERVER_MAPFILE = "/art:meta/art:mapserver/art:map/text()"; + public static final String XPATH_LAYERNODESET = + "/art:meta/art:layer"; + public static final String XPATH_LAYER_TITLE = - "/art:meta/art:layer/art:title/text()"; + "art:title/text()"; public static final String XPATH_LAYER_NAME = - "/art:meta/art:layer/art:name/text()"; + "art:name/text()"; public static final String XPATH_TTL = "/art:meta/art:mapserver/art:ttl/text()"; @@ -122,16 +125,14 @@ // do wms publishing Document meta = adc.publishWMS(artifactfactory,artifact,ips); + + // read the Server-information String mapserverPath = XMLUtils.getStringXPath( meta, XPATH_MAPSERVER_PATH); String mapfilePath = XMLUtils.getStringXPath( meta, XPATH_MAPSERVER_MAPFILE); - String layer = XMLUtils.getStringXPath( - meta, XPATH_LAYER_NAME); String tmpTTL = XMLUtils.getStringXPath( - meta, XPATH_TTL); - layer = layer != null ? layer : artifact.getId(); - + meta, XPATH_TTL); String ttl = null; if (tmpTTL != null) { DateFormat df = DateFormat.getDateTimeInstance( @@ -154,19 +155,40 @@ if (logger.isDebugEnabled()) { logger.debug("Mapserver path: " + mapserverPath); logger.debug("Mapfile path: " + mapfilePath); - logger.debug("Layer: " + layer); logger.debug("Layer ttl: " + ttl); } + // read the layer information + + NodeList layerNodes = XMLUtils.getNodeSetXPath(meta, + XPATH_LAYERNODESET); + Collection<Layer> layers = null; + if (layerNodes != null && layerNodes.getLength() > 0){ + layers = new ArrayList<Layer>(layerNodes.getLength()); + for (int i = 0 ; i < layerNodes.getLength(); i++){ + Node tmpLayerNode = layerNodes.item(i); + String layerName = XMLUtils.getStringXPath( + tmpLayerNode, XPATH_LAYER_NAME); + String layerTitle = XMLUtils.getStringXPath( + tmpLayerNode, XPATH_LAYER_TITLE); + // TODO: write layerTitle to title and not to id + Layer currentLayer = new DefaultLayer(layerTitle, layerName, + false, null); + layers.add(currentLayer); + } + } + - request.setAttribute("wms", true); - request.setAttribute("mapserver", mapserverPath); - request.setAttribute("mapfile", mapfilePath); - request.setAttribute("layer", layer); - request.setAttribute("ttl", ttl); + + + // TODO PUT MAPFILEPATH AND TTL to MapServiceObject + if (mapserverPath != null && - mapfilePath != null && - layer != null){ + mapfilePath != null) { request.setAttribute("wms_published", Boolean.TRUE); + + MapService mapService = new DefaultMapService("0815", layers, + "UMN", mapserverPath); + sm.setLocalMapService(mapService); return super.execute(mapping, form, request, response); }else{ return super.execute(mapping, form, request, response);
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Tue Jun 01 17:40:54 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Tue Jun 01 17:46:03 2010 +0000 @@ -10,6 +10,7 @@ import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet; import de.intevation.gnv.artifactdatabase.objects.OutputMode; +import de.intevation.gnv.artifactdatabase.objects.map.MapService; /** * The default implementation of <code>SessionModel</code> which stores the @@ -20,6 +21,8 @@ */ public class DefaultSessionModel implements SessionModel { + + /** * the logger, used to log exceptions and additonaly information */ @@ -61,6 +64,10 @@ private Locale currentLocale; /** + * The Mapservice containing all Layers that should be displayed. + */ + private MapService localMapService = null; + /** * Constructor */ public DefaultSessionModel() { @@ -178,5 +185,13 @@ public void setCurrentLocale(Locale currentLocale) { this.currentLocale = currentLocale; } + + public MapService getLocalMapService() { + return this.localMapService; + } + + public void setLocalMapService(MapService mapService) { + this.localMapService = mapService; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Tue Jun 01 17:40:54 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Tue Jun 01 17:46:03 2010 +0000 @@ -8,6 +8,7 @@ import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet; import de.intevation.gnv.artifactdatabase.objects.OutputMode; +import de.intevation.gnv.artifactdatabase.objects.map.MapService; /** * This interface describe basic methods to store artifacts and diagram options. @@ -124,5 +125,9 @@ * @return the locale that is currently used. */ Locale getCurrentLocale(); + + void setLocalMapService(MapService mapService); + + MapService getLocalMapService(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :