Changeset 20727


Ignore:
Timestamp:
2009-09-28T14:59:17+13:00 (15 years ago)
Author:
kjdon
Message:

added support for defaultlevel in collect.cfg, for mgpp and lucene. also added defaultindex for lucene

Location:
gsdl/trunk/runtime-src/src/colservr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/runtime-src/src/colservr/lucenequeryfilter.cpp

    r16947 r20727  
    4545  filtopt.type = FilterOption_t::enumeratedt;
    4646  filtopt.repeatable = FilterOption_t::onePerTerm;
     47  filtopt.defaultValue = "";
    4748  filterOptions["Level"] = filtopt;
    4849
     
    7576    text_tarray options;
    7677    indexfieldmap.gettoarray (options);
    77 
    78     text_tarray::const_iterator here = options.begin();
    79     text_tarray::const_iterator end = options.end();
    80     bool start = true;
    81     while (here !=end) {
    82       if (!(*here).empty()) {
    83     filterOptions["IndexField"].validValues.push_back(*here);
    84     if (start) {
    85       filterOptions["IndexField"].defaultValue = *here;
    86       start = false;
    87     }
    88       }
    89       ++here;
    90     }
     78    filterOptions["IndexField"].validValues = options;
     79  } else if (key == "levelmap") {
     80    levelmap.importmap (cfgline);
    9181  } else if (key == "indexlevels") {
    9282    text_tarray::const_iterator here = cfgline.begin();
    9383    text_tarray::const_iterator end = cfgline.end();
    94     bool first=true;
    9584    while (here != end) {
    9685      if (!(*here).empty()) {
    97     if (first) {
    98       first = false;
    99       // the default is the first value
    100       filterOptions["Level"].defaultValue = *here;
    101     }
    10286    filterOptions["Level"].validValues.push_back(*here);
    10387      }
     
    10690  } else if (key == "textlevel") {
    10791      ((lucenesearchclass *)textsearchptr)->set_text_level(cfgline[0]);
    108   }
    109  
    110 }
    111 
     92  } else if (key == "defaultindex") {
     93    indexfieldmap.from2to (cfgline[0], filterOptions["IndexField"].defaultValue);
     94  } else if (key == "defaultlevel") {
     95    levelmap.from2to (cfgline[0], filterOptions["Level"].defaultValue);
     96  }
     97 
     98}
     99
     100bool lucenequeryfilterclass::init (ostream &logout) {
     101 
     102  if (!queryfilterclass::init(logout)) {
     103    return false;
     104  }
     105 
     106  if (filterOptions["IndexField"].defaultValue.empty()) {
     107    // use first index in map as default if no default is set explicitly
     108    text_tarray fromarray;
     109    indexfieldmap.getfromarray(fromarray);
     110    if (fromarray.size()) {
     111      filterOptions["IndexField"].defaultValue = fromarray[0];
     112    }
     113  }
     114  if (filterOptions["Levels"].defaultValue.empty()) {
     115    // use first level as default if no default is set explicitly
     116    if (!filterOptions["Level"].validValues[0].empty())
     117      filterOptions["Levels"].defaultValue = filterOptions["Level"].validValues[0];
     118  }
     119
     120  return true;
     121}
    112122
    113123void lucenequeryfilterclass::filter(const FilterRequest_t &request,
  • gsdl/trunk/runtime-src/src/colservr/lucenequeryfilter.h

    r15558 r20727  
    3636
    3737  stringmap indexfieldmap;
     38  stringmap levelmap;
     39
    3840  bool full_text_browse (int filterRequestOptions);
    3941
     
    5052
    5153  void configure (const text_t &key, const text_tarray &cfgline);
    52 
     54  bool init (ostream &logout);
    5355  void filter (const FilterRequest_t &request,
    5456               FilterResponse_t &response,
  • gsdl/trunk/runtime-src/src/colservr/mgppqueryfilter.cpp

    r16445 r20727  
    4545  filtopt.type = FilterOption_t::enumeratedt;
    4646  filtopt.repeatable = FilterOption_t::onePerTerm;
     47  filtopt.defaultValue = "";
    4748  filterOptions["Level"] = filtopt;
    4849
     
    7172  if (key == "indexfieldmap") {
    7273    indexfieldmap.importmap (cfgline);
    73    
    74     // update the list of indexes in the filter information
    7574    text_tarray options;
    7675    indexfieldmap.gettoarray (options);
    7776    filterOptions["IndexField"].validValues = options;
    7877   
     78  } else if (key == "levelmap") {
     79    levelmap.importmap (cfgline);
    7980  } else if (key == "indexlevels") {
     81    filterOptions["Level"].validValues.erase(filterOptions["Level"].validValues.begin(), filterOptions["Level"].validValues.end());
    8082    text_tarray::const_iterator here = cfgline.begin();
    8183    text_tarray::const_iterator end = cfgline.end();
    82     bool first=true;
    83     filterOptions["Level"].validValues.erase(filterOptions["Level"].validValues.begin(), filterOptions["Level"].validValues.end());
    8484    while (here != end) {
    8585      if (!(*here).empty()) {
    86     if (first) {
    87       first = false;
    88       // the default is the first value
    89       filterOptions["Level"].defaultValue = *here;
    90     }
    9186    filterOptions["Level"].validValues.push_back(*here);
    9287      }
     
    9994  } else if (key == "defaultindex") { // used for fields in mgpp
    10095    indexfieldmap.from2to (cfgline[0], filterOptions["IndexField"].defaultValue);
     96  } else if (key == "defaultlevel") {
     97    levelmap.from2to (cfgline[0], filterOptions["Level"].defaultValue);
    10198  }
    10299 
     
    117114    }
    118115  }
     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
    119122  return true;
    120123}
  • gsdl/trunk/runtime-src/src/colservr/mgppqueryfilter.h

    r15595 r20727  
    3636
    3737  stringmap indexfieldmap;
     38  stringmap levelmap;
     39
    3840  bool full_text_browse (int filterRequestOptions);
    3941
Note: See TracChangeset for help on using the changeset viewer.