Revision 3771
Added by Jing Tao about 16 years ago
QueryTerm.java | ||
---|---|---|
303 | 303 |
} |
304 | 304 |
else { |
305 | 305 |
// without using XML Index; using nested statements instead |
306 |
self.append("AND parentnodeid IN "); |
|
306 |
//self.append("AND parentnodeid IN "); |
|
307 |
self.append("AND "); |
|
307 | 308 |
self.append(useNestedStatements(pathexpr)); |
308 | 309 |
} |
309 | 310 |
} |
... | ... | |
335 | 336 |
{ |
336 | 337 |
log.info("useNestedStatements()"); |
337 | 338 |
log.info("pathexpr: " + pathexpr); |
339 |
String elementPrefix = " parentnodeid IN "; |
|
340 |
String attributePrefix = " nodeid IN "; |
|
341 |
boolean lastOneIsAttribute = false; |
|
338 | 342 |
StringBuffer nestedStmts = new StringBuffer(); |
339 | 343 |
String path = pathexpr.trim(); |
344 |
String sql = ""; |
|
340 | 345 |
|
341 | 346 |
if (path.indexOf('/') == 0) |
342 | 347 |
{ |
... | ... | |
366 | 371 |
{ |
367 | 372 |
// no and it's the last node |
368 | 373 |
node = path; |
374 |
if (node != null && node.indexOf(QuerySpecification.ATTRIBUTESYMBOL) != -1) |
|
375 |
{ |
|
376 |
lastOneIsAttribute = true; |
|
377 |
node = removeAttributeSymbol(node); |
|
378 |
} |
|
369 | 379 |
path = ""; |
370 | 380 |
} |
371 | 381 |
else |
... | ... | |
426 | 436 |
nestedStmts.append(") "); |
427 | 437 |
} |
428 | 438 |
while (!path.equals("")); |
429 |
|
|
430 |
return nestedStmts.toString(); |
|
439 |
if (lastOneIsAttribute) |
|
440 |
{ |
|
441 |
sql = attributePrefix+nestedStmts.toString(); |
|
442 |
} |
|
443 |
else |
|
444 |
{ |
|
445 |
sql = elementPrefix+nestedStmts.toString(); |
|
446 |
} |
|
447 |
return sql; |
|
431 | 448 |
} |
449 |
|
|
450 |
|
|
451 |
/* |
|
452 |
* Removes @ symbol from path. For example, if path is @entity, entity will be returned. |
|
453 |
* If path is entity, entity will be returned. |
|
454 |
*/ |
|
455 |
private static String removeAttributeSymbol(String path) |
|
456 |
{ |
|
457 |
String newPath =""; |
|
458 |
log.debug("Original string before removing @ is " + path); |
|
459 |
if (path != null) |
|
460 |
{ |
|
461 |
|
|
462 |
int attribute = path.indexOf(QuerySpecification.ATTRIBUTESYMBOL); |
|
463 |
if (attribute != -1) |
|
464 |
{ |
|
465 |
// has attribute symbol. Reomve it and return the remained part. |
|
466 |
try |
|
467 |
{ |
|
468 |
newPath = path.substring(attribute + 1).trim(); |
|
469 |
} |
|
470 |
catch (Exception e) |
|
471 |
{ |
|
472 |
newPath = path; |
|
473 |
} |
|
474 |
} |
|
475 |
else |
|
476 |
{ |
|
477 |
// doesn't have attribute symbol. Return original string |
|
478 |
newPath = path; |
|
479 |
} |
|
480 |
} |
|
481 |
else |
|
482 |
{ |
|
483 |
// if is null, return null; |
|
484 |
newPath = path; |
|
485 |
} |
|
486 |
log.debug("String after removing @ is " + newPath); |
|
487 |
return newPath; |
|
488 |
|
|
489 |
} |
|
432 | 490 |
|
433 | 491 |
/** |
434 | 492 |
* |
Also available in: Unified diff
Fixed bug that lsid couldn't be shown up in result page of kepler skin. The bug is that in extended query, lsid attribute was treated as a element, but it is attribute.
I also optimized the query by deleting xml_documents table from query. The table is not needed.