- Timestamp:
- 2013-03-12T14:37:44+13:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/colservr/mgppqueryfilter.cpp
r20727 r27064 1 1 /********************************************************************** 2 2 * 3 * queryfilter.cpp --3 * mgppqueryfilter.cpp -- 4 4 * Copyright (C) 1999 The New Zealand Digital Library Project 5 5 * … … 28 28 #include "mgppsearch.h" 29 29 30 /////////////////////////////////31 // functions for queryfilterclass32 /////////////////////////////////33 34 35 30 mgppqueryfilterclass::mgppqueryfilterclass () 36 : queryfilterclass() { 37 38 39 FilterOption_t filtopt; 40 41 // -- onePerTerm Level enumerated 42 // likely to be Doc, Sec, Para, but we dont assume anything now 43 filtopt.clear(); 44 filtopt.name = "Level"; 45 filtopt.type = FilterOption_t::enumeratedt; 46 filtopt.repeatable = FilterOption_t::onePerTerm; 47 filtopt.defaultValue = ""; 48 filterOptions["Level"] = filtopt; 49 50 // -- IndexField, enumerated, used to list available fields 51 filtopt.clear(); 52 filtopt.name = "IndexField"; 53 filtopt.type = FilterOption_t::enumeratedt; 54 filtopt.repeatable = FilterOption_t::onePerTerm; 55 filtopt.defaultValue = ""; 56 filterOptions["IndexField"] = filtopt; 31 : fieldedqueryfilterclass() { 57 32 58 33 } … … 62 37 63 38 64 //whether a query is a full text browse65 bool mgppqueryfilterclass::full_text_browse (int filterRequestOptions) {66 return (filterRequestOptions & FRfullTextBrowse);67 }68 39 69 40 void mgppqueryfilterclass::configure (const text_t &key, const text_tarray &cfgline) { 70 queryfilterclass::configure(key, cfgline); 71 72 if (key == "indexfieldmap") { 73 indexfieldmap.importmap (cfgline); 74 text_tarray options; 75 indexfieldmap.gettoarray (options); 76 filterOptions["IndexField"].validValues = options; 77 78 } else if (key == "levelmap") { 79 levelmap.importmap (cfgline); 80 } else if (key == "indexlevels") { 81 filterOptions["Level"].validValues.erase(filterOptions["Level"].validValues.begin(), filterOptions["Level"].validValues.end()); 82 text_tarray::const_iterator here = cfgline.begin(); 83 text_tarray::const_iterator end = cfgline.end(); 84 while (here != end) { 85 if (!(*here).empty()) { 86 filterOptions["Level"].validValues.push_back(*here); 87 } 88 ++here; 89 } 90 } else if (key == "textlevel") { 91 ((mgppsearchclass *)textsearchptr)->set_text_level(cfgline[0]); 41 fieldedqueryfilterclass::configure(key, cfgline); 42 43 if (key == "textlevel") { 44 ((mgppsearchclass *)textsearchptr)->set_text_level(cfgline[0]); 92 45 } else if (key == "indexstem") { 93 46 ((mgppsearchclass *)textsearchptr)->set_indexstem (cfgline[0]); 94 } else if (key == "defaultindex") { // used for fields in mgpp 95 indexfieldmap.from2to (cfgline[0], filterOptions["IndexField"].defaultValue); 96 } else if (key == "defaultlevel") { 97 levelmap.from2to (cfgline[0], filterOptions["Level"].defaultValue); 98 } 99 100 } 101 102 bool mgppqueryfilterclass::init (ostream &logout) { 103 104 if (!queryfilterclass::init(logout)) { 105 return false; 106 } 107 108 if (filterOptions["IndexField"].defaultValue.empty()) { 109 // use first index in map as default if no default is set explicitly 110 text_tarray fromarray; 111 indexfieldmap.getfromarray(fromarray); 112 if (fromarray.size()) { 113 filterOptions["IndexField"].defaultValue = fromarray[0]; 114 } 115 } 116 if (filterOptions["Levels"].defaultValue.empty()) { 117 // use first level as default if no default is set explicitly 118 if (!filterOptions["Level"].validValues[0].empty()) 119 filterOptions["Levels"].defaultValue = filterOptions["Level"].validValues[0]; 120 } 121 122 return true; 47 } 123 48 } 124 49 … … 163 88 // get the query parameters 164 89 int startresults, endresults; 165 text_t phrasematch; // not used here any more166 90 vector<queryparamclass> queryfilterparams; 167 91 parse_query_params (request, queryfilterparams, startresults, 168 endresults, phrasematch,logout);92 endresults, logout); 169 93 170 94 … … 261 185 // get the query parameters 262 186 int startresults, endresults; 263 text_t phrasematch; // not used here any more, just have it so can use264 // parse_query_params function265 266 187 vector<queryparamclass> queryfilterparams; 267 188 parse_query_params (request, queryfilterparams, startresults, 268 endresults, phrasematch,logout);189 endresults, logout); 269 190 270 191 vector<queryparamclass>::const_iterator query_here = queryfilterparams.begin();
Note:
See TracChangeset
for help on using the changeset viewer.