# HG changeset patch # User Tim Englich # Date 1258021350 0 # Node ID 5570d9b3282f44c7f9562011512266f228dfb652 # Parent 1fe52a0cbd1f87b17376d9e239f1c9505f004833 Implemented a better GUI-Structure for displaying the Statisticdata. issue83 gnv/trunk@327 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 1fe52a0cbd1f -r 5570d9b3282f gnv/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java (execute): diff -r 1fe52a0cbd1f -r 5570d9b3282f gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java --- 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 statistics = adc + Collection statistics = adc .calculateStatistics(sm.getSelectedArtifactFactory(), sm.getCurrentArtifact()); sm.setStatistics(statistics); diff -r 1fe52a0cbd1f -r 5570d9b3282f gnv/src/main/java/de/intevation/gnv/action/sessionmodel/DefaultSessionModel.java --- 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 statistics = null; + private Collection statistics = null; /** * Constructor @@ -155,17 +156,14 @@ } - /** + /**b * @see de.intevation.gnv.action.sessionmodel.SessionModel#getStatistics() */ - public Collection getStatistics() { + public Collection getStatistics() { return this.statistics; } - /** - * @see de.intevation.gnv.action.sessionmodel.SessionModel#setStatistics(java.util.Collection) - */ - public void setStatistics(Collection statistics) { + public void setStatistics(Collection statistics) { this.statistics = statistics; } } diff -r 1fe52a0cbd1f -r 5570d9b3282f gnv/src/main/java/de/intevation/gnv/action/sessionmodel/SessionModel.java --- 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 statistics); + void setStatistics(Collection statistics); - Collection getStatistics(); + Collection getStatistics(); } diff -r 1fe52a0cbd1f -r 5570d9b3282f gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/ArtifactDatabaseClient.java --- 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 calculateStatistics( + public Collection calculateStatistics( ArtifactObject artifactFactory, ArtifactObject currentArtifact) throws ArtifactDatabaseClientException; diff -r 1fe52a0cbd1f -r 5570d9b3282f gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java --- 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 calculateStatistics( + public Collection calculateStatistics( ArtifactObject artifactFactory, ArtifactObject currentArtifact) throws ArtifactDatabaseClientException { log.debug("DefaultArtifactDatabaseClient.calculateStatistics"); - Collection result; + Collection 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(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 + (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) { diff -r 1fe52a0cbd1f -r 5570d9b3282f gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ArtifactStatisticsSet.java --- /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 + * + */ +public interface ArtifactStatisticsSet { + + + String getName(); + + Collection getStatisticValues(); + + void addStatisticValues(ArtifactStatisticValue value); + +} diff -r 1fe52a0cbd1f -r 5570d9b3282f gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultArtifactStatisticsSet.java --- /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 + * + */ +public class DefaultArtifactStatisticsSet implements ArtifactStatisticsSet{ + + private String name = null; + + private Collection statisticValues = + new ArrayList(); + /** + * 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 getStatisticValues() { + return this.statisticValues; + } + +} diff -r 1fe52a0cbd1f -r 5570d9b3282f 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 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"%>
<% SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request); - Collection statistics = sm.getStatistics(); + Collection statistics = sm.getStatistics(); %> - - -<%@page import="java.util.Iterator"%>
+ <%if (statistics != null){ + Iterator it = statistics.iterator(); + while (it.hasNext()){ + ArtifactStatisticsSet set = it.next(); + %>
- <%if (statistics != null){%> +

<%=set.getName()%>

- <% Iterator it = statistics.iterator(); - while (it.hasNext()){ - ArtifactStatisticValue asv = it.next(); - %> + <% Iterator sit = set.getStatisticValues().iterator(); + while (sit.hasNext()){ + ArtifactStatisticValue asv = sit.next(); + %> @@ -34,5 +38,6 @@
<%=asv.getValue()%>
<%} %>
+ <%}%>
\ No newline at end of file