Revision 3635
Added by ben leinfelder about 17 years ago
src/edu/ucsb/nceas/metacat/DBQuery.java | ||
---|---|---|
1106 | 1106 |
ResultSet rs = null; |
1107 | 1107 |
String docid = null; |
1108 | 1108 |
String fieldname = null; |
1109 |
String fieldtype = null; |
|
1109 | 1110 |
String fielddata = null; |
1110 | 1111 |
String relation = null; |
1111 | 1112 |
|
... | ... | |
1159 | 1160 |
fielddata = rs.getString(3); |
1160 | 1161 |
fielddata = MetaCatUtil.normalize(fielddata); |
1161 | 1162 |
String parentId = rs.getString(4); |
1163 |
fieldtype = rs.getString(5); |
|
1162 | 1164 |
StringBuffer value = new StringBuffer(); |
1163 | 1165 |
|
1164 |
// if xml_index is used, there would be just one record per nodeid |
|
1165 |
// as xml_index just keeps one entry for each path |
|
1166 |
//handle case when usexmlindex is true differently |
|
1167 |
//at one point merging the nodedata (for large text elements) was |
|
1168 |
//deemed unnecessary - but now it is needed. but not for attribute nodes |
|
1166 | 1169 |
if (useXMLIndex || !containsKey(parentidList, parentId)) { |
1167 |
// don't need to merger nodedata |
|
1170 |
//merge node data only for non-ATTRIBUTEs |
|
1171 |
if (fieldtype != null && !fieldtype.equals("ATTRIBUTE")) { |
|
1172 |
//try merging the data |
|
1173 |
ReturnFieldValue existingRFV = |
|
1174 |
getArrayValue(parentidList, parentId); |
|
1175 |
if (existingRFV != null) { |
|
1176 |
fielddata = existingRFV.getFieldValue() + fielddata; |
|
1177 |
} |
|
1178 |
} |
|
1168 | 1179 |
value.append("<param name=\""); |
1169 | 1180 |
value.append(fieldname); |
1170 | 1181 |
value.append("\">"); |
... | ... | |
1173 | 1184 |
//set returnvalue |
1174 | 1185 |
returnValue.setDocid(docid); |
1175 | 1186 |
returnValue.setFieldValue(fielddata); |
1187 |
returnValue.setFieldType(fieldtype); |
|
1176 | 1188 |
returnValue.setXMLFieldValue(value.toString()); |
1177 | 1189 |
// Store it in hastable |
1178 | 1190 |
putInArray(parentidList, parentId, returnValue); |
... | ... | |
1191 | 1203 |
value.append("</param>"); |
1192 | 1204 |
returnValue.setDocid(docid); |
1193 | 1205 |
returnValue.setFieldValue(fielddata); |
1206 |
returnValue.setFieldType(fieldtype); |
|
1194 | 1207 |
returnValue.setXMLFieldValue(value.toString()); |
1195 | 1208 |
// remove the old return value from paretnidList |
1196 | 1209 |
parentidList.remove(parentId); |
... | ... | |
1400 | 1413 |
} |
1401 | 1414 |
return false; |
1402 | 1415 |
} |
1403 |
|
|
1416 |
|
|
1404 | 1417 |
/* |
1405 | 1418 |
* A method to put key and value in Vector |
1406 | 1419 |
*/ |
... | ... | |
1409 | 1422 |
{ |
1410 | 1423 |
|
1411 | 1424 |
Vector tempVector = null; |
1412 |
|
|
1413 |
for (int count = 0; count < parentidList.size(); count++) { |
|
1414 |
tempVector = (Vector) parentidList.get(count); |
|
1415 |
|
|
1416 |
if (key.compareTo((String) tempVector.get(0)) == 0) { |
|
1417 |
tempVector.remove(1); |
|
1418 |
tempVector.add(1, value); |
|
1419 |
return; |
|
1420 |
} |
|
1425 |
//only filter if the field type is NOT an attribute (say, for text) |
|
1426 |
String fieldType = value.getFieldType(); |
|
1427 |
if (fieldType != null && !fieldType.equals("ATTRIBUTE")) { |
|
1428 |
|
|
1429 |
for (int count = 0; count < parentidList.size(); count++) { |
|
1430 |
tempVector = (Vector) parentidList.get(count); |
|
1431 |
|
|
1432 |
if (key.compareTo((String) tempVector.get(0)) == 0) { |
|
1433 |
tempVector.remove(1); |
|
1434 |
tempVector.add(1, value); |
|
1435 |
return; |
|
1436 |
} |
|
1437 |
} |
|
1421 | 1438 |
} |
1422 | 1439 |
|
1423 | 1440 |
tempVector = new Vector(); |
... | ... | |
2423 | 2440 |
|
2424 | 2441 |
private String xmlFieldValue = null; //return field value in xml |
2425 | 2442 |
// format |
2443 |
private String fieldType = null; //ATTRIBUTE, TEXT... |
|
2426 | 2444 |
|
2427 | 2445 |
public void setDocid(String myDocid) |
2428 | 2446 |
{ |
... | ... | |
2453 | 2471 |
{ |
2454 | 2472 |
return xmlFieldValue; |
2455 | 2473 |
} |
2474 |
|
|
2475 |
public void setFieldType(String myType) |
|
2476 |
{ |
|
2477 |
fieldType = myType; |
|
2478 |
} |
|
2456 | 2479 |
|
2480 |
public String getFieldType() |
|
2481 |
{ |
|
2482 |
return fieldType; |
|
2483 |
} |
|
2484 |
|
|
2457 | 2485 |
} |
2458 | 2486 |
|
2459 | 2487 |
/** |
Also available in: Unified diff
changes for fix to bug #2999 (only one attribute of an element is returned in resultset doc)
-added merging for large TEXT nodes when they have been broken up.
-allow multiple attributes to be returned in the resultset doc (uses newly-available field type to determine text vs attribute node).