Revision 4874
Added by ben leinfelder over 15 years ago
lib/style/skins/first/download.jsp | ||
---|---|---|
55 | 55 |
return params; |
56 | 56 |
} |
57 | 57 |
%><%! |
58 |
private List transpose(ResultSet rs, int idCol, int pivotCol, boolean omitIdValues) throws SQLException { |
|
58 |
private List transpose(ResultSet rs, int idCol, int pivotCol, List pivotAttributes, boolean omitIdValues) throws SQLException {
|
|
59 | 59 |
OrderedMap table = new OrderedMap(); |
60 | 60 |
OrderedMap widestRow = new OrderedMap(); |
61 | 61 |
int colCount = rs.getMetaData().getColumnCount(); |
... | ... | |
75 | 75 |
for (int i = 1; i <= colCount; i++) { |
76 | 76 |
if (i != pivotCol) { |
77 | 77 |
String colName = rs.getMetaData().getColumnName(i); |
78 |
//annotate the column name with the pivot column value if not the id column |
|
79 |
if (i != idCol) { |
|
80 |
colName = pivotValue + "_" + colName; |
|
78 |
//do we include this column in the pivot? |
|
79 |
if (pivotAttributes.contains(colName)) { |
|
80 |
//annotate the column name with the pivot column value if not the id column |
|
81 |
if (i != idCol) { |
|
82 |
colName = pivotValue + "_" + colName; |
|
83 |
} |
|
84 |
String value = rs.getString(i); |
|
85 |
row.put(colName, value); |
|
81 | 86 |
} |
82 |
String value = rs.getString(i); |
|
83 |
row.put(colName, value); |
|
84 | 87 |
} |
85 | 88 |
} |
86 | 89 |
//track the headers - the values are junk |
... | ... | |
179 | 182 |
CSVWriter csv = new CSVWriter(writer, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER); |
180 | 183 |
try { |
181 | 184 |
if (transpose) { |
182 |
List transposedTable = transpose(rs, observation, pivot, true); |
|
185 |
List pivotCols = new ArrayList(); |
|
186 |
pivotCols.add("studentid"); |
|
187 |
pivotCols.add("score"); |
|
188 |
pivotCols.add("response"); |
|
189 |
List transposedTable = transpose(rs, observation, pivot, pivotCols, true); |
|
183 | 190 |
csv.writeAll(transposedTable); |
184 | 191 |
} else { |
185 | 192 |
csv.writeAll(rs, true); |
Also available in: Unified diff
pivot constrained to a List of specific attributes: studentId (record number), score, response.
This is the "lower half" of the return set (data).
now: on to the metadata header rows