changeset 1058:2b4f1c095468

Fixed the aggregation of row with the same parameter in the odv export (issue291). gnv-artifacts/trunk@1136 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 28 May 2010 07:37:59 +0000
parents 04967dc9c83f
children 174f6eacd595
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/exports/ODVExport.java
diffstat 2 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Thu May 27 16:43:00 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Fri May 28 07:37:59 2010 +0000
@@ -1,3 +1,10 @@
+2010-05-28  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	  Issue291
+
+	* src/main/java/de/intevation/gnv/exports/ODVExport.java: Fixed the
+	  aggregation of parameters.
+
 2010-05-27  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	  Issue198
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/ODVExport.java	Thu May 27 16:43:00 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/ODVExport.java	Fri May 28 07:37:59 2010 +0000
@@ -54,9 +54,12 @@
 
 
     @Override
-    protected void writeData(Profile profile, Collection result,
-                             CSVWriter writer) throws StateException {
+    protected void writeData(
+        Profile profile, Collection result, CSVWriter writer
+    )throws StateException
+    {
         Iterator<Result> it = result.iterator();
+        log.debug("Put " + result.size() + " elements into odv export.");
 
         String[] header = profile.getHeader();
         ArrayList<String> headerList = new ArrayList<String>();
@@ -69,9 +72,8 @@
         }
         ArrayList<String> paramids = new ArrayList<String>();
 
-        Map<StringArrayKey, Map<String,String>> aggregatedRows = new HashMap<StringArrayKey, Map<String,String>>();
-
-        String currentParameterID = "N/N";
+        Map<StringArrayKey, Map<String,String>> aggregatedRows =
+            new HashMap<StringArrayKey, Map<String,String>>();
 
         while (it.hasNext()) {
             Result res = it.next();
@@ -81,17 +83,17 @@
             String parameterValue = res.getString("DATAVALUE");
             String parameterID = res.getString("PARAMETER");
 
-            if (!currentParameterID.equals(parameterID)){
+            if (!paramids.contains(parameterID)){
                 paramids.add(parameterID);
-                headerList.add(this.findParamTitle(parameters, parameterID));
+                headerList.add(findParamTitle(parameters, parameterID));
                 headerList.add("QF");
-                currentParameterID = parameterID;
             }
 
             Map<String,String> aggregatedRow = aggregatedRows.get(key);
             if (aggregatedRow!= null){
                 aggregatedRow.put(parameterID, parameterValue);
-            }else{
+            }
+            else{
                 Map<String,String> params = new HashMap<String, String>();
                 params.put(parameterID, parameterValue);
                 aggregatedRows.put(key, params);

http://dive4elements.wald.intevation.org