changeset 32:0f4362d75e9e

Adding StatisticsOutput to the GUI gnv/trunk@142 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 28 Sep 2009 09:36:02 +0000
parents ad739da2802b
children 32ffff3f67aa
files gnv/Changelog gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.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/java/de/intevation/gnv/artifactdatabase/objects/ArtifactStatisticValue.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultArtifactStatisticValue.java gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp gnv/src/main/webapp/styles/default.css
diffstat 10 files changed, 169 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/Changelog	Fri Sep 25 15:11:26 2009 +0000
+++ b/gnv/Changelog	Mon Sep 28 09:36:02 2009 +0000
@@ -1,3 +1,21 @@
+2009-09-28  Tim Englich  <tim.englich@intevation.de>
+
+    * src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultArtifactStatisticValue.java Added, 
+      src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactStatisticValue.java Added: 
+      Added the Interface and the Defaultimplementation for the Representation of Statistic-Values.
+    * src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java (execute) Edited:
+      Added the Busionesslogic for Calculation the Statistics to the Action. 
+    * src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Edited, 
+      src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Edited:
+      Added the Methods for setting and getting the statistics to the SessionModel 
+    * src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java (calculateStatistics) Edited, 
+      src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java (calculateStatistics) Edited:
+      Added the Method for retrieving the Statistics from the current Artifcat. 
+    * src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp Edited:
+     Put the Values of the Statitics into the View. 
+    * src/main/webapp/styles/default.css Edited:
+    Changed CSS-for Statistics so that it would be displayed. 
+    
 2009-09-25  Tim Englich  <tim.englich@intevation.de>
 
     * src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp Edited:
--- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java	Fri Sep 25 15:11:26 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java	Mon Sep 28 09:36:02 2009 +0000
@@ -21,6 +21,7 @@
 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
+import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticValue;
 import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter;
 import de.intevation.gnv.artifactdatabase.objects.InputParameter;
 import de.intevation.gnv.util.XMLUtils;
@@ -94,6 +95,11 @@
                
             request.setAttribute("diagramm", true);
             
+            // statistic abholen und in das sessionmodell schreiben.
+            
+            Collection<ArtifactStatisticValue> statistics = adc.calculateStatistics(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact());
+            sm.setStatistics(statistics);
+            
             ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact());
             
             Node currentUI = artifactDescription.getCurrentUI();
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java	Fri Sep 25 15:11:26 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java	Mon Sep 28 09:36:02 2009 +0000
@@ -10,6 +10,7 @@
 
 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
+import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticValue;
 import de.intevation.gnv.artifactdatabase.objects.OutputMode;
 
 /**
@@ -36,6 +37,8 @@
     private ArtifactObject currentArtifact  =null;
     
     private DiagrammOptions diagrammOptions= null;
+    
+    private Collection<ArtifactStatisticValue> statistics= null;
    
 
     /**
@@ -146,9 +149,24 @@
      */
     public void resetModel() {
         log.debug("DefaultSessionModel.resetModel");
-        selectedArtifactFactory = null;
-        currentArtifact  =null;
-        diagrammOptions= null;
+        this.selectedArtifactFactory = null;
+        this.currentArtifact  =null;
+        this.diagrammOptions= null;
+        this.statistics = null;
        
     }
+
+    /**
+     * @see de.intevation.gnv.action.sessionmodel.SessionModel#getStatistics()
+     */
+    public Collection<ArtifactStatisticValue> getStatistics() {
+        return this.statistics;
+    }
+
+    /**
+     * @see de.intevation.gnv.action.sessionmodel.SessionModel#setStatistics(java.util.Collection)
+     */
+    public void setStatistics(Collection<ArtifactStatisticValue> statistics) {
+        this.statistics = statistics;
+    }
 }
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java	Fri Sep 25 15:11:26 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java	Mon Sep 28 09:36:02 2009 +0000
@@ -8,6 +8,7 @@
 
 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
+import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticValue;
 import de.intevation.gnv.artifactdatabase.objects.OutputMode;
 
 /**
@@ -37,5 +38,9 @@
     ArtifactDescription getArtifactDescription();
     
     void resetModel();
+    
+    void setStatistics(Collection<ArtifactStatisticValue> statistics);
+    
+    Collection<ArtifactStatisticValue> getStatistics();
 
 }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java	Fri Sep 25 15:11:26 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java	Mon Sep 28 09:36:02 2009 +0000
@@ -10,6 +10,7 @@
 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
+import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticValue;
 import de.intevation.gnv.artifactdatabase.objects.InputParameter;
 
 /**
@@ -77,4 +78,12 @@
      * @throws ArtifactDatabaseClientException
      */
     public void doOutput(ArtifactObject artifactFactory, ArtifactObject currentArtifact, OutputStream stream, String targetName, String mimeType, Collection<InputParameter> inputParameter) throws ArtifactDatabaseClientException;
+    
+    /**
+     * @param artifactFactory
+     * @param currentArtifact
+     * @return
+     * @throws ArtifactDatabaseClientException
+     */
+    public Collection<ArtifactStatisticValue> calculateStatistics(ArtifactObject artifactFactory, ArtifactObject currentArtifact)throws ArtifactDatabaseClientException;
 }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Fri Sep 25 15:11:26 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Mon Sep 28 09:36:02 2009 +0000
@@ -30,6 +30,8 @@
 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject;
+import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticValue;
+import de.intevation.gnv.artifactdatabase.objects.DefaultArtifactStatisticValue;
 import de.intevation.gnv.artifactdatabase.objects.DefaultOutputMode;
 import de.intevation.gnv.artifactdatabase.objects.DefaultOutputParameter;
 import de.intevation.gnv.artifactdatabase.objects.InputParameter;
@@ -535,4 +537,36 @@
         }
         
     }
+
+    public Collection<ArtifactStatisticValue> calculateStatistics(
+            ArtifactObject artifactFactory, ArtifactObject currentArtifact) throws ArtifactDatabaseClientException{
+        log.debug("DefaultArtifactDatabaseClient.calculateStatistics") ;
+        Collection<ArtifactStatisticValue> result;
+        try {
+            result = null;
+            String targetName = "statistics";
+            String requestUrl = this.getArtifactUrl(artifactFactory, currentArtifact)+"/"+targetName;
+            Document requestBody = this.createOutRequestBody(currentArtifact, targetName, "text/xml", null);
+            XMLUtils xmlUtils = new XMLUtils();
+            InputStream is  = this.doPostRequest(requestUrl, requestBody);
+            Document resultDocument = xmlUtils.readDocument(is);
+            if (resultDocument != null){
+                NodeList resultNodes = xmlUtils.getNodeSetXPath(resultDocument, "/statistic-values/statistic");
+                if (resultNodes != null){
+                    result = new ArrayList<ArtifactStatisticValue>(resultNodes.getLength());
+                    for (int i = 0; i < resultNodes.getLength(); i++){
+                        Node statisticNode = resultNodes.item(i);
+                        String name = xmlUtils.getStringXPath(statisticNode, "@name");
+                        String value = xmlUtils.getStringXPath(statisticNode, "@value");
+                        result.add(new DefaultArtifactStatisticValue(name, value));
+                    }
+                }
+            }
+        } catch (IOException e) {
+            log.error(e,e);
+            throw new ArtifactDatabaseClientException(e); 
+        }
+        
+        return result;
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactStatisticValue.java	Mon Sep 28 09:36:02 2009 +0000
@@ -0,0 +1,15 @@
+/**
+ *
+ */
+package de.intevation.gnv.artifactdatabase.objects;
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public interface ArtifactStatisticValue {
+    
+    
+    String getKey();
+    String getValue();
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultArtifactStatisticValue.java	Mon Sep 28 09:36:02 2009 +0000
@@ -0,0 +1,31 @@
+/**
+ *
+ */
+package de.intevation.gnv.artifactdatabase.objects;
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public class DefaultArtifactStatisticValue  implements ArtifactStatisticValue{
+
+    
+    private String key = null;
+    
+    private String value = null;
+    
+
+    public DefaultArtifactStatisticValue(String key, String value) {
+        super();
+        this.key = key;
+        this.value = value;
+    }
+
+    public String getKey() {
+        return this.key;
+    }
+
+    public String getValue() {
+        return this.value;
+    }
+
+}
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp	Fri Sep 25 15:11:26 2009 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp	Mon Sep 28 09:36:02 2009 +0000
@@ -1,10 +1,38 @@
 <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
-<div id="statistics">
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean-el" prefix="bean-el" %>
+<%@page import="de.intevation.gnv.action.sessionmodel.SessionModel"%>
+<%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%>
+<%@page import="java.util.Collection"%>
+<%@page import="de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticValue"%>
+<%
+    SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
+    Collection<ArtifactStatisticValue> statistics = sm.getStatistics();
+%>
+
+
+<%@page import="java.util.Iterator"%><div id="statistics">
   <fieldset>
       <legend class="expandableFieldset">
             <bean:message key="gnviewer.statistics.header.title"/>
         </legend>
         <div id="statisticValues">
+        <%if (statistics != null){%>
+            <table id="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> it = statistics.iterator();
+            while (it.hasNext()){
+                ArtifactStatisticValue asv = it.next(); 
+        %>
+              <tr>
+                  <td><bean-el:message key="<%=asv.getKey()%>"/></td>
+                  <td><%=asv.getValue()%></td>
+              </tr>
+        <%}%>
+            </table>
+        <%} %>
         </div>
     </fieldset>
 </div>
\ No newline at end of file
--- a/gnv/src/main/webapp/styles/default.css	Fri Sep 25 15:11:26 2009 +0000
+++ b/gnv/src/main/webapp/styles/default.css	Mon Sep 28 09:36:02 2009 +0000
@@ -246,7 +246,7 @@
 }
 
 div#statisticValues {
-    display: none;
+    width: 100%;
 }
 
 table#statistik_tab_0{

http://dive4elements.wald.intevation.org