Revision 3730
Added by Jing Tao over 16 years ago
src/edu/ucsb/nceas/metacat/DBQuery.java | ||
---|---|---|
847 | 847 |
MetaCatUtil.writeDebugToDelimiteredFile(" " |
848 | 848 |
+ (endExtendedQuery - endGetReturnValueFromQueryresultable), false); |
849 | 849 |
//add relationship part part docid list for the documents in partOfDocList |
850 |
partOfDoclist = addRelationship(partOfDoclist, qspec, dbconn, useXMLIndex); |
|
850 |
//partOfDoclist = addRelationship(partOfDoclist, qspec, dbconn, useXMLIndex);
|
|
851 | 851 |
|
852 | 852 |
double startStoreReturnField = System.currentTimeMillis()/1000; |
853 | 853 |
Iterator keys = partOfDoclist.getDocids(); |
... | ... | |
1251 | 1251 |
return docListResult; |
1252 | 1252 |
}//addReturnfield |
1253 | 1253 |
|
1254 |
/* |
|
1255 |
* A method to add relationship to return doclist hash table |
|
1256 |
*/ |
|
1257 |
private ResultDocumentSet addRelationship(ResultDocumentSet docListResult, |
|
1258 |
QuerySpecification qspec, |
|
1259 |
DBConnection dbconn, boolean useXMLIndex ) |
|
1260 |
throws Exception |
|
1261 |
{ |
|
1262 |
PreparedStatement pstmt = null; |
|
1263 |
ResultSet rs = null; |
|
1264 |
StringBuffer document = null; |
|
1265 |
double startRelation = System.currentTimeMillis() / 1000; |
|
1266 |
Iterator docidkeys = docListResult.getDocids(); |
|
1267 |
while (docidkeys.hasNext()) |
|
1268 |
{ |
|
1269 |
//String connstring = |
|
1270 |
// "metacat://"+util.getOption("server")+"?docid="; |
|
1271 |
String connstring = "%docid="; |
|
1272 |
String docidkey; |
|
1273 |
synchronized(docListResult) |
|
1274 |
{ |
|
1275 |
docidkey = (String) docidkeys.next(); |
|
1276 |
} |
|
1277 |
pstmt = dbconn.prepareStatement(QuerySpecification |
|
1278 |
.printRelationSQL(docidkey)); |
|
1279 |
pstmt.execute(); |
|
1280 |
rs = pstmt.getResultSet(); |
|
1281 |
boolean tableHasRows = rs.next(); |
|
1282 |
while (tableHasRows) |
|
1283 |
{ |
|
1284 |
String sub = rs.getString(1); |
|
1285 |
String rel = rs.getString(2); |
|
1286 |
String obj = rs.getString(3); |
|
1287 |
String subDT = rs.getString(4); |
|
1288 |
String objDT = rs.getString(5); |
|
1289 |
|
|
1290 |
document = new StringBuffer(); |
|
1291 |
document.append("<triple>"); |
|
1292 |
document.append("<subject>").append(MetaCatUtil.normalize(sub)); |
|
1293 |
document.append("</subject>"); |
|
1294 |
if (subDT != null) |
|
1295 |
{ |
|
1296 |
document.append("<subjectdoctype>").append(subDT); |
|
1297 |
document.append("</subjectdoctype>"); |
|
1298 |
} |
|
1299 |
document.append("<relationship>").append(MetaCatUtil.normalize(rel)); |
|
1300 |
document.append("</relationship>"); |
|
1301 |
document.append("<object>").append(MetaCatUtil.normalize(obj)); |
|
1302 |
document.append("</object>"); |
|
1303 |
if (objDT != null) |
|
1304 |
{ |
|
1305 |
document.append("<objectdoctype>").append(objDT); |
|
1306 |
document.append("</objectdoctype>"); |
|
1307 |
} |
|
1308 |
document.append("</triple>"); |
|
1309 |
|
|
1310 |
String removedelement = (String) docListResult.get(docidkey); |
|
1311 |
docListResult.set(docidkey, removedelement+ document.toString()); |
|
1312 |
tableHasRows = rs.next(); |
|
1313 |
}//while |
|
1314 |
rs.close(); |
|
1315 |
pstmt.close(); |
|
1316 |
|
|
1317 |
}//while |
|
1318 |
double endRelation = System.currentTimeMillis() / 1000; |
|
1319 |
logMetacat.warn("Time to add relationship to return fields (part 3 in return fields): " |
|
1320 |
+ (endRelation - startRelation)); |
|
1321 |
MetaCatUtil.writeDebugToFile("-----------------------------------------Add relationship to return field(part3 in return fields): " |
|
1322 |
+ (endRelation - startRelation)); |
|
1323 |
MetaCatUtil.writeDebugToDelimiteredFile(" "+ (endRelation - startRelation), false); |
|
1324 |
|
|
1325 |
return docListResult; |
|
1326 |
}//addRelation |
|
1327 |
|
|
1254 |
|
|
1328 | 1255 |
/** |
1329 | 1256 |
* removes the <?xml version="1.0"?> tag from the beginning. This takes a |
1330 | 1257 |
* string as a param instead of a hashtable. |
Also available in: Unified diff
Remove the relation query.