diff gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp @ 30:07e9c137a2f1

Added dynamic Outputparameter Support and Outputparameter-manipulation gnv/trunk@134 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 25 Sep 2009 14:24:08 +0000
parents bba8fd97e549
children ad739da2802b
line wrap: on
line diff
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp	Fri Sep 25 07:28:49 2009 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp	Fri Sep 25 14:24:08 2009 +0000
@@ -1,28 +1,49 @@
 <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
 <%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%>
+<%@page import="de.intevation.gnv.action.sessionmodel.SessionModel"%>
+<%@page import="de.intevation.gnv.action.sessionmodel.DiagrammOptions"%>
+<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%>
+<%@page import="java.util.Collection"%>
+<%@page import="java.util.Iterator"%>
 <%Object diagramm = request.getAttribute("diagramm");
+SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
 if (diagramm != null){
-    
     String target = "chart"; 
     String targetCSV = "csv";
-    boolean supportCSV = true; // TODO get from SessionModel
-    String mimeType = "image/png";// TODO: get from SessionModel SessionModelFactory.getInstance().getSessionModel(request).
-    String mimeTypeCSV = "text/plain";// TODO: get from SessionModel SessionModelFactory.getInstance().getSessionModel(request).
+    boolean supportChart = sm.getOutputMode(target) != null;
+    boolean supportCSV = sm.getOutputMode(targetCSV) != null;
+    String mimeType = null;
+    String parameterString = "";
+    if (supportChart){
+       mimeType = sm.getOutputMode(target).getMimeType();
+       DiagrammOptions diagrammOptions = sm.getDiagrammOptions();
+       Collection<OutputParameter> op = sm.getOutputMode(target).getOutputParameters();
+       if (op != null){
+           Iterator<OutputParameter> it = op.iterator();
+           while (it.hasNext()){
+               OutputParameter parameter = it.next(); 
+               parameterString = parameterString +"&"+parameter.getName()+"="+(diagrammOptions != null ? diagrammOptions.getValue(parameter.getName()): parameter.getValue());
+           }
+       }
+    }
+    String mimeTypeCSV = null;
+    if (supportCSV){
+        mimeTypeCSV = sm.getOutputMode(targetCSV).getMimeType();
+    }
 %>
-    
-    <div id="diagram">
-        <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&target="+target+"&uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.diagramm.alt"/>'/>
+<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"/>'/>
         <br/>
         <div id="export">
-            <a href="<%=response.encodeURL("export.do?mimetype="+mimeType+"&target="+target+"&uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>">
+            <a href="<%=response.encodeURL("export.do?mimetype="+mimeType+"&target="+target+parameterString+"&uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>">
                 <img src="images/diagram_export.png" border="0"/>
             </a>
             <%if (supportCSV) { %>
-            <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeCSV+"&target="+targetCSV+"&uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.title"/>">
+            <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeCSV+"&target="+targetCSV+"+uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.title"/>">
                 <img src="images/data_export.png" border="0"/>
             </a>
             <%}%>
         </div>
+        <jsp:include page="/WEB-INF/jsp/includes/display_diagramm_adons_inc.jsp"></jsp:include>
     </div>
-    <jsp:include page="/WEB-INF/jsp/includes/display_diagramm_adons_inc.jsp"></jsp:include>
 <%}%>
\ No newline at end of file

http://dive4elements.wald.intevation.org