Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/exports/ODVExport.java @ 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 | 2423cefe7d39 |
children | f953c9a559d8 |
comparison
equal
deleted
inserted
replaced
1057:04967dc9c83f | 1058:2b4f1c095468 |
---|---|
52 this.startTime = startTime; | 52 this.startTime = startTime; |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 @Override | 56 @Override |
57 protected void writeData(Profile profile, Collection result, | 57 protected void writeData( |
58 CSVWriter writer) throws StateException { | 58 Profile profile, Collection result, CSVWriter writer |
59 )throws StateException | |
60 { | |
59 Iterator<Result> it = result.iterator(); | 61 Iterator<Result> it = result.iterator(); |
62 log.debug("Put " + result.size() + " elements into odv export."); | |
60 | 63 |
61 String[] header = profile.getHeader(); | 64 String[] header = profile.getHeader(); |
62 ArrayList<String> headerList = new ArrayList<String>(); | 65 ArrayList<String> headerList = new ArrayList<String>(); |
63 for (int i= 0; i < header.length; i++){ | 66 for (int i= 0; i < header.length; i++){ |
64 headerList.add(header[i]); | 67 headerList.add(header[i]); |
67 if (this.startTime != null){ | 70 if (this.startTime != null){ |
68 headerList.add("time_ISO8601"); | 71 headerList.add("time_ISO8601"); |
69 } | 72 } |
70 ArrayList<String> paramids = new ArrayList<String>(); | 73 ArrayList<String> paramids = new ArrayList<String>(); |
71 | 74 |
72 Map<StringArrayKey, Map<String,String>> aggregatedRows = new HashMap<StringArrayKey, Map<String,String>>(); | 75 Map<StringArrayKey, Map<String,String>> aggregatedRows = |
73 | 76 new HashMap<StringArrayKey, Map<String,String>>(); |
74 String currentParameterID = "N/N"; | |
75 | 77 |
76 while (it.hasNext()) { | 78 while (it.hasNext()) { |
77 Result res = it.next(); | 79 Result res = it.next(); |
78 | 80 |
79 String[] value = collector.getData(res); | 81 String[] value = collector.getData(res); |
80 StringArrayKey key = new StringArrayKey(value); | 82 StringArrayKey key = new StringArrayKey(value); |
81 String parameterValue = res.getString("DATAVALUE"); | 83 String parameterValue = res.getString("DATAVALUE"); |
82 String parameterID = res.getString("PARAMETER"); | 84 String parameterID = res.getString("PARAMETER"); |
83 | 85 |
84 if (!currentParameterID.equals(parameterID)){ | 86 if (!paramids.contains(parameterID)){ |
85 paramids.add(parameterID); | 87 paramids.add(parameterID); |
86 headerList.add(this.findParamTitle(parameters, parameterID)); | 88 headerList.add(findParamTitle(parameters, parameterID)); |
87 headerList.add("QF"); | 89 headerList.add("QF"); |
88 currentParameterID = parameterID; | |
89 } | 90 } |
90 | 91 |
91 Map<String,String> aggregatedRow = aggregatedRows.get(key); | 92 Map<String,String> aggregatedRow = aggregatedRows.get(key); |
92 if (aggregatedRow!= null){ | 93 if (aggregatedRow!= null){ |
93 aggregatedRow.put(parameterID, parameterValue); | 94 aggregatedRow.put(parameterID, parameterValue); |
94 }else{ | 95 } |
96 else{ | |
95 Map<String,String> params = new HashMap<String, String>(); | 97 Map<String,String> params = new HashMap<String, String>(); |
96 params.put(parameterID, parameterValue); | 98 params.put(parameterID, parameterValue); |
97 aggregatedRows.put(key, params); | 99 aggregatedRows.put(key, params); |
98 } | 100 } |
99 } | 101 } |