changeset 410:9602f4bffc07

Added statistic to the actions if available. gnv/trunk@604 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 22 Jan 2010 13:58:30 +0000
parents df78178e1180
children 8e39c74f9fb6
files gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/ShowStatisticAction.java gnv/src/main/resources/applicationMessages.properties gnv/src/main/resources/applicationMessages_en.properties gnv/src/main/webapp/WEB-INF/config/struts-config.xml gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/index.jsp gnv/src/main/webapp/images/statistics.png gnv/src/main/webapp/styles/default.css
diffstat 11 files changed, 137 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/ChangeLog	Fri Jan 22 11:28:25 2010 +0000
+++ b/gnv/ChangeLog	Fri Jan 22 13:58:30 2010 +0000
@@ -1,3 +1,26 @@
+2010-01-22  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/java/de/intevation/gnv/action/ShowStatisticAction.java: This
+	  action 'calculates' the statistic and shows the result in the gui.
+	
+	* src/main/webapp/WEB-INF/config/struts-config.xml: Added controller and
+	  forwards.
+
+	* src/main/webapp/images/statistics.png: Statistic icon.
+
+	* src/main/webapp/WEB-INF/jsp/index.jsp,
+	  src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_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 symbol
+	  in action box to show the statistic.
+
+	* src/main/webapp/styles/default.css: Adjusted some parameter for a proper
+	  placement of the statistic box.
+
+	* src/main/resources/applicationMessages.properties,
+	  src/main/resources/applicationMessages_en.properties: Added label for
+	  statistic icon.
+
 2010-01-22  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/action/DescribeUIAction.java: New action.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/ShowStatisticAction.java	Fri Jan 22 13:58:30 2010 +0000
@@ -0,0 +1,62 @@
+package de.intevation.gnv.action;
+
+import java.util.Collection;
+
+import javax.servlet.http.HttpServletRequest;
+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 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.ArtifactStatisticsSet;
+
+/**
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ */
+public class ShowStatisticAction extends DescribeUIAction {
+
+    private static Logger logger = Logger.getLogger(ShowStatisticAction.class);
+
+
+    public ShowStatisticAction() {
+        super();
+    }
+
+
+    @Override
+    public ActionForward execute(
+        ActionMapping       mapping,
+        ActionForm          form,
+        HttpServletRequest  request,
+        HttpServletResponse response
+    ) throws Exception
+    {
+        logger.info("show statistic");
+        SessionModel sm = SessionModelFactory.getInstance().getSessionModel(
+            request);
+
+        ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory.getInstance()
+            .getArtifactDatabaseClient(getLocale(request));
+
+        try{
+            Collection<ArtifactStatisticsSet> statistics =
+                adc.calculateStatistics(sm.getSelectedArtifactFactory(),
+                sm.getCurrentArtifact());
+
+            sm.setStatistics(statistics);
+
+            request.setAttribute("statistic", true);
+        }
+        catch (Exception e) {
+            logger.error(e, e);
+        }
+
+        return super.execute(mapping, form, request, response);
+    }
+}
--- a/gnv/src/main/resources/applicationMessages.properties	Fri Jan 22 11:28:25 2010 +0000
+++ b/gnv/src/main/resources/applicationMessages.properties	Fri Jan 22 13:58:30 2010 +0000
@@ -52,6 +52,7 @@
 gnviewer.statistics.descriptive.variance=Varianz
 gnviewer.statistics.descriptive.intercept=Intercept
 gnviewer.statistics.descriptive.slope=Steigung
+gnviewer.statistic.button = Statistik
 
 # diagram options dialog
 gnviewer.diagram.options.header.title=Diagrammoptionen
--- a/gnv/src/main/resources/applicationMessages_en.properties	Fri Jan 22 11:28:25 2010 +0000
+++ b/gnv/src/main/resources/applicationMessages_en.properties	Fri Jan 22 13:58:30 2010 +0000
@@ -52,6 +52,7 @@
 gnviewer.statistics.descriptive.variance=Variance
 gnviewer.statistics.descriptive.intercept=Intercept
 gnviewer.statistics.descriptive.slope=Increase
+gnviewer.statistic.button = Statistic
 
 # diagram options dialog
 gnviewer.diagram.options.header.title=Diagram options
--- a/gnv/src/main/webapp/WEB-INF/config/struts-config.xml	Fri Jan 22 11:28:25 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/config/struts-config.xml	Fri Jan 22 13:58:30 2010 +0000
@@ -90,6 +90,20 @@
                 name="selectfis"
                 path="/gnv/selectFis.do"/>
         </action>
+        <action path="/statistic"
+                type="de.intevation.gnv.action.ShowStatisticAction"
+                scope="request"
+                validate="false">
+            <forward
+                name="back"
+                path="/gnv/back.do"/>
+            <forward
+                name="selectfis"
+                path="/gnv/selectFis.do"/>
+            <forward
+                name="success"
+                path="/WEB-INF/jsp/mainlayout.jsp"/>
+        </action>
        </action-mappings>
        
        <message-resources parameter="applicationMessages" null="false"/>
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp	Fri Jan 22 11:28:25 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp	Fri Jan 22 13:58:30 2010 +0000
@@ -26,7 +26,7 @@
            Iterator<OutputParameter> it = op.iterator();
            while (it.hasNext()){
                OutputParameter parameter = it.next(); 
-               parameterString = parameterString +"&"+parameter.getName()+"="+(diagrammOptions != null ? diagrammOptions.getValue(parameter.getName()): parameter.getValue());
+               parameterString = parameterString +"&amp;"+parameter.getName()+"="+(diagrammOptions != null ? diagrammOptions.getValue(parameter.getName()): parameter.getValue());
            }
        }
     }
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp	Fri Jan 22 11:28:25 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp	Fri Jan 22 13:58:30 2010 +0000
@@ -5,7 +5,8 @@
 <%@page import="java.util.Collection"%>
 <%@page import="de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticValue"%>
 <%@page import="java.util.Iterator"%>
-<%@page import="de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet"%><div id="statistics">
+<%@page import="de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet"%>
+<div class="statistics">
 <%
     SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
     Collection<ArtifactStatisticsSet> statistics = sm.getStatistics();
@@ -19,25 +20,24 @@
             while (it.hasNext()){
                 ArtifactStatisticsSet set = it.next(); 
         %>
-        <div id="statisticValues">
-             <h1><%=set.getName()%></h1>
-            <table id="statistics">
+            <h1><%=set.getName()%></h1>
+            <table class="statistics">
               <tr>
                   <th><bean:message key="gnviewer.statistics.table.header.param"/></th>
                   <th><bean:message key="gnviewer.statistics.table.header.value"/></th>
               </tr>
-              <% Iterator<ArtifactStatisticValue> sit = set.getStatisticValues().iterator();
-                 while (sit.hasNext()){
-                     ArtifactStatisticValue asv = sit.next(); 
+              <% 
+                Iterator<ArtifactStatisticValue> sit = set.getStatisticValues().iterator();
+                while (sit.hasNext()){
+                    ArtifactStatisticValue asv = sit.next(); 
               %>
-              <tr>
-                  <td><bean-el:message key="<%=asv.getKey()%>"/></td>
-                  <td><%=asv.getValue()%></td>
-              </tr>
-        <%}%>
+                  <tr>
+                      <td><bean-el:message key="<%=asv.getKey()%>"/></td>
+                      <td><%=asv.getValue()%></td>
+                  </tr>
+                <%}%>
             </table>
-        <%} %>
-        </div>
+            <%} %>
         <%}%>
     </fieldset>
-</div>
\ No newline at end of file
+</div>
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp	Fri Jan 22 11:28:25 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp	Fri Jan 22 13:58:30 2010 +0000
@@ -18,6 +18,7 @@
     String targetSVG = "svg";
     String targetZIP = "zip";
     String targetWMS = "wms";
+    String targetSta = "statistics";
 
     boolean supportChart = sm.getOutputMode(target)    != null;
     boolean supportCSV   = sm.getOutputMode(targetCSV) != null;
@@ -26,6 +27,7 @@
     boolean supportSVG   = sm.getOutputMode(targetSVG) != null;
     boolean supportZIP   = sm.getOutputMode(targetZIP) != null;
     boolean supportWMS   = sm.getOutputMode(targetWMS) != null;
+    boolean supportSta   = sm.getOutputMode(targetSta) != null;
 
     if (supportChart){
         mimeType = sm.getOutputMode(target).getMimeType();
@@ -111,6 +113,12 @@
                 <img src="images/disk.png" border="0"/>
             </a>
             <%}%>
+
+            <%if (supportSta) { %>
+                <a href="<%=response.encodeURL("statistic.do")%>" title="<bean:message key="gnviewer.statistic.button"/>">
+                    <img src="images/statistics.png" border="0"/>
+                </a>
+            <%}%>
         </fieldset>
     </div>
 <%}%>
--- a/gnv/src/main/webapp/WEB-INF/jsp/index.jsp	Fri Jan 22 11:28:25 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/index.jsp	Fri Jan 22 13:58:30 2010 +0000
@@ -6,6 +6,7 @@
 <%@page import="java.util.Iterator"%>
 <%  Object ui              = request.getAttribute("ui");
     Object staticui        = request.getAttribute("staticui");
+    Object statistic       = request.getAttribute("statistic");
     boolean furthertargets = true;
       
     Object furthertargetsObject = request.getAttribute("furthertargets");
@@ -41,3 +42,8 @@
 
     <%-- render export options if existing for this state --%>
     <jsp:include page="includes/display_export_inc.jsp"></jsp:include>
+
+    <%-- render statistic --%>
+    <%if (statistic != null) {%>
+        <jsp:include page="includes/display_diagramm_statistics_inc.jsp"></jsp:include>
+    <%}%>
Binary file gnv/src/main/webapp/images/statistics.png has changed
--- a/gnv/src/main/webapp/styles/default.css	Fri Jan 22 11:28:25 2010 +0000
+++ b/gnv/src/main/webapp/styles/default.css	Fri Jan 22 13:58:30 2010 +0000
@@ -255,10 +255,8 @@
 }
 
 div#diagram {
-/*POSITION DEFINIEREN*/
-/* border: 1px solid crimson;*/
     position: absolute;
-    top: 65px;
+    top: 33px;
     left: 350px;
 }
 
@@ -274,7 +272,6 @@
 }
 
 div#diagramoptions {
-/*POSITION DEFINIEREN*/
     position: relative;
     width:    325px;
 }
@@ -283,11 +280,11 @@
     width : 325px;
 }
 
-div#statistics {
-/*POSITION DEFINIEREN*/
-/*border: 1px solid Red;*/
-    position: relative;
-    width: 600px;
+div.statistics {
+    position: absolute;
+    top     : 33px;
+    left    : 350px;
+    width   : 325px;
 }
 
 div#statisticValues {

http://dive4elements.wald.intevation.org