Changeset 865
- Timestamp:
- 2000-01-25T11:58:00+13:00 (24 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/queryaction.cpp
r828 r865 28 28 /* 29 29 $Log$ 30 Revision 1.33 2000/01/24 22:57:59 sjboddie 31 fixed bug in cross-collection searching, tidied up a bit 32 30 33 Revision 1.32 1999/12/13 02:54:11 davidb 31 34 Support for cross collection searching (CCS) … … 539 542 } 540 543 541 void queryaction::output_ccp (cgiargsclass &args, recptprotolistclass *protos,542 displayclass &disp, outconvertclass &outconvert,543 ostream &textout, ostream &logout) {544 545 ColInfoResponse_t cinfo;546 comerror_t err;547 InfoFilterOptionsResponse_t fresponse;548 InfoFilterOptionsRequest_t frequest;549 frequest.filterName = "QueryFilter";550 551 text_t &index = args["h"];552 text_t &subcollection = args["j"];553 text_t &language = args["n"];554 555 text_tset collections;556 text_t arg_c = args["c"];557 558 // get collect info for 'c'559 bool found_arg_c = false;560 recptprotolistclass::iterator rprotolist_here = protos->begin();561 const recptprotolistclass::iterator rprotolist_end = protos->end();562 while (rprotolist_here != rprotolist_end)563 {564 if ((*rprotolist_here).p != NULL)565 {566 (*rprotolist_here).p->get_collectinfo (arg_c, cinfo, err, logout);567 if (err == noError && (cinfo.buildDate > 0))568 {569 text_tarray::iterator collist_here = cinfo.ccsCols.begin();570 const text_tarray::iterator collist_end = cinfo.ccsCols.end();571 while (collist_here != collist_end) {572 collections.insert(*collist_here);573 collist_here++;574 }575 found_arg_c = true;576 break;577 }578 579 }580 rprotolist_here ++;581 }582 583 if (!found_arg_c)584 {585 // if no collection is found, let ccs be across all collections586 rprotolist_here = protos->begin();587 while (rprotolist_here != rprotolist_end)588 {589 if ((*rprotolist_here).p != NULL)590 {591 (*rprotolist_here).p->get_collectinfo (arg_c, cinfo, err, logout);592 if (err == noError && (cinfo.buildDate > 0))593 594 {595 text_tarray collist;596 (*rprotolist_here).p->get_collection_list (collist, err, logout);597 598 text_tarray::iterator collist_here = collist.begin();599 text_tarray::iterator collist_end = collist.end();600 while (collist_here != collist_end)601 {602 collections.insert(*collist_here);603 collist_here++;604 }605 }606 }607 rprotolist_here ++;608 }609 }610 611 textout << outconvert << disp << "_query:header_\n"612 << "<center>_navigationbar_</center><br>\n"613 << "<form name=QueryForm method=get action=\"_gwcgi_\">\n"614 << "<input type=hidden name=a value=\"q\">\n"615 << "<input type=hidden name=e value=\"_compressedoptions_\">\n"616 << "<input type=hidden name=ccp value=\"1\">\n"617 << "<center><table width=_pagewidth_><tr valign=top>\n"618 << "<td>Select collections to search for \"" << args["q"]619 << "\" <i>(index=" << index << " subcollection=" << subcollection620 << " language=" << language << ")</i></td>\n"621 << "<td><input type=\"submit\" value=\"_query:textbeginsearch_\"></td>\n"622 << "</tr></table></center>\n"623 << "<center><table width=_pagewidth_>\n"624 << "<tr><td>\n";625 626 rprotolist_here = protos->begin();627 while (rprotolist_here != rprotolist_end) {628 if ((*rprotolist_here).p != NULL) {629 630 text_tarray collist;631 (*rprotolist_here).p->get_collection_list (collist, err, logout);632 if (err == noError) {633 text_tarray::iterator collist_here = collist.begin();634 text_tarray::iterator collist_end = collist.end();635 while (collist_here != collist_end) {636 637 (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, logout);638 if (err == noError && (cinfo.buildDate > 0)) {639 640 text_tset::const_iterator t = collections.find (*collist_here);641 if (t == collections.end()) {collist_here++; continue;}642 643 (*rprotolist_here).p->get_filteroptions (*collist_here, frequest, fresponse, err, logout);644 if (err == noError) {645 646 FilterOption_tmap::const_iterator it;647 FilterOption_tmap::const_iterator end = fresponse.filterOptions.end();648 if (!index.empty()) {649 it = fresponse.filterOptions.find ("Index");650 if (it == end) {collist_here ++; continue;}651 text_tarray::const_iterator there = (*it).second.validValues.begin();652 text_tarray::const_iterator tend = (*it).second.validValues.end();653 while (there != tend) {654 if (*there == index) break;655 there ++;656 }657 if (there == tend) {collist_here++; continue;}658 }659 if (!subcollection.empty()) {660 it = fresponse.filterOptions.find ("Subcollection");661 if (it == end) {collist_here++; continue;}662 text_tarray::const_iterator there = (*it).second.validValues.begin();663 text_tarray::const_iterator tend = (*it).second.validValues.end();664 while (there != tend) {665 if (*there == subcollection) break;666 there ++;667 }668 if (there == tend) {collist_here++; continue;}669 }670 if (!language.empty()) {671 it = fresponse.filterOptions.find ("Language");672 if (it == end) {collist_here++; continue;}673 text_tarray::const_iterator there = (*it).second.validValues.begin();674 text_tarray::const_iterator tend = (*it).second.validValues.end();675 while (there != tend) {676 if (*there == language) break;677 there ++;678 }679 if (there == tend) {collist_here++; continue;}680 }681 682 // we've got a matching collection683 textout << "<input type=checkbox";684 685 text_tset::const_iterator t = collections.find (*collist_here);686 if (t != collections.end()) textout << " checked"; // already know this is true687 688 textout << outconvert689 << " name=cc value=\"" << *collist_here << "\">";690 691 if (!cinfo.collectionmeta["collectionname"].empty())692 textout << outconvert << disp << cinfo.collectionmeta["collectionname"];693 else694 textout << outconvert << *collist_here;695 696 textout << "<br>\n";697 698 }699 }700 collist_here ++;701 }702 }703 }704 rprotolist_here ++;705 }706 textout << outconvert << disp707 << "</td></tr></table></center>\n"708 << "</form>\n"709 << "_query:footer_\n";710 711 }712 713 544 bool queryaction::do_action (cgiargsclass &args, recptprotolistclass *protos, 714 545 browsermapclass *browsers, displayclass &disp, … … 716 547 ostream &logout) { 717 548 718 if (args["ccs"] == 1) { 719 // cross collection searching (we'll just borrow the el argument 720 // from extlinkaction for now - this will probably want to use 721 // a separate argument eventually) 722 // if (args["ccp"] != 1 && args["el"] != "direct") { 723 // display the cross collection search page 724 // output_ccp (args, protos, disp, outconvert, textout, logout); 725 // } else { 549 if (args["ccs"] == "1") { 550 if (!args["cc"].empty()) { 726 551 // query the selected collections 727 728 text_t::const_iterator b = args["cc"].begin(); 729 text_t::const_iterator e = args["cc"].end(); 730 if (!args["cc"].empty() && (findchar (b, e, ',') != e)) 731 if (!search_multiple_collections (args, protos, browsers, disp, outconvert, 732 textout, logout)) return false; 733 else return true; 552 text_t::const_iterator b = args["cc"].begin(); 553 text_t::const_iterator e = args["cc"].end(); 554 if (findchar (b, e, ',') != e) { 555 if (!search_multiple_collections (args, protos, browsers, disp, outconvert, 556 textout, logout)) return false; 557 return true; 558 } else { 559 if (!search_single_collection (args, args["cc"], protos, browsers, disp, 560 outconvert, textout, logout)) return false; 561 return true; 562 } 563 } 734 564 } 735 565 736 566 // simply query the current collection 737 if (!search_single_collection (args, protos, browsers, disp, outconvert, 738 textout, logout)) return false; 739 567 if (!search_single_collection (args, args["c"], protos, browsers, disp, 568 outconvert, textout, logout)) return false; 740 569 return true; 741 570 } … … 756 585 << "set for doing multiple query - will search current collection\n"; 757 586 textout << outconvert << disp << "_query:textwarningnocollections_\n"; 758 return search_single_collection (args, protos, browsers, disp,587 return search_single_collection (args, args["c"], protos, browsers, disp, 759 588 outconvert, textout, logout); 760 589 } … … 777 606 int numdocs = 0; 778 607 isapprox isApprox = Exact; 779 text_tset colnamedata;780 colnamedata.insert ("collectionname");781 608 782 609 format_querystring (formattedstring, args.getintarg("b")); … … 797 624 text_tarray::iterator col_end = collections.end(); 798 625 626 map<text_t, int, lttext_t> termfreqs; 799 627 while (col_here != col_end) { 800 628 … … 845 673 isApprox = response.isApprox; 846 674 847 text_t collectionname = *col_here;848 FilterResponse_t nresponse;849 if (get_info ("collection", *col_here, colnamedata, false, collectproto, nresponse, logout)) {850 if (!nresponse.docInfo[0].metadata["collectionname"].values[0].empty())851 collectionname = nresponse.docInfo[0].metadata["collectionname"].values[0];852 }853 854 675 TermInfo_tarray::const_iterator this_term = response.termInfo.begin(); 855 676 TermInfo_tarray::const_iterator end_term = response.termInfo.end(); 856 freqmsg += "<br><b>" + collectionname + "</b>: ";857 677 while (this_term != end_term) { 858 freqmsg += (*this_term).term + ": " + (*this_term).freq; 859 if ((this_term + 1) != end_term) 860 freqmsg += ", "; 678 termfreqs[(*this_term).term] += (*this_term).freq; 679 if ((col_here+1) == col_end) { 680 freqmsg += (*this_term).term + ": " + termfreqs[(*this_term).term]; 681 if ((this_term+1) != end_term) freqmsg += ", "; 682 } 861 683 this_term ++; 862 684 } … … 961 783 } 962 784 963 bool queryaction::search_single_collection (cgiargsclass &args, recptprotolistclass *protos,964 browsermapclass *browsers, displayclass &disp,965 outconvertclass &outconvert, ostream &textout,966 ostream & logout) {967 968 recptproto *collectproto = protos->getrecptproto ( args["c"], logout);785 bool queryaction::search_single_collection (cgiargsclass &args, const text_t &collection, 786 recptprotolistclass *protos, browsermapclass *browsers, 787 displayclass &disp, outconvertclass &outconvert, 788 ostream &textout, ostream &logout) { 789 790 recptproto *collectproto = protos->getrecptproto (collection, logout); 969 791 if (collectproto == NULL) { 970 logout << outconvert << "queryaction::search_single_collection: " << args["c"]792 logout << outconvert << "queryaction::search_single_collection: " << collection 971 793 << " collection has a NULL collectproto\n"; 972 794 return false; … … 980 802 ColInfoResponse_t cinfo; 981 803 comerror_t err; 982 collectproto->get_collectinfo ( args["c"], cinfo, err, logout);804 collectproto->get_collectinfo (collection, cinfo, err, logout); 983 805 984 806 browserclass *bptr = browsers->getbrowser (browsertype); … … 1003 825 format_querystring (formattedstring, args.getintarg("b")); 1004 826 set_queryfilter_options (request, formattedstring, args); 1005 collectproto->filter ( args["c"], request, response, err, logout);827 collectproto->filter (collection, request, response, err, logout); 1006 828 if (err != noError) { 1007 829 outconvertclass text_t2ascii; 1008 830 logout << text_t2ascii 1009 831 << "queryaction::search_single_collections: call to QueryFilter failed " 1010 << "for " << args["c"]<< " collection (" << get_comerror_string (err) << ")\n";832 << "for " << collection << " collection (" << get_comerror_string (err) << ")\n"; 1011 833 return false; 1012 834 } … … 1019 841 // output the results 1020 842 bool use_table = is_table_content (formatlistptr); 1021 bptr->output_section_group (response, args, "", 0, formatlistptr,843 bptr->output_section_group (response, args, collection, 0, formatlistptr, 1022 844 use_table, request.fields, request.getParents, 1023 845 collectproto, disp, outconvert, textout, logout); -
trunk/gsdl/src/recpt/queryaction.h
r757 r865 70 70 const FilterOption_t &option, displayclass &disp); 71 71 72 void output_ccp (cgiargsclass &args, recptprotolistclass *protos,73 displayclass &disp, outconvertclass &outconvert,74 ostream &textout, ostream &logout);75 76 77 72 bool search_multiple_collections (cgiargsclass &args, recptprotolistclass *protos, 78 73 browsermapclass *browsers, displayclass &disp, … … 80 75 ostream &logout); 81 76 82 bool search_single_collection (cgiargsclass &args, recptprotolistclass *protos,83 browsermapclass *browsers, displayclass &disp,84 outconvertclass &outconvert, ostream &textout,85 ostream & logout);77 bool search_single_collection (cgiargsclass &args, const text_t &collection, 78 recptprotolistclass *protos, browsermapclass *browsers, 79 displayclass &disp, outconvertclass &outconvert, 80 ostream &textout, ostream &logout); 86 81 87 82
Note:
See TracChangeset
for help on using the changeset viewer.