# HG changeset patch # User Tim Englich # Date 1254130562 0 # Node ID 0f4362d75e9e7a4fab3ebf9f39f4126c9284c556 # Parent ad739da2802bacbe1160026b81b1c1c4bb33c919 Adding StatisticsOutput to the GUI gnv/trunk@142 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r ad739da2802b -r 0f4362d75e9e gnv/Changelog --- 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 + + * 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 * src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp Edited: diff -r ad739da2802b -r 0f4362d75e9e gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java --- 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 statistics = adc.calculateStatistics(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); + sm.setStatistics(statistics); + ArtifactDescription artifactDescription = adc.getCurrentStepDescription(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); Node currentUI = artifactDescription.getCurrentUI(); diff -r ad739da2802b -r 0f4362d75e9e gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java --- 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 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 getStatistics() { + return this.statistics; + } + + /** + * @see de.intevation.gnv.action.sessionmodel.SessionModel#setStatistics(java.util.Collection) + */ + public void setStatistics(Collection statistics) { + this.statistics = statistics; + } } diff -r ad739da2802b -r 0f4362d75e9e gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java --- 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 statistics); + + Collection getStatistics(); } diff -r ad739da2802b -r 0f4362d75e9e gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java --- 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) throws ArtifactDatabaseClientException; + + /** + * @param artifactFactory + * @param currentArtifact + * @return + * @throws ArtifactDatabaseClientException + */ + public Collection calculateStatistics(ArtifactObject artifactFactory, ArtifactObject currentArtifact)throws ArtifactDatabaseClientException; } diff -r ad739da2802b -r 0f4362d75e9e gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java --- 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 calculateStatistics( + ArtifactObject artifactFactory, ArtifactObject currentArtifact) throws ArtifactDatabaseClientException{ + log.debug("DefaultArtifactDatabaseClient.calculateStatistics") ; + Collection 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(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; + } } diff -r ad739da2802b -r 0f4362d75e9e gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactStatisticValue.java --- /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 + * + */ +public interface ArtifactStatisticValue { + + + String getKey(); + String getValue(); + +} diff -r ad739da2802b -r 0f4362d75e9e gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultArtifactStatisticValue.java --- /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 + * + */ +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; + } + +} diff -r ad739da2802b -r 0f4362d75e9e gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp --- 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" %> -
+<%@ 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 statistics = sm.getStatistics(); +%> + + +<%@page import="java.util.Iterator"%>
+ <%if (statistics != null){%> + + + + + + <% Iterator it = statistics.iterator(); + while (it.hasNext()){ + ArtifactStatisticValue asv = it.next(); + %> + + + + + <%}%> +
<%=asv.getValue()%>
+ <%} %>
\ No newline at end of file diff -r ad739da2802b -r 0f4362d75e9e gnv/src/main/webapp/styles/default.css --- 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{