Project

General

Profile

« Previous | Next » 

Revision 4883

add vocab name/value matrix above data rows.
currently there is only a single column for the concatenated value of the vocab name + "/" + vocab value. it's so much easier!

View differences:

lib/style/skins/first/download.jsp
63 63
		//map keyed by the pivot column - metadata
64 64
		OrderedMap headerRows = new OrderedMap();
65 65
		
66
		//vocab columns
67
		String vocabNameCol = "qmetadatavocabulary";
68
		String vocabValueCol = "qmetadatavalue";
69
		//maps for the vocab lists
70
		OrderedMap vocabNames = new OrderedMap();
71
		OrderedMap vocabValues = new OrderedMap();
72
		//all vocab names/values
73
		List allVocabNames = new ArrayList();
74
		List allVocabValues = new ArrayList();
75
		
66 76
		int colCount = rs.getMetaData().getColumnCount();
67 77
		String idColName = rs.getMetaData().getColumnName(idCol);
68 78
		
......
108 118
					else {
109 119
						metadataRow.put(colName, value);
110 120
					}
121
					//names
122
					if (colName.startsWith(vocabNameCol)) {
123
						List list = (List) vocabNames.get(pivotValue);
124
						if (list == null) {
125
							list = new ArrayList();
126
						}
127
						list.add(value);
128
						vocabNames.put(pivotValue, list);
129
						allVocabNames.add(value);
130
					}
131
					//values
132
					if (colName.startsWith(vocabValueCol)) {
133
						List list = (List) vocabValues.get(pivotValue);
134
						if (list == null) {
135
							list = new ArrayList();
136
						}
137
						list.add(value);
138
						vocabValues.put(pivotValue, list);
139
						allVocabValues.add(value);
140
					}
111 141
				}
112 142
			}
113 143
			//track the data columns - the values are junk
......
121 151
			
122 152
		}
123 153
		
154
		/** Construct the table structure for returning **/
155
		
124 156
		//now make it into a list
125 157
		List retTable = new ArrayList();
126 158
		
......
168 200
			retTable.add(rowValues.toArray(new String[0]));
169 201
		}
170 202
		
203
		//create the special vocab matrix rows
204
		List vocabTable = new ArrayList();
205
		List uniqueVocabs = new ArrayList();
206
		for (int i = 0; i < allVocabNames.size(); i++) {
207
			List vocabRow = new ArrayList();
208
			String vocabName = (String) allVocabNames.get(i);
209
			String vocabValue = (String) allVocabValues.get(i);
210
			String key = vocabName + "/" + vocabValue;
211
			//check if we've processed this already, skip if so
212
			if (uniqueVocabs.contains(key)) {
213
				continue;
214
			}
215
			uniqueVocabs.add(key);
216
			//TODO: expand the column count by one for _everything_
217
			vocabRow.add(key);
218
			//vocabRow.add(vocabName);
219
			//vocabRow.add(vocabValue);
220
			//go through the questions now, again
221
			headerIter = header.iterator();
222
			while (headerIter.hasNext()) {
223
				String column = (String) headerIter.next();
224
				//get the pivotValue part of column name if it exists
225
				String pivotValue = null;
226
				try {
227
					pivotValue = column.substring(0, column.indexOf("_"));
228
				}
229
				catch (Exception e) {}
230
				if (pivotValue == null) {
231
					continue;
232
				}
233
				//check to see if this question has that keyword
234
				List names = (List) vocabNames.get(pivotValue);
235
				List values = (List) vocabValues.get(pivotValue);
236
				if (names != null && names.indexOf(vocabName) > -1 && names.indexOf(vocabName) == values.indexOf(vocabValue) ) {
237
					vocabRow.add("true");
238
				}
239
				else {
240
					vocabRow.add("false");
241
				}
242
			}
243
			//put the row on
244
			vocabTable.add(vocabRow.toArray(new String[0]));
245
		}
246
		
247
		//put the vocab matrix on the table
248
		retTable.addAll(vocabTable);
249
		
171 250
		//put the data header row on the table
172 251
		retTable.add(header.toArray(new String[0]));
173 252
		

Also available in: Unified diff