Mercurial > dive4elements > gnv-client
changeset 583:2f3d885fed09
Adjusted http requests and appended a new parameter export mode to 'out'-xml document to choose between svg, pdf or image exports.
gnv/trunk@725 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 02 Mar 2010 14:55:29 +0000 |
parents | b8ea9383d285 |
children | b31e81f35b64 |
files | gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp |
diffstat | 10 files changed, 89 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv/ChangeLog Tue Mar 02 10:53:30 2010 +0000 +++ b/gnv/ChangeLog Tue Mar 02 14:55:29 2010 +0000 @@ -1,3 +1,22 @@ +2010-03-02 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + * src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java, + src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java: + Added export mode to 'out'-xml document. + + * src/main/java/de/intevation/gnv/action/DoOutputAction.java, + src/main/java/de/intevation/gnv/action/DoExportAction.java: Call + 'doOutput' for triggering an output like chart, histogram, csv or odv with + a new parameter export mode which contains the export format (img, pdf, + svg). + + * src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp, + src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp, + src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp, + src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp, + src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp: Added export + mode to HTTP-Get requests. + 2010-03-02 Ingo Weinzierl <ingo.weinzierl@intevation.de> * src/main/webapp/WEB-INF/config/templates/describe-ui-static.xsl:
--- a/gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java Tue Mar 02 10:53:30 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java Tue Mar 02 14:55:29 2010 +0000 @@ -107,9 +107,14 @@ this.setHeaders(mode, mimeType, response, request); OutputStream outputStream = response.getOutputStream(); - adc.doOutput(sm.getSelectedArtifactFactory(), sm - .getCurrentArtifact(), outputStream, mode, mimeType, - ips); + adc.doOutput( + sm.getSelectedArtifactFactory(), + sm.getCurrentArtifact(), + outputStream, + target, + mode, + mimeType, + ips); outputStream.flush(); outputStream.close(); @@ -137,9 +142,14 @@ this.setHeaders(target, mimeType, response, request); OutputStream outputStream = response.getOutputStream(); - adc.doOutput(sm.getSelectedArtifactFactory(), sm - .getCurrentArtifact(), outputStream, target, mimeType, - ips); + adc.doOutput( + sm.getSelectedArtifactFactory(), + sm.getCurrentArtifact(), + outputStream, + target, + mode, + mimeType, + ips); outputStream.flush(); outputStream.close();
--- a/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java Tue Mar 02 10:53:30 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java Tue Mar 02 14:55:29 2010 +0000 @@ -59,11 +59,13 @@ HttpServletResponse response) throws Exception { log.debug("DoOutputAction.execute"); try { - String target = request.getParameter("target"); + String target = request.getParameter("target"); String mimeType = request.getParameter("mimetype"); + String mode = request.getParameter("mode"); log.debug("Target: " + target); log.debug("MimeType: " + mimeType); + log.debug("ExportMode: " + mode); // TODO Check if is propper; @@ -99,9 +101,14 @@ this.setHeaders(target, mimeType, response, request); OutputStream outputStream = response.getOutputStream(); - adc.doOutput(sm.getSelectedArtifactFactory(), sm - .getCurrentArtifact(), outputStream, target, mimeType, - ips); + adc.doOutput( + sm.getSelectedArtifactFactory(), + sm.getCurrentArtifact(), + outputStream, + target, + mode, + mimeType, + ips); outputStream.flush(); outputStream.close();
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java Tue Mar 02 10:53:30 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java Tue Mar 02 14:55:29 2010 +0000 @@ -98,11 +98,15 @@ * @param mimeType * @throws ArtifactDatabaseClientException */ - public void doOutput(ArtifactObject artifactFactory, - ArtifactObject currentArtifact, OutputStream stream, - String targetName, String mimeType, - Collection<InputParameter> inputParameter) - throws ArtifactDatabaseClientException; + public void doOutput( + ArtifactObject artifactFactory, + ArtifactObject currentArtifact, + OutputStream stream, + String targetName, + String exportMode, + String mimeType, + Collection<InputParameter> inputParameter) + throws ArtifactDatabaseClientException; /** * @param factory
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Tue Mar 02 10:53:30 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Tue Mar 02 14:55:29 2010 +0000 @@ -678,14 +678,23 @@ * java.io.OutputStream, java.lang.String, java.lang.String, * java.util.Collection) */ - public void doOutput(ArtifactObject artifactFactory, - ArtifactObject currentArtifact, OutputStream stream, - String targetName, String mimeType, - Collection<InputParameter> inputParameter) - throws ArtifactDatabaseClientException { + public void doOutput( + ArtifactObject artifactFactory, + ArtifactObject currentArtifact, + OutputStream stream, + String targetName, + String exportMode, + String mimeType, + Collection<InputParameter> inputParameter) + throws ArtifactDatabaseClientException + { try { - Document requestBody = this.createOutRequestBody(currentArtifact, - targetName, mimeType, inputParameter); + Document requestBody = this.createOutRequestBody( + currentArtifact, + targetName, + exportMode, + mimeType, + inputParameter); String requestUrl = this.getArtifactUrl(artifactFactory, currentArtifact) @@ -704,10 +713,12 @@ } private Document createOutRequestBody( - ArtifactObject currentArtifact, - String target, - String mimeType, - Collection<InputParameter> inputParameter) { + ArtifactObject currentArtifact, + String target, + String exportMode, + String mimeType, + Collection<InputParameter> inputParameter) + { Document document = new XMLUtils().newDocument(); Node rootNode = this.createRootNode(document); @@ -727,6 +738,10 @@ outNode.setAttribute("name", target); rootNode.appendChild(outNode); + Element exportNode = this.createArtifactElement(document, "export"); + exportNode.setAttribute("name", exportMode); + outNode.appendChild(exportNode); + Element mimeTypeNode = this.createArtifactElement(document, "mime-type"); mimeTypeNode.setAttribute("value", mimeType); outNode.appendChild(mimeTypeNode); @@ -779,7 +794,7 @@ String target = "wms"; String requestURL = getArtifactUrl(factory, artifact) + "/" + target; Document request = createOutRequestBody( - artifact, target, "text/xml", null); + artifact, target, "", "text/xml", null); try { InputStream input = doPostRequest(requestURL, request); Document result = XMLUtils.readDocument(input); @@ -806,7 +821,7 @@ String requestUrl = this.getArtifactUrl(artifactFactory, currentArtifact) + "/" + targetName; Document requestBody = this.createOutRequestBody(currentArtifact, - targetName, "text/xml", null); + targetName, "", "text/xml", null); XMLUtils xmlUtils = new XMLUtils(); InputStream is = this.doPostRequest(requestUrl, requestBody); Document resultDocument = xmlUtils.readDocument(is);
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp Tue Mar 02 10:53:30 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp Tue Mar 02 14:55:29 2010 +0000 @@ -34,6 +34,6 @@ <%-- diagramm is not null if the user clicked the 'draw' button --%> <jsp:include page="/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp"></jsp:include> <div id="diagram"> - <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&target="+target+parameterString+"&uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.diagramm.alt"/>'/> + <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&target="+target+"&mode=img"+parameterString+"&uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.diagramm.alt"/>'/> <br/> </div>
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp Tue Mar 02 10:53:30 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp Tue Mar 02 14:55:29 2010 +0000 @@ -30,7 +30,7 @@ if (op != null){ Iterator<OutputParameter> it = op.iterator(); while (it.hasNext()){ - OutputParameter parameter = it.next(); + OutputParameter parameter = it.next(); parameterString = parameterString +"&"+parameter.getName()+"="+(diagrammOptions != null ? diagrammOptions.getValue(parameter.getName()): parameter.getValue()); } } @@ -83,7 +83,7 @@ <input type="image" name="target" value="chart" src="images/arrow_refresh.png" alt="<bean:message key="gnviewer.draw.button"/>"/> <%}%> <%if (supportIMG != null) { %> - <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeIMG+"&target="+target+"&mode="+target+parameterString+"uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>"> + <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeIMG+"&target="+target+"&mode="+targetIMG+parameterString+"uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>"> <img src="images/diagram_export.png" border="0"/> </a> <%}%>
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp Tue Mar 02 10:53:30 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp Tue Mar 02 14:55:29 2010 +0000 @@ -72,7 +72,7 @@ <fieldset> <legend><bean:message key="gnviewer.export.fieldset.title"/></legend> <%if (supportChart) { %> - <a href="<%=response.encodeURL("chart.do?mimetype="+mimeType+"&target="+target+parameterString+"&uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>"> + <a href="<%=response.encodeURL("chart.do?mimetype="+mimeType+"&target="+target+"&mode=img"+parameterString+"&uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>"> <img src="images/chart_curve.png" border="0"/> </a> <%}%>
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp Tue Mar 02 10:53:30 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp Tue Mar 02 14:55:29 2010 +0000 @@ -29,5 +29,5 @@ <jsp:include page="/WEB-INF/jsp/includes/display_histogram_options_inc.jsp"></jsp:include> <div class="histogram"> - <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&target=histogram"+parameterString+"&uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.histogram.alt"/>'/> + <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&target="+target+"&mode=img"+parameterString+"&uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.histogram.alt"/>'/> </div>
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp Tue Mar 02 10:53:30 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp Tue Mar 02 14:55:29 2010 +0000 @@ -107,7 +107,7 @@ <input type="image" name="target" value="histogram" src="images/arrow_refresh.png" alt="<bean:message key="gnviewer.draw.button"/>"/> <%}%> <%if (supportIMG != null) { %> - <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeIMG+"&target="+target+"&mode="+target+parameterString+"uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>"> + <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeIMG+"&target="+target+"&mode="+targetIMG+parameterString+"uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>"> <img src="images/diagram_export.png" border="0"/> </a> <%}%>