Revision 7417
Added by ben leinfelder over 11 years ago
DBQuery.java | ||
---|---|---|
391 | 391 |
response.setContentType("text/xml"); |
392 | 392 |
} |
393 | 393 |
createResultDocument(xmlquery, qspec, out, user, groups, useXMLIndex, |
394 |
pagesize, pagestart, sessionid, qformat); |
|
394 |
pagesize, pagestart, sessionid, qformat, false);
|
|
395 | 395 |
}//if |
396 | 396 |
else |
397 | 397 |
{ |
... | ... | |
400 | 400 |
Writer nonout = null; |
401 | 401 |
StringBuffer xml = createResultDocument(xmlquery, qspec, nonout, user, |
402 | 402 |
groups, useXMLIndex, pagesize, |
403 |
pagestart, sessionid, qformat); |
|
403 |
pagestart, sessionid, qformat, false);
|
|
404 | 404 |
|
405 | 405 |
//transfer the xml to html |
406 | 406 |
try |
... | ... | |
440 | 440 |
|
441 | 441 |
} |
442 | 442 |
|
443 |
|
|
444 |
|
|
445 | 443 |
/** |
446 | 444 |
* Transforms a hashtable of documents to an xml or html result and sent |
447 | 445 |
* the content to outputstream. Keep going untill hastable is empty. stop it. |
... | ... | |
462 | 460 |
String user, String[] groups, |
463 | 461 |
boolean useXMLIndex) |
464 | 462 |
{ |
465 |
return createResultDocument(xmlquery,qspec,out, user,groups, useXMLIndex, 0, 0,"", qformat); |
|
463 |
return createResultDocument(xmlquery,qspec,out, user,groups, useXMLIndex, 0, 0,"", qformat, false);
|
|
466 | 464 |
} |
465 |
|
|
466 |
/** |
|
467 |
* |
|
468 |
* @param xmlquery |
|
469 |
* @param user |
|
470 |
* @param groups |
|
471 |
* @param useXMLIndex |
|
472 |
* @return |
|
473 |
* @throws IOException |
|
474 |
* @throws PropertyNotFoundException |
|
475 |
*/ |
|
476 |
public String performPathquery(String xmlquery, String user, |
|
477 |
String[] groups) throws PropertyNotFoundException, IOException { |
|
478 |
|
|
479 |
// get the XML query and convert it to query specification |
|
480 |
xmlquery = transformQuery(xmlquery); |
|
481 |
QuerySpecification qspec = new QuerySpecification(xmlquery, parserName, PropertyService.getProperty("document.accNumSeparator")); |
|
482 |
|
|
483 |
// force it to output the results to the string buffer, not outputstream |
|
484 |
Writer nonout = null; |
|
485 |
boolean useXMLIndex = (new Boolean(PropertyService.getProperty("database.usexmlindex"))).booleanValue(); |
|
486 |
StringBuffer xml = createResultDocument(xmlquery, qspec, nonout, user, groups, useXMLIndex, 0, 0, "", qformat, true); |
|
467 | 487 |
|
488 |
return xml.toString(); |
|
489 |
|
|
490 |
} |
|
491 |
|
|
468 | 492 |
/* |
469 | 493 |
* Transforms a hashtable of documents to an xml or html result and sent |
470 | 494 |
* the content to outputstream. Keep going untill hastable is empty. stop it. |
... | ... | |
477 | 501 |
String user, String[] groups, |
478 | 502 |
boolean useXMLIndex, int pagesize, |
479 | 503 |
int pagestart, String sessionid, |
480 |
String qformat) |
|
504 |
String qformat, boolean includeGuid)
|
|
481 | 505 |
{ |
482 | 506 |
DBConnection dbconn = null; |
483 | 507 |
int serialNumber = -1; |
... | ... | |
523 | 547 |
logMetacat.debug("DBQuery.createResultDocument - Not in map query"); |
524 | 548 |
resultContent = findResultDoclist(qspec, out, user, groups, |
525 | 549 |
dbconn, useXMLIndex, pagesize, pagestart, |
526 |
sessionid, givenDocids, qformat); |
|
550 |
sessionid, givenDocids, qformat, includeGuid);
|
|
527 | 551 |
} |
528 | 552 |
else |
529 | 553 |
{ |
... | ... | |
535 | 559 |
givenDocids = (Vector)docidOverride.elementAt(i); |
536 | 560 |
StringBuffer subset = findResultDoclist(qspec, out, user, groups, |
537 | 561 |
dbconn, useXMLIndex, pagesize, pagestart, |
538 |
sessionid, givenDocids, qformat); |
|
562 |
sessionid, givenDocids, qformat, includeGuid);
|
|
539 | 563 |
resultContent.append(subset); |
540 | 564 |
} |
541 | 565 |
} |
... | ... | |
584 | 608 |
String user, String[]groups, |
585 | 609 |
DBConnection dbconn, boolean useXMLIndex, |
586 | 610 |
int pagesize, int pagestart, String sessionid, |
587 |
Vector givenDocids, String qformat) |
|
611 |
Vector givenDocids, String qformat, boolean includeGuid)
|
|
588 | 612 |
throws Exception |
589 | 613 |
{ |
590 | 614 |
// keep track of the values we add as prepared statement question marks (?) |
... | ... | |
597 | 621 |
ResultDocumentSet docListResult = new ResultDocumentSet(); |
598 | 622 |
PreparedStatement pstmt = null; |
599 | 623 |
String docid = null; |
624 |
String guid = null; |
|
600 | 625 |
String docname = null; |
601 | 626 |
String doctype = null; |
602 | 627 |
String createDate = null; |
... | ... | |
652 | 677 |
|
653 | 678 |
// include the docids, either exclusively, or in conjuction with the query |
654 | 679 |
if (operator == null) { |
655 |
query = "SELECT xml_documents.docid, docname, doctype, date_created, date_updated, xml_documents.rev " + |
|
680 |
query = "SELECT xml_documents.docid, identifier.guid, docname, doctype, date_created, date_updated, xml_documents.rev " +
|
|
656 | 681 |
"FROM xml_documents, identifier " + |
657 | 682 |
"WHERE xml_documents.docid = identifier.docid AND xml_documents.rev = identifier.rev AND "; |
658 | 683 |
query = query + docidCondition.toString(); |
... | ... | |
749 | 774 |
{ |
750 | 775 |
logMetacat.debug("DBQuery.findResultDoclist - getting result: " + currentIndex); |
751 | 776 |
docid = rs.getString(1).trim(); |
752 |
logMetacat.debug("DBQuery.findResultDoclist - processing: " + docid); |
|
753 |
docname = rs.getString(2); |
|
754 |
doctype = rs.getString(3); |
|
755 |
logMetacat.debug("DBQuery.findResultDoclist - processing: " + doctype); |
|
756 |
createDate = rs.getString(4); |
|
757 |
updateDate = rs.getString(5); |
|
758 |
rev = rs.getInt(6); |
|
777 |
logMetacat.debug("DBQuery.findResultDoclist - docid: " + docid); |
|
778 |
guid = rs.getString(2).trim(); |
|
779 |
logMetacat.debug("DBQuery.findResultDoclist - guid: " + guid); |
|
780 |
docname = rs.getString(3); |
|
781 |
doctype = rs.getString(4); |
|
782 |
logMetacat.debug("DBQuery.findResultDoclist - doctype: " + doctype); |
|
783 |
createDate = rs.getString(5); |
|
784 |
updateDate = rs.getString(6); |
|
785 |
rev = rs.getInt(7); |
|
759 | 786 |
|
760 | 787 |
Vector returndocVec = qspec.getReturnDocList(); |
761 | 788 |
if (returndocVec.size() == 0 || returndocVec.contains(doctype)) |
... | ... | |
767 | 794 |
+ PropertyService.getProperty("document.accNumSeparator"); |
768 | 795 |
completeDocid += rev; |
769 | 796 |
document.append("<docid>").append(completeDocid).append("</docid>"); |
797 |
if (includeGuid) { |
|
798 |
document.append("<guid>").append(guid).append("</guid>"); |
|
799 |
} |
|
770 | 800 |
if (docname != null) |
771 | 801 |
{ |
772 | 802 |
document.append("<docname>" + docname + "</docname>"); |
Also available in: Unified diff
Implement MNQuery for "pathquery" engine. Optionally include guid in the pathquery results (https://redmine.dataone.org/issues/3083)