# HG changeset patch # User Ingo Weinzierl # Date 1268660765 0 # Node ID ccd47d9887ec4a296cfdb6e57bb72b49d2b1ea25 # Parent c4f051adc6e780b447ae6728cbf75e1c5a56eda5 Added an options panel for wms customization (issue198). gnv/trunk@775 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c4f051adc6e7 -r ccd47d9887ec gnv/ChangeLog --- a/gnv/ChangeLog Fri Mar 12 11:56:07 2010 +0000 +++ b/gnv/ChangeLog Mon Mar 15 13:46:05 2010 +0000 @@ -1,9 +1,36 @@ +2010-03-15 Ingo Weinzierl + + Issue198 + + * src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java, + src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java: + Added the method signature for publishing wms layers. 'publishWMS' + requires a collection of InputParameters which are used to create the + request xml document. These input parameters can be used to adjust some + wms settings. At the moment, the only parameter which written to the + request xml document is the title for a wms layer. + + * src/main/java/de/intevation/gnv/action/WMSAction.java: Search for user + input and append given input values to request xml document. Put the layer + title into request object to be accessible in jsp files. + + * src/main/webapp/WEB-INF/jsp/index.jsp: Render wms option panel if wms is + requested. + + * src/main/webapp/WEB-INF/jsp/includes/display_wms_options_inc.jsp: New. + Option panel for wms customization. At the moment, the user has the + possibility to adjust wms layers' title. + + * src/main/resources/applicationMessages.properties, + src/main/resources/applicationMessages_en.properties: Added some labels + for wms options. + 2010-03-12 Tim Englich * src/test/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClientTestCase.java (testArtifactDatabaseClient): Fixed Compilation-Error because of InterfaceChanges of the ArtifactDatabaseClient-Interface. - + 2010-03-12 Tim Englich * src/main/resources/applicationMessages*.properties: diff -r c4f051adc6e7 -r ccd47d9887ec gnv/src/main/java/de/intevation/gnv/action/WMSAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/WMSAction.java Fri Mar 12 11:56:07 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/WMSAction.java Mon Mar 15 13:46:05 2010 +0000 @@ -1,5 +1,9 @@ package de.intevation.gnv.action; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -10,11 +14,16 @@ 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.util.XMLUtils; /** @@ -28,6 +37,9 @@ public static final String XPATH_MAPSERVER_MAPFILE = "/art:meta/art:mapserver/art:map/text()"; + public static final String XPATH_LAYER_TITLE = + "/art:meta/art:layer/art:title/text()"; + /** * the logger, used to log exceptions and additonaly information */ @@ -48,6 +60,39 @@ try { SessionModel sm = SessionModelFactory.getInstance().getSessionModel( request); + + OutputMode outputMode = sm.getOutputMode("wms"); + Collection ips = null; + if (outputMode != null) { + Collection inputParameter = + outputMode.getOutputParameters(); + + if (inputParameter != null) { + ips = new ArrayList(inputParameter.size()); + Iterator it = inputParameter.iterator(); + DiagrammOptions diagrammOptions = new DiagrammOptions(); + + int params = 0; + while (it.hasNext()) { + String name = it.next().getName(); + String[] values = request.getParameterValues(name); + String value = request.getParameter(name); + InputParameter ip = new DefaultInputParameter(name, + values); + ips.add(ip); + + if (value != null) { + ++params; + diagrammOptions.setValue(name, value); + } + } + + if (params > 0) { + sm.setDiagrammOptions(diagrammOptions); + } + } + } + ArtifactObject artifact = sm.getCurrentArtifact(); ArtifactDatabaseClientFactory factory = @@ -57,15 +102,25 @@ ArtifactObject artifactfactory = sm.getSelectedArtifactFactory(); // do wms publishing - Document meta = adc.publishWMS(artifactfactory, artifact); + Document meta = adc.publishWMS(artifactfactory,artifact,ips); String mapserverPath = XMLUtils.getStringXPath( meta, XPATH_MAPSERVER_PATH); String mapfilePath = XMLUtils.getStringXPath( meta, XPATH_MAPSERVER_MAPFILE); + String layer = XMLUtils.getStringXPath( + meta, XPATH_LAYER_TITLE); + layer = layer != null ? layer : artifact.getId(); + if (logger.isDebugEnabled()) { + logger.debug("Mapserver path: " + mapserverPath); + logger.debug("Mapfile path: " + mapfilePath); + logger.debug("Layer title: " + layer); + } + + request.setAttribute("wms", true); request.setAttribute("mapserver", mapserverPath); request.setAttribute("mapfile", mapfilePath); - request.setAttribute("layer", artifact.getId()); + request.setAttribute("layer", layer); return super.execute(mapping, form, request, response); } diff -r c4f051adc6e7 -r ccd47d9887ec gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java --- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java Fri Mar 12 11:56:07 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java Mon Mar 15 13:46:05 2010 +0000 @@ -113,7 +113,11 @@ * @param artifact * @return URL to wms service as string */ - public Document publishWMS(ArtifactObject factory, ArtifactObject artifact); + public Document publishWMS( + ArtifactObject factory, + ArtifactObject artifact, + Collection inputParameter + ); /** diff -r c4f051adc6e7 -r ccd47d9887ec gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java --- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Fri Mar 12 11:56:07 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Mon Mar 15 13:46:05 2010 +0000 @@ -792,29 +792,29 @@ private void check4ExceptionReport(Document document) throws ArtifactDatabaseClientException, ArtifactDatabaseInputException { - log.debug("REPORT: " + XMLUtils.writeDocument2String(document)); - String message = new XMLUtils().getStringXPath(document, EXCEPTION_GENERAL); if (message != null) { - log.error("FOUND GENERAL EXCEPTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); throw new ArtifactDatabaseClientException(message); } String input = XMLUtils.getStringXPath(document, EXCEPTION_USER_INPUT); if (input != null) { - log.error("FOUND INPUT EXCEPTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); throw new ArtifactDatabaseInputException(input); } } - public Document publishWMS(ArtifactObject factory, ArtifactObject artifact) { + public Document publishWMS( + ArtifactObject factory, + ArtifactObject artifact, + Collection inputParameter + ) { log.debug("Start wms publishing..."); String target = "wms"; String requestURL = getArtifactUrl(factory, artifact) + "/" + target; Document request = createOutRequestBody( - artifact, target, "", "text/xml", null); + artifact, target, "", "text/xml", inputParameter); try { InputStream input = doPostRequest(requestURL, request); Document result = XMLUtils.readDocument(input); diff -r c4f051adc6e7 -r ccd47d9887ec gnv/src/main/resources/applicationMessages.properties --- a/gnv/src/main/resources/applicationMessages.properties Fri Mar 12 11:56:07 2010 +0000 +++ b/gnv/src/main/resources/applicationMessages.properties Mon Mar 15 13:46:05 2010 +0000 @@ -70,6 +70,7 @@ # wms gnviewer.wms.server.path=URL des WMS gnviewer.wms.server.layer=Name des Layers +gnviewer.wms.options.header.title=WMS Optionen # attachedOutputOptions gnviewer.output.options.diagramm.alt=Diagramm @@ -88,6 +89,7 @@ height=H\u00f6he width=Breite points=Zeichne Datenpunkte +title=Titel # Fehlermeldungen: diff -r c4f051adc6e7 -r ccd47d9887ec gnv/src/main/resources/applicationMessages_en.properties --- a/gnv/src/main/resources/applicationMessages_en.properties Fri Mar 12 11:56:07 2010 +0000 +++ b/gnv/src/main/resources/applicationMessages_en.properties Mon Mar 15 13:46:05 2010 +0000 @@ -70,6 +70,7 @@ # wms gnviewer.wms.server.path=WMS URL gnviewer.wms.server.layer=Layername +gnviewer.wms.options.header.title=WMS Optionen # attachedOutputOptions gnviewer.output.options.diagramm.alt=Diagram @@ -88,6 +89,7 @@ height=Height width=Width points=Draw data points +title=Title java.io.ioexception..connection.refused = The Connection to the ArtifactDatabase is interrupted. Please try again later. java.io.ioexception..unable.to.parse.the.response.http.version..end.of.stream.reached.too.early= The Connection to the ArtifactDatabase was interrupted unexpected. diff -r c4f051adc6e7 -r ccd47d9887ec gnv/src/main/webapp/WEB-INF/jsp/includes/display_wms_options_inc.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_wms_options_inc.jsp Mon Mar 15 13:46:05 2010 +0000 @@ -0,0 +1,66 @@ +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean-el" prefix="bean-el" %> +<%@page import="de.intevation.gnv.action.CommunicationKeys"%> +<%@page import="de.intevation.gnv.action.sessionmodel.DiagrammOptions"%> +<%@page import="de.intevation.gnv.action.sessionmodel.SessionModel"%> +<%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%> +<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputMode"%> +<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%> +<%@page import="java.util.Collection"%> +<%@page import="java.util.Iterator"%> +<%@page import="java.net.URLEncoder"%> +<% + String exceptionMsg = (String) request.getAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE); + String exceptionValue= (String) request.getAttribute(CommunicationKeys.REQUEST_EXCEPTION_VALUE); + String layer = (String) request.getAttribute("layer"); + String target = "wms"; + SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); + OutputMode om = sm.getOutputMode(target); + DiagrammOptions opts = sm.getDiagrammOptions(); + String uuid = sm.getCurrentArtifact().getId(); +%> + +
+
+ + + + + <% if (exceptionMsg != null) {%> +
+ '<%=exceptionValue%>' +
+ <%}%> + +
"> + + <% Collection params = om.getOutputParameters(); + if (om != null && params != null && !params.isEmpty()) { + Iterator iter = params.iterator(); + while (iter.hasNext()) { + OutputParameter param = iter.next(); %> + + + + + + <%} + }%> + + + +
+ <%if (param.getType().equalsIgnoreCase("boolean")) { + boolean checked = (opts != null) ? "true".equalsIgnoreCase(opts.getValue(param.getName())) : param.getValue().equalsIgnoreCase("true"); + %> + /> + <%} + else {%> + + <%}%> +
+ "/> +
+
+
+
diff -r c4f051adc6e7 -r ccd47d9887ec gnv/src/main/webapp/WEB-INF/jsp/index.jsp --- a/gnv/src/main/webapp/WEB-INF/jsp/index.jsp Fri Mar 12 11:56:07 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/index.jsp Mon Mar 15 13:46:05 2010 +0000 @@ -79,3 +79,8 @@ <%if (histogram != null) {%> <%}%> + + <%-- render wms options --%> + <%if (wms != null) {%> + + <%}%>