Mercurial > dive4elements > gnv-client
changeset 164:5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
gnv/trunk@327 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Thu, 12 Nov 2009 10:22:30 +0000 |
parents | 1fe52a0cbd1f |
children | 183850730a90 |
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/ArtifactStatisticsSet.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultArtifactStatisticsSet.java gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp |
diffstat | 9 files changed, 143 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv/ChangeLog Wed Nov 11 16:24:02 2009 +0000 +++ b/gnv/ChangeLog Thu Nov 12 10:22:30 2009 +0000 @@ -1,3 +1,21 @@ +2009-11-12 Tim Englich <tim.englich@intevation.de> + + * src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp: + Implemented a better GUI-Structure for displaying the Statisticdata. + * src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultArtifactStatisticsSet.java, + src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactStatisticsSet.java: + Added new Beanstructur for a better Representation of the Statistics which + is generated by the ArtifactDatabase. + * src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java (calculateStatistics): + Changed the parsing algorithm of the Document which is generated + by the ArtifactDatabase. + * src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java (calculateStatistics): + Changed Return-Value to ArtifacStatisticsSet according to the new Structur of + Statistics that will be generated by the ArtifactDatabase. + * src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java (execute): + Changed the Resultvalue from ArtifactStatisticValue to ArtifacStatisticsSet according + to API-Changes of the ArtifactDatabaseClient + 2009-11-11 Tim Englich <tim.englich@intevation.de> * src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java (execute):
--- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Wed Nov 11 16:24:02 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Thu Nov 12 10:22:30 2009 +0000 @@ -22,6 +22,7 @@ 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.ArtifactStatisticsSet; import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter; import de.intevation.gnv.artifactdatabase.objects.InputParameter; import de.intevation.gnv.util.XMLUtils; @@ -140,7 +141,7 @@ adc.doFeed(sm.getSelectedArtifactFactory(), sm .getCurrentArtifact(), ips); - Collection<ArtifactStatisticValue> statistics = adc + Collection<ArtifactStatisticsSet> statistics = adc .calculateStatistics(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); sm.setStatistics(statistics);
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Wed Nov 11 16:24:02 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java Thu Nov 12 10:22:30 2009 +0000 @@ -11,6 +11,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.ArtifactStatisticsSet; import de.intevation.gnv.artifactdatabase.objects.OutputMode; /** @@ -37,7 +38,7 @@ private DiagrammOptions diagrammOptions = null; - private Collection<ArtifactStatisticValue> statistics = null; + private Collection<ArtifactStatisticsSet> statistics = null; /** * Constructor @@ -155,17 +156,14 @@ } - /** + /**b * @see de.intevation.gnv.action.sessionmodel.SessionModel#getStatistics() */ - public Collection<ArtifactStatisticValue> getStatistics() { + public Collection<ArtifactStatisticsSet> getStatistics() { return this.statistics; } - /** - * @see de.intevation.gnv.action.sessionmodel.SessionModel#setStatistics(java.util.Collection) - */ - public void setStatistics(Collection<ArtifactStatisticValue> statistics) { + public void setStatistics(Collection<ArtifactStatisticsSet> statistics) { this.statistics = statistics; } }
--- a/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Wed Nov 11 16:24:02 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java Thu Nov 12 10:22:30 2009 +0000 @@ -9,6 +9,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.ArtifactStatisticsSet; import de.intevation.gnv.artifactdatabase.objects.OutputMode; /** @@ -39,8 +40,8 @@ void resetModel(); - void setStatistics(Collection<ArtifactStatisticValue> statistics); + void setStatistics(Collection<ArtifactStatisticsSet> statistics); - Collection<ArtifactStatisticValue> getStatistics(); + Collection<ArtifactStatisticsSet> getStatistics(); }
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java Wed Nov 11 16:24:02 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java Thu Nov 12 10:22:30 2009 +0000 @@ -11,6 +11,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.ArtifactStatisticsSet; import de.intevation.gnv.artifactdatabase.objects.InputParameter; /** @@ -102,7 +103,7 @@ * @return * @throws ArtifactDatabaseClientException */ - public Collection<ArtifactStatisticValue> calculateStatistics( + public Collection<ArtifactStatisticsSet> calculateStatistics( ArtifactObject artifactFactory, ArtifactObject currentArtifact) throws ArtifactDatabaseClientException;
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Wed Nov 11 16:24:02 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Thu Nov 12 10:22:30 2009 +0000 @@ -39,7 +39,9 @@ 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.ArtifactStatisticsSet; import de.intevation.gnv.artifactdatabase.objects.DefaultArtifactStatisticValue; +import de.intevation.gnv.artifactdatabase.objects.DefaultArtifactStatisticsSet; import de.intevation.gnv.artifactdatabase.objects.DefaultOutputMode; import de.intevation.gnv.artifactdatabase.objects.DefaultOutputParameter; import de.intevation.gnv.artifactdatabase.objects.InputParameter; @@ -688,38 +690,48 @@ } - public Collection<ArtifactStatisticValue> calculateStatistics( + public Collection<ArtifactStatisticsSet> calculateStatistics( ArtifactObject artifactFactory, ArtifactObject currentArtifact) throws ArtifactDatabaseClientException { log.debug("DefaultArtifactDatabaseClient.calculateStatistics"); - Collection<ArtifactStatisticValue> result; + Collection<ArtifactStatisticsSet> resultValues = null; + try { - result = null; String targetName = "statistics"; String requestUrl = this.getArtifactUrl(artifactFactory, - currentArtifact) - + "/" + targetName; + 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)); + + NodeList statisticSetNodes = xmlUtils.getNodeSetXPath(resultDocument, + "/statistics/statistic"); + resultValues = new ArrayList<ArtifactStatisticsSet> + (statisticSetNodes.getLength()); + for (int i = 0; i < statisticSetNodes.getLength(); i++) { + Element statisticSetNode = (Element)statisticSetNodes.item(i); + String name = statisticSetNode.getAttribute("name"); + ArtifactStatisticsSet set = + new DefaultArtifactStatisticsSet(name); + NodeList resultNodes = xmlUtils.getNodeSetXPath(statisticSetNode, + "statistic-value"); + if (resultNodes != null) { + for (int j = 0; j < resultNodes.getLength(); j++) { + Element statisticNode = (Element)resultNodes.item(j); + String statisticName = statisticNode. + getAttribute("name"); + String statisticValue = statisticNode. + getAttribute("value"); + set.addStatisticValues( + new DefaultArtifactStatisticValue + (statisticName,statisticValue)); + } } + resultValues.add(set); } } } catch (IOException e) { @@ -727,7 +739,7 @@ throw new ArtifactDatabaseClientException(e); } - return result; + return resultValues; } public void setLocale(Locale locale) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactStatisticsSet.java Thu Nov 12 10:22:30 2009 +0000 @@ -0,0 +1,21 @@ +/** + * + */ +package de.intevation.gnv.artifactdatabase.objects; + +import java.util.Collection; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public interface ArtifactStatisticsSet { + + + String getName(); + + Collection<ArtifactStatisticValue> getStatisticValues(); + + void addStatisticValues(ArtifactStatisticValue value); + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultArtifactStatisticsSet.java Thu Nov 12 10:22:30 2009 +0000 @@ -0,0 +1,47 @@ +/** + * + */ +package de.intevation.gnv.artifactdatabase.objects; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public class DefaultArtifactStatisticsSet implements ArtifactStatisticsSet{ + + private String name = null; + + private Collection<ArtifactStatisticValue> statisticValues = + new ArrayList<ArtifactStatisticValue>(); + /** + * Constructor + */ + public DefaultArtifactStatisticsSet(String name) { + this.name = name; + } + + /** + * @see de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet#addStatisticValues(de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticValue) + */ + public void addStatisticValues(ArtifactStatisticValue value) { + this.statisticValues.add(value); + } + + /** + * @see de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet#getName() + */ + public String getName() { + return this.name; + } + + /** + * @see de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet#getStatisticValues() + */ + public Collection<ArtifactStatisticValue> getStatisticValues() { + return this.statisticValues; + } + +}
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp Wed Nov 11 16:24:02 2009 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_statistics_inc.jsp Thu Nov 12 10:22:30 2009 +0000 @@ -4,28 +4,32 @@ <%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%> <%@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"> <% SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); - Collection<ArtifactStatisticValue> statistics = sm.getStatistics(); + Collection<ArtifactStatisticsSet> statistics = sm.getStatistics(); %> - - -<%@page import="java.util.Iterator"%><div id="statistics"> <fieldset> <legend class="expandableFieldset"> <bean:message key="gnviewer.statistics.header.title"/> </legend> + <%if (statistics != null){ + Iterator<ArtifactStatisticsSet> it = statistics.iterator(); + while (it.hasNext()){ + ArtifactStatisticsSet set = it.next(); + %> <div id="statisticValues"> - <%if (statistics != null){%> + <h1><%=set.getName()%></h1> <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(); - %> + <% 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> @@ -34,5 +38,6 @@ </table> <%} %> </div> + <%}%> </fieldset> </div> \ No newline at end of file