Changeset 226


Ignore:
Timestamp:
1999-04-07T10:20:35+12:00 (25 years ago)
Author:
rjmcnab
Message:

Got browsefilter working.

Location:
trunk/gsdl/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/colservr/collectserver.cpp

    r220 r226  
     1
    12/**********************************************************************
    23 *
     
    1213/*
    1314   $Log$
     15   Revision 1.6  1999/04/06 22:20:29  rjmcnab
     16   Got browsefilter working.
     17
    1418   Revision 1.5  1999/03/31 23:44:44  rjmcnab
    1519   Altered the protocol so that the metadata is part of the filter.
     
    4852// it contains. The configuration should take place just before initialisation.
    4953void collectserver::configure (const text_t &key, const text_tarray &cfgline) {
    50   if (key == "indexmap") {
    51     configinfo.indexmap.importmap (cfgline);
    52 
    53     // update the list of indexes in the filter information
    54     text_tarray options;
    55     configinfo.indexmap.gettoarray (options);
    56     update_enumfiltopt ("Index", options);
    57 
    58   } else if (key == "subcollectionmap") {
    59     configinfo.subcollectionmap.importmap (cfgline);
    60 
    61     // update the list of subcollections in the filter information
    62     text_tarray options;
    63     configinfo.subcollectionmap.gettoarray (options);
    64     update_enumfiltopt ("Subcollection", options);
    65 
    66   } else if (key == "languagemap") {
    67     configinfo.languagemap.importmap (cfgline);
    68 
    69     // update the list of languages in the filter information
    70     text_tarray options;
    71     configinfo.languagemap.gettoarray (options);
    72     update_enumfiltopt ("Language", options);
    73  
    74   } else if (cfgline.size() >= 1) {
     54  if (cfgline.size() >= 1) {
    7555    const text_t &value = cfgline[0];
    7656    if (key == "gsdlhome") configinfo.gsdlhome = value;
     
    9272    else if (key == "numwords") collectinfo.numWords = value.getint();
    9373    else if (key == "numbytes") collectinfo.numBytes = value.getint();
    94 
    95     else if ((key == "filteroptdefault") && (cfgline.size() == 2)) {
    96       // set this default for each type of filter
    97       //      FilterDescript_tmap::iterator filteropthere = filterinfo.filterOptions.begin();
    98       //      FilterDescript_tmap::iterator filteroptend = filterinfo.filterOptions.end();
    99 
    100       //      while (filteropthere != filteroptend) {
    101       //    // see if this filter has an option with this name
    102       //    FilterOption_tmap &fotm = (*filteropthere).second.filterOptions;
    103       //    if (fotm.find(cfgline[0]) != fotm.end()) {
    104       //      (*(fotm.find(cfgline[0]))).second.defaultValue = cfgline[1];
    105       //    }
    106    
    107       //    filteropthere++;
    108       //      }
    109     }
     74  }
     75
     76  // configure the filters
     77  filtermapclass::iterator filter_here = filters.begin();
     78  filtermapclass::iterator filter_end = filters.end();
     79  while (filter_here != filter_end) {
     80    assert ((*filter_here).second.f != NULL);
     81    if ((*filter_here).second.f != NULL)
     82      (*filter_here).second.f->configure(key, cfgline);
     83
     84    filter_here++;
     85  }
     86
     87  // configure the sources
     88  sourcelistclass::iterator source_here = sources.begin();
     89  sourcelistclass::iterator source_end = sources.end();
     90  while (source_here != source_end) {
     91    assert ((*source_here).s != NULL);
     92    if ((*source_here).s != NULL)
     93      (*source_here).s->configure(key, cfgline);
     94   
     95    source_here++;
    11096  }
    11197}
     
    118104
    119105
    120 bool collectserver::init (ostream &/*logout*/) {
     106bool collectserver::init (ostream &logout) {
     107  // init the filters
     108  filtermapclass::iterator filter_here = filters.begin();
     109  filtermapclass::iterator filter_end = filters.end();
     110  while (filter_here != filter_end) {
     111    assert ((*filter_here).second.f != NULL);
     112    if (((*filter_here).second.f != NULL) &&
     113    !(*filter_here).second.f->init(logout)) return false;
     114   
     115    filter_here++;
     116  }
     117
     118  // init the sources
     119  sourcelistclass::iterator source_here = sources.begin();
     120  sourcelistclass::iterator source_end = sources.end();
     121  while (source_here != source_end) {
     122    assert ((*source_here).s != NULL);
     123    if (((*source_here).s != NULL) &&
     124    !(*source_here).s->init(logout)) return false;
     125   
     126    source_here++;
     127  }
     128
    121129  return true;
    122130}
     
    129137}
    130138
    131 void collectserver::get_filterinfo (InfoFiltersResponse_t &/*response*/,
     139void collectserver::get_filterinfo (InfoFiltersResponse_t &response,
    132140                    comerror_t &err, ostream &/*logout*/) {
    133   err = protocolError;
    134 }
    135 
    136 void collectserver::get_filteroptions (const InfoFilterOptionsRequest_t &/*request*/,
     141  response.clear ();
     142
     143  // get a list of filter names
     144  filtermapclass::iterator filter_here = filters.begin();
     145  filtermapclass::iterator filter_end = filters.end();
     146  while (filter_here != filter_end) {
     147    response.filterNames.insert ((*filter_here).first);
     148    filter_here++;
     149  }
     150
     151  err = noError;
     152}
     153
     154void collectserver::get_filteroptions (const InfoFilterOptionsRequest_t &request,
    137155                       InfoFilterOptionsResponse_t &response,
    138                        comerror_t &err, ostream &/*logout*/) {
    139   response = filterinfo;
    140   err = noError;
     156                       comerror_t &err, ostream &logout) {
     157  outconvertclass text_t2ascii;
     158
     159  filterclass *thisfilter = filters.getfilter(request.filterName);
     160  if (thisfilter != NULL) {
     161    thisfilter->get_filteroptions (response, err, logout);
     162  } else {
     163    response.clear ();
     164    err = protocolError;
     165    logout << text_t2ascii << "Protocol Error: filter options requested for non-existent\n"
     166       << "filter \"" << request.filterName << "\".\n\n";
     167  }
    141168}
    142169
    143170void collectserver::filter (const FilterRequest_t &request,
    144171                FilterResponse_t &response,
    145                 comerror_t &err, ostream &/*logout*/) {
     172                comerror_t &err, ostream &logout) {
     173  outconvertclass text_t2ascii;
     174
    146175  response.clear();
    147176
    148   if (request.filterName == "QueryFilter") {
    149     // return documents
    150     response.numDocs = 2;
    151     response.isApprox = false;
    152    
    153     // fill in the term info
    154     TermInfo_t terminfo;
    155     terminfo.term = "the";
    156     terminfo.freq = 2;
    157     terminfo.matchTerms.push_back ("the");
    158     terminfo.matchTerms.push_back ("The");
    159     response.termInfo.push_back (terminfo);
    160 
    161     // fill in the document info
    162     ResultDocInfo_t resultdoc;
    163     resultdoc.OID = "HASH1234";
    164     resultdoc.ranking = 8000;
    165     resultdoc.docFreq.push_back (10);
    166     response.docInfo.push_back (resultdoc);
    167 
    168     resultdoc.clear();
    169     resultdoc.OID = "HASH2345";
    170     resultdoc.ranking = 5000;
    171     resultdoc.docFreq.push_back (5);
    172     response.docInfo.push_back (resultdoc);
    173 
    174   } else if (request.filterName == "BrowseFilter") {
    175     // return documents
    176     response.numDocs = 2;
    177     response.isApprox = false;
    178    
    179     // fill in the document info
    180     ResultDocInfo_t resultdoc;
    181     resultdoc.OID = "HASH2345";
    182     response.docInfo.push_back (resultdoc);
    183 
    184     resultdoc.clear();
    185     resultdoc.OID = "HASH3456";
    186     response.docInfo.push_back (resultdoc);
     177  filterclass *thisfilter = filters.getfilter(request.filterName);
     178  if (thisfilter != NULL) {
     179    // filter the data
     180    thisfilter->filter (request, response, err, logout);
     181
     182    // fill in the metadata for each of the OIDs (if it is requested)
     183    if (request.filterResultOptions & FRmetadata) {
     184      ResultDocInfo_tarray::iterator resultdoc_here = response.docInfo.begin();
     185      ResultDocInfo_tarray::iterator resultdoc_end = response.docInfo.end();
     186      while (resultdoc_here != resultdoc_end) {
     187    // try each of the sources in turn
     188    sourcelistclass::iterator source_here = sources.begin();
     189    sourcelistclass::iterator source_end = sources.end();
     190    while (source_here != source_end) {
     191      assert ((*source_here).s != NULL);
     192      if (((*source_here).s != NULL) &&
     193          ((*source_here).s->get_metadata(request.requestParams, request.refParams,
     194                          request.fields, (*resultdoc_here).OID,
     195                          (*resultdoc_here).metadata, err, logout))) {
     196        if (err != noError) return;
     197        break;
     198      }
     199     
     200      source_here++;
     201    }
     202   
     203    resultdoc_here++;
     204      }
     205    }
    187206   
    188207  } else {
     208    response.clear ();
    189209    err = protocolError;
    190     return;
    191   }
    192 
     210    logout << text_t2ascii << "Protocol Error: filter options requested for non-existent\n"
     211       << "filter \"" << request.filterName << "\".\n\n";
     212  }
     213 
    193214  err = noError;
    194215}
    195216
    196217
    197 void collectserver::update_enumfiltopt (text_t /*optionname*/,
    198                     const text_tarray &/*options*/) {
    199   // update this option for each of the filters
    200   //  FilterDescript_tmap::iterator filteropthere = filterinfo.filterOptions.begin();
    201   //  FilterDescript_tmap::iterator filteroptend = filterinfo.filterOptions.end();
    202  
    203   //  while (filteropthere != filteroptend) {
    204   //    // see if this filter has an option with this name
    205   //    FilterOption_tmap &fotm = (*filteropthere).second.filterOptions;
    206   //    FilterOption_tmap::iterator fotm_iterator = fotm.find(optionname);
    207   //    if (fotm_iterator != fotm.end()) {
    208   //      // set the valid values to be the options
    209   //      (*fotm_iterator).second.validValues = options;
    210 
    211   //      // make sure the default is a valid value
    212   //      (*fotm_iterator).second.check_defaultValue();
    213   //    }
    214    
    215   //    filteropthere++;
    216   //  }
    217 }
    218218
    219219
  • trunk/gsdl/src/colservr/collectserver.h

    r220 r226  
    1717#include "text_t.h"
    1818#include "comtypes.h"
    19 #include "maptools.h"
     19#include "filter.h"
     20#include "source.h"
    2021
    2122#if defined(GSDL_USE_OBJECTSPACE)
     
    4041  text_t collection;
    4142  text_t collectdir;
    42   stringmap indexmap;
    43   stringmap subcollectionmap;
    44   stringmap languagemap;
    4543};
    4644
     
    5048  colservrconf configinfo;
    5149  ColInfoResponse_t collectinfo;
    52   InfoFilterOptionsResponse_t filterinfo;
     50
     51  filtermapclass filters;
     52  sourcelistclass sources;
    5353
    5454public:
    5555  collectserver ();
    5656  virtual ~collectserver ();
     57
     58  // add_filter makes another filter available to the collection server
     59  // the filter remains the property of the calling code and that
     60  // code should destroy the filter after the collection server has been
     61  // destroyed.
     62  void add_filter (filterclass *thefilter) {filters.addfilter(thefilter);}
     63  filtermapclass *get_filtermap_ptr () {return &filters;}
     64
     65  // add_source makes another source available to the collection server
     66  // the source remains the property of the calling code and that
     67  // code should destroy the source after the collection server has been
     68  // destroyed.
     69  void add_source (sourceclass *thesource) {sources.addsource(thesource);}
     70  sourcelistclass *get_sourcelist_ptr () {return &sources;}
    5771
    5872  // configure should be called for each line in the
     
    8397               FilterResponse_t &response,
    8498               comerror_t &err, ostream &logout);
    85 
    86 protected:
    87   void update_enumfiltopt (text_t optionname, const text_tarray &options);
    8899};
    89100
  • trunk/gsdl/src/colservr/filter.cpp

    r220 r226  
    1212/*
    1313   $Log$
     14   Revision 1.3  1999/04/06 22:20:30  rjmcnab
     15   Got browsefilter working.
     16
    1417   Revision 1.2  1999/03/31 23:44:46  rjmcnab
    1518   Altered the protocol so that the metadata is part of the filter.
     
    2225
    2326#include "filter.h"
     27#include "fileutil.h"
    2428#include <assert.h>
    2529
     
    3438
    3539// configure should be called once for each configuration line
    36 // default does nothing
    37 void filterclass::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) {
     40// default configures the default filter options
     41void filterclass::configure (const text_t &key, const text_tarray &cfgline) {
     42  if (cfgline.size() >= 1) {
     43    const text_t &value = cfgline[0];
     44
     45    if (key == "collection") collection = value;
     46    else if (key == "collectdir") collectdir = value;
     47    else if (key == "gsdlhome") gsdlhome = value;
     48    else if ((key == "filteroptdefault") && (cfgline.size() == 2)) {
     49      // see if this filter has an option with this name
     50      FilterOption_tmap::iterator thisfilteroption =
     51    filterOptions.find(cfgline[0]);
     52      if (thisfilteroption != filterOptions.end())
     53    (*thisfilteroption).second.defaultValue = cfgline[1];
     54    }
     55  }
    3856}
    3957
    4058// init should be called after all the configuration is done but
    4159// before any other methods are called
    42 // default does nothing
     60// default checks all the filter option defaults
    4361bool filterclass::init (ostream &/*logout*/) {
     62  // check all the filter defaults
     63  FilterOption_tmap::iterator filteroption_here = filterOptions.begin();
     64  FilterOption_tmap::iterator filteroption_end = filterOptions.end();
     65  while (filteroption_here != filteroption_end) {
     66    (*filteroption_here).second.check_defaultValue ();
     67   
     68    filteroption_here++;
     69  }
     70
     71  // get the collection directory name
     72  if (collectdir.empty()) {
     73    collectdir = filename_cat (gsdlhome, "collect", collection);
     74  }
     75 
    4476  return true;
    4577}
     
    5183}
    5284
     85// returns the current filter options
     86void filterclass::get_filteroptions (InfoFilterOptionsResponse_t &response,
     87                     comerror_t &err, ostream &/*logout*/) {
     88  response.clear();
     89  response.filterOptions = filterOptions;
     90  err = noError;
     91}
     92
    5393// default returns nothing
    54 void filterclass::get_filteroptions (InfoFilterOptionsResponse_t &response) {
    55   response.clear();
    56 }
    57 
    58 // default returns nothing
    59 void filterclass::filter (const FilterRequest_t &/*request*/,
     94void filterclass::filter (const FilterRequest_t &request,
    6095              FilterResponse_t &response,
    6196              comerror_t &err, ostream &/*logout*/) {
     97  ResultDocInfo_t resultdoc;
     98
    6299  response.clear();
     100
     101  if ((request.filterResultOptions & FROID) ||
     102      (request.filterResultOptions & FRmetadata)) {
     103    // copy the OIDs from the request to the response
     104    text_tset::const_iterator here = request.docSet.begin();
     105    text_tset::const_iterator end = request.docSet.end();
     106    while (here != end) {
     107      resultdoc.OID = (*here);
     108      response.docInfo.push_back(resultdoc);
     109
     110      here++;
     111    }
     112  }
     113
     114  response.numDocs = response.docInfo.size();
     115  response.isApprox = false;
    63116  err = noError;
    64117}
     
    94147}
    95148
     149
     150
     151
     152// some useful functions for dealing with document sets
     153
     154// returns -1 if t1 is a child of t2
     155// returns 0  if t1 and t2 are not parent-child related
     156// returns 1  if t1 is a parent of t2
     157int child_compare (const text_t &t1, const text_t &t2) {
     158  text_t::const_iterator t1_here = t1.begin();
     159  text_t::const_iterator t1_end = t1.end();
     160  text_t::const_iterator t2_here = t2.begin();
     161  text_t::const_iterator t2_end = t2.end();
     162
     163  while ((t1_here != t1_end) && (t2_here != t2_end)) {
     164    if (*t1_here != *t2_here) return 0; // unrelated
     165    t1_here++;
     166    t2_here++;
     167  }
     168
     169  if ((t1_here == t1_end) && (t2_here == t2_end)) return 0; // equal
     170  if (t1_here != t1_end) {
     171    if (*t1_here == '.') return -1; // t1 is child
     172    else return 0; // unrelated
     173  }
     174
     175  if (t2_here != t2_end) {
     176    if (*t2_here == '.') return 1; // t2 is child
     177    else return 0; // unrelated
     178  }
     179
     180  return 0; // shouldn't get here...
     181}
     182
     183// intersect places the result in set1
     184void intersect (text_tset &set1, const text_tset &set2) {
     185  text_tset resultset;
     186  int childcomp = 0;
     187
     188  text_tset::const_iterator set1_here = set1.begin();
     189  text_tset::const_iterator set1_end = set1.end();
     190  text_tset::const_iterator set2_here = set2.begin();
     191  text_tset::const_iterator set2_end = set2.end();
     192  while ((set1_here != set1_end) && (set2_here != set2_end)) {
     193    if (*set1_here == *set2_here) {
     194      // equal
     195      resultset.insert (*set1_here);
     196      set1_here++;
     197      set2_here++;
     198
     199    } else if ((childcomp=child_compare(*set1_here, *set2_here)) != 0) {
     200      if (childcomp < 0) {
     201    // set1_here is child
     202    resultset.insert (*set1_here);
     203    set1_here++;
     204      } else {
     205    // set2_here is child
     206    resultset.insert (*set2_here);
     207    set2_here++;
     208      }
     209
     210    } else if (*set1_here < *set2_here) {
     211      // set1 is less
     212      set1_here++;
     213
     214    } else {
     215      // set2 is less
     216      set2_here++;
     217    }
     218  }
     219
     220  set1 = resultset;
     221}
  • trunk/gsdl/src/colservr/filter.h

    r220 r226  
    2020
    2121class filterclass {
     22protected:
     23  text_t gsdlhome;
     24  text_t collection;
     25  text_t collectdir;
     26
     27  FilterOption_tmap filterOptions;
     28
    2229public:
    2330  filterclass ();
     
    2532
    2633  // configure should be called once for each configuration line
     34  // default configures the default filter options
    2735  virtual void configure (const text_t &key, const text_tarray &cfgline);
    2836
    2937  // init should be called after all the configuration is done but
    3038  // before any other methods are called
     39  // default checks all the filter option defaults
    3140  virtual bool init (ostream &logout);
    3241
     
    3443  virtual text_t get_filter_name ();
    3544
    36   virtual void get_filteroptions (InfoFilterOptionsResponse_t &response);
     45  // returns the current filter options
     46  virtual void get_filteroptions (InfoFilterOptionsResponse_t &response,
     47                  comerror_t &err, ostream &logout);
    3748
    3849  virtual void filter (const FilterRequest_t &request,
     
    96107
    97108
     109
     110// some useful functions for dealing with document sets
     111
     112// intersect places the result in set1
     113void intersect (text_tset &set1, const text_tset &set2);
     114
    98115#endif
  • trunk/gsdl/src/colservr/infodbclass.cpp

    r216 r226  
    1212/*
    1313   $Log$
     14   Revision 1.2  1999/04/06 22:20:31  rjmcnab
     15   Got browsefilter working.
     16
    1417   Revision 1.1  1999/03/30 05:10:07  rjmcnab
    1518   Initial revision.
     
    5861
    5962
    60 // returns 0 if failed, 1 if opened
    61 int gdbmclass::opendatabase (const text_t &filename) {
     63// returns true if opened
     64bool gdbmclass::opendatabase (const text_t &filename) {
    6265  text_t data_location;
    6366  int block_size = 0;
    6467 
    6568  if (gdbmfile != NULL) {
    66     if (openfile == filename) return 1;
     69    if (openfile == filename) return true;
    6770    else closedatabase ();
    6871  }
     
    9093}
    9194
    92 // returns 0 on success, -1 on failure
    93 int gdbmclass::getinfo (text_t key, infodbclass &info) {
     95// returns true on success
     96bool gdbmclass::getinfo (text_t key, infodbclass &info) {
    9497  text_t data;
    95 
    96   if (!getkeydata (key, data)) return -1;
     98 
     99  if (!getkeydata (key, data)) return false;
    97100  text_t::iterator here = data.begin ();
    98101  text_t::iterator end = data.end ();
    99 
     102 
    100103  text_t ikey, ivalue;
    101104  info.clear (); // reset info
    102 
     105 
    103106  while (getinfoline(here, end, ikey, ivalue)) {
    104107    info[ikey] = ivalue;
    105108  }
    106109 
    107   return 0;
     110  return true;
    108111}
    109112
    110 int gdbmclass::exists (text_t key) {
     113// returns true if exists
     114bool gdbmclass::exists (text_t key) {
    111115  text_t data;
    112116  return getkeydata (key, data);
    113117}
    114118
    115 int gdbmclass::getkeydata (text_t key, text_t &data) {
     119// returns true on success
     120bool gdbmclass::getkeydata (text_t key, text_t &data) {
    116121  datum key_data;
    117122  datum return_data;
    118123
    119   if (gdbmfile == NULL) return 0;
    120 
     124  if (gdbmfile == NULL) return false;
     125 
    121126  // get a utf-8 encoded c string of the unicode key
    122127  key_data.dptr = (to_utf8(key)).getcstr();
    123128  if (key_data.dptr == NULL) {
    124129    if (logout != NULL) (*logout) << "gdbmclass: out of memory\n";
    125     return 0;
     130    return false;
    126131  }
    127132  key_data.dsize = strlen (key_data.dptr);
    128 
     133 
    129134  // fetch the result
    130135  return_data = gdbm_fetch (gdbmfile, key_data);
    131136  delete key_data.dptr;
    132 
    133   if (return_data.dptr == NULL) return 0;
     137 
     138  if (return_data.dptr == NULL) return false;
    134139
    135140  data.setcarr (return_data.dptr, return_data.dsize);
     
    137142  data = to_uni(data);  // convert to unicode
    138143
    139   return 1;
     144  return true;
    140145}
    141146
    142 int gdbmclass::getinfoline (text_t::iterator &here, text_t::iterator end,
    143                 text_t &key, text_t &value) {
     147// returns true on success
     148bool gdbmclass::getinfoline (text_t::iterator &here, text_t::iterator end,
     149                 text_t &key, text_t &value) {
    144150  key.clear();
    145151  value.clear();
     
    149155
    150156  // get the '<'
    151   if (here == end || *here != '<') return 0;
     157  if (here == end || *here != '<') return false;
    152158  here++;
    153159 
     
    159165 
    160166  // get the '>'
    161   if (here == end || *here != '>') return 0;
     167  if (here == end || *here != '>') return false;
    162168  here++;
    163169 
     
    181187  }
    182188
    183   return 1;
     189  return true;
    184190}
    185191
  • trunk/gsdl/src/colservr/infodbclass.h

    r216 r226  
    8383  ~gdbmclass() {};
    8484 
    85   // returns 0 if failed, 1 if opened
    86   int opendatabase (const text_t &filename);
     85  // returns true if opened
     86  bool opendatabase (const text_t &filename);
    8787  void closedatabase ();
    8888
    89   // returns 0 on success, -1 on failure
    90   int getinfo (text_t key, infodbclass &info);
     89  // returns true on success
     90  bool getinfo (text_t key, infodbclass &info);
    9191  void setlogout (ostream *thelogout) {logout = thelogout;}
    92   int exists (text_t key);
     92
     93  // returns true if exists
     94  bool exists (text_t key);
    9395
    9496protected:
     
    9799  ostream *logout;
    98100 
    99   int getkeydata (text_t key, text_t &data);
    100   int getinfoline (text_t::iterator &here, text_t::iterator end,
     101  // returns true on success
     102  bool getkeydata (text_t key, text_t &data);
     103
     104  // returns true on success
     105  bool getinfoline (text_t::iterator &here, text_t::iterator end,
    101106           text_t &key, text_t &value);
    102107};
  • trunk/gsdl/src/colservr/mgsearch.h

    r138 r226  
    2525// appear within the index directory) and real indexes (indexes as they
    2626// appear within the collect.cfg file) and mappings between them.
     27
     28// all these functions can go when we don't need src/library any more
     29
    2730void getdirindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
    2831               const text_tarray &languagemap, const text_t &dirindex,
     
    4548bool isdoclevelindex (const text_t &realindex);
    4649text_t getdoclevelindex (const text_tarray &indexmap);
     50
     51
    4752
    4853class mgsearchclass {
  • trunk/gsdl/src/colservr/source.cpp

    r219 r226  
    1212/*
    1313   $Log$
     14   Revision 1.2  1999/04/06 22:20:32  rjmcnab
     15   Got browsefilter working.
     16
    1417   Revision 1.1  1999/03/31 23:43:40  rjmcnab
    1518   Initial revision
     
    4245}
    4346
    44 // default does nothing
    45 //void sourceclass::get_metadata (const MetadataRequest_t &/*request*/,
    46 //              MetadataResponse_t &response,
    47 //              comerror_t &err, ostream &/*logout*/) {
    48 //  response.clear();
    49 //  err = noError;
    50 //}
     47// get_metadata fills out the metadata if possible, if it is not responsable
     48// for the given OID then it will return false.
     49bool sourceclass::get_metadata (const text_t &/*requestParams*/, const text_t &/*refParams*/,
     50                const text_tarray &/*fields*/, const text_t &/*OID*/,
     51                MetadataInfo_tarray &metadata,
     52                comerror_t &err, ostream &/*logout*/) {
     53  metadata.erase(metadata.begin(), metadata.end());
     54  err = noError;
     55
     56  return false;
     57}
    5158
    5259
     
    5562// should not be deleted until it is removed from this list.
    5663void sourcelistclass::addsource (sourceclass *thesource) {
    57   // can't add a protocol that doesn't exist
     64  // can't add a source that doesn't exist
    5865  assert (thesource != NULL);
    5966  if (thesource == NULL) return;
  • trunk/gsdl/src/colservr/source.h

    r219 r226  
    3030  // before any other methods are called
    3131  virtual bool init (ostream &logout);
    32   /* // needs some work
    33   virtual void get_metadata (const MetadataRequest_t &request,
    34                  MetadataResponse_t &response,
     32
     33  // get_metadata fills out the metadata if possible, if it is not responsable
     34  // for the given OID then it will return false.
     35  virtual bool get_metadata (const text_t &requestParams, const text_t &refParams,
     36                 const text_tarray &fields, const text_t &OID,
     37                 MetadataInfo_tarray &metadata,
    3538                 comerror_t &err, ostream &logout);
    36   */
    3739};
    3840
  • trunk/gsdl/src/recpt/Makefile

    r220 r226  
    4242
    4343COLSERVRHEADERS = infodbclass.h mgq.h mgsearch.h querycache.h queryinfo.h \
    44                   collectserver.h colservrconfig.h maptools.h filter.h source.h
     44                  collectserver.h colservrconfig.h maptools.h filter.h \
     45                  source.h browsefilter.h queryfilter.h
    4546
    4647LIBRARYHEADERS = $(COLSERVRHEADERS) \
     
    5859
    5960COLSERVRSOURCES = infodbclass.cpp mgq.c mgsearch.cpp querycache.cpp queryinfo.cpp \
    60                   collectserver.cpp colservrconfig.cpp maptools.cpp filter.cpp source.cpp
     61                  collectserver.cpp colservrconfig.cpp maptools.cpp filter.cpp \
     62                  source.cpp browsefilter.cpp queryfilter.cpp
    6163
    6264LIBRARYSOURCES = $(COLSERVRSOURCES) \
     
    7476
    7577COLSERVROBJECTS = infodbclass.o mgq.o mgsearch.o querycache.o queryinfo.o \
    76                   collectserver.o colservrconfig.o maptools.o filter.o source.o
     78                  collectserver.o colservrconfig.o maptools.o filter.o \
     79                  source.o browsefilter.o queryfilter.o
    7780
    7881LIBRARYOBJECTS = $(COLSERVROBJECTS) \
     
    212215queryinfo.o: ../../lib/text_t.h
    213216collectserver.o: collectserver.h ../../lib/gsdlconf.h ../../lib/site.h
    214 collectserver.o: ../../lib/text_t.h comtypes.h maptools.h
     217collectserver.o: ../../lib/text_t.h comtypes.h filter.h source.h
    215218colservrconfig.o: colservrconfig.h ../../lib/gsdlconf.h ../../lib/site.h
    216 colservrconfig.o: ../../lib/text_t.h collectserver.h comtypes.h maptools.h
    217 colservrconfig.o: ../../lib/fileutil.h ../../lib/cfgread.h
     219colservrconfig.o: ../../lib/text_t.h collectserver.h comtypes.h filter.h
     220colservrconfig.o: source.h ../../lib/fileutil.h ../../lib/cfgread.h
    218221maptools.o: maptools.h ../../lib/gsdlconf.h ../../lib/site.h
    219222maptools.o: ../../lib/text_t.h
    220223filter.o: filter.h ../../lib/gsdlconf.h ../../lib/site.h ../../lib/text_t.h
    221 filter.o: comtypes.h
     224filter.o: comtypes.h ../../lib/fileutil.h
    222225source.o: source.h ../../lib/gsdlconf.h ../../lib/site.h ../../lib/text_t.h
    223226source.o: comtypes.h
     227browsefilter.o: browsefilter.h ../../lib/gsdlconf.h ../../lib/site.h
     228browsefilter.o: ../../lib/text_t.h comtypes.h filter.h infodbclass.h
     229browsefilter.o: ../../lib/fileutil.h
     230queryfilter.o: queryfilter.h ../../lib/gsdlconf.h ../../lib/site.h
     231queryfilter.o: ../../lib/text_t.h comtypes.h filter.h infodbclass.h
     232queryfilter.o: maptools.h ../../lib/fileutil.h
    224233nullproto.o: nullproto.h ../../lib/gsdlconf.h ../../lib/site.h
    225 nullproto.o: collectserver.h ../../lib/text_t.h comtypes.h maptools.h
     234nullproto.o: collectserver.h ../../lib/text_t.h comtypes.h filter.h source.h
    226235nullproto.o: recptproto.h colservrconfig.h
    227236librarymain.o: receptionist.h ../../lib/gsdlconf.h ../../lib/site.h
    228237librarymain.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h action.h
    229238librarymain.o: recptproto.h comtypes.h converter.h ../../lib/gsdlunicode.h
    230 librarymain.o: cgiwrapper.h nullproto.h collectserver.h maptools.h
     239librarymain.o: cgiwrapper.h nullproto.h collectserver.h filter.h source.h
     240librarymain.o: browsefilter.h infodbclass.h queryfilter.h maptools.h
  • trunk/gsdl/src/recpt/comtypes.cpp

    r220 r226  
    1212/*
    1313   $Log$
     14   Revision 1.6  1999/04/06 22:20:34  rjmcnab
     15   Got browsefilter working.
     16
    1417   Revision 1.5  1999/03/31 23:44:47  rjmcnab
    1518   Altered the protocol so that the metadata is part of the filter.
     
    3942  else if (err == authenticationFailure) return "authentication failure";
    4043  else if (err == protocolError) return "protocol error";
     44  else if (err == configurationError) return "configuration error";
    4145  else if (err == systemProblem) return "system problem";
    4246
     
    9498
    9599void FilterOption_t::check_defaultValue () {
    96   if (validValues.empty()) {
    97     // nothing to check against
    98     defaultValue.clear();
    99     return;
     100  text_tarray::iterator here, end;
     101
     102  // how the default is interpreted depends on the option type
     103  switch (type) {
     104  case booleant:
     105  case enumeratedt: // has to be one of the validValues
     106    here = validValues.begin ();
     107    end = validValues.end ();
     108    while (here != end) {
     109      if (*here == defaultValue) return;
     110      here++;
     111    }
     112   
     113    break;
     114
     115  case integert: // has to be in the validValues range
     116    if ((validValues.size() >= 2) &&
     117    (validValues[0].getint() <= defaultValue.getint()) &&
     118    (validValues[1].getint() >= defaultValue.getint()))
     119      return;
     120    break;
     121
     122  case stringt: // any value is valid
     123    return;
    100124  }
    101125
    102   text_tarray::iterator here = validValues.begin ();
    103   text_tarray::iterator end = validValues.end ();
    104   while (here != end) {
    105     if (*here == defaultValue) {
    106       // found the default value in the list of valid values
    107       // now there is nothing more to do
    108       return;
    109     }
    110 
    111     here++;
    112   }
    113 
    114   // did not find the defaultValue, set it to be the
    115   // first option in the list
    116   defaultValue = validValues[0];
     126  // did not find the defaultValue
     127  if (validValues.empty()) defaultValue.clear();
     128  else defaultValue = validValues[0];
    117129}
    118130
  • trunk/gsdl/src/recpt/comtypes.h

    r220 r226  
    3232
    3333
    34 enum comerror_t {noError, authenticationFailure, protocolError, systemProblem};
     34enum comerror_t {noError, authenticationFailure, protocolError,
     35         configurationError, systemProblem};
    3536text_t get_comerror_string (comerror_t err);
    3637
     
    203204  text_t filterName;
    204205  OptionValue_tarray filterOptions;
    205   text_tarray docSet;      // contains "" if not used
     206  text_tset docSet;        // empty if not used
    206207  int filterResultOptions; // use the FR* defines above
    207208
  • trunk/gsdl/src/recpt/librarymain.cpp

    r189 r226  
    1212/*
    1313   $Log$
     14   Revision 1.3  1999/04/06 22:20:35  rjmcnab
     15   Got browsefilter working.
     16
    1417   Revision 1.2  1999/03/05 03:53:54  sjboddie
    1518
     
    2730#include "nullproto.h"
    2831#include "collectserver.h"
     32#include "filter.h"
     33#include "browsefilter.h"
     34#include "queryfilter.h"
     35#include "infodbclass.h"
     36#include "mgsearch.h"
    2937#include <assert.h>
    3038
     
    3543  // add a collection server for each collection ... (not implemented yet)
    3644  collectserver cserver;
     45  gdbmclass gdbmhandler;
     46  mgsearchclass mgsearch;
     47
     48  // add a null filter
     49  filterclass filter;
     50  cserver.add_filter (&filter);
     51
     52  // add a browse filter
     53  browsefilterclass browsefilter;
     54  browsefilter.set_gdbmptr (&gdbmhandler);
     55  cserver.add_filter (&browsefilter);
     56
     57  // add a query filter
     58  queryfilterclass queryfilter;
     59  queryfilter.set_gdbmptr (&gdbmhandler);
     60  queryfilter.set_mgsearchptr (&mgsearch);
     61  cserver.add_filter (&queryfilter);
     62
     63  // inform collection server and everything it contains about its
     64  // collection name
    3765  cserver.configure ("collection", "gberg");
     66
    3867  nproto.add_collectserver (&cserver);
    3968
     
    4170  recpt.add_protocol (&nproto);
    4271
    43   cgiwrapper (recpt, "gberg");
     72  cgiwrapper (recpt, "cnrub");
    4473  return 0;
    4574}
  • trunk/gsdl/src/recpt/statusaction.cpp

    r220 r226  
    1212/*
    1313   $Log$
     14   Revision 1.12  1999/04/06 22:20:35  rjmcnab
     15   Got browsefilter working.
     16
    1417   Revision 1.11  1999/03/31 23:44:49  rjmcnab
    1518   Altered the protocol so that the metadata is part of the filter.
     
    470473    }
    471474
    472     /*    textout << outconvert << "<hr>\n"
    473         << "<h3>Metadata options</h3>\n";
    474 
    475     MetadataInfoResponse_t metainfo;
    476     rproto->get_metadataoptions (arg_c, metainfo, err, logout);
     475
     476    InfoFiltersResponse_t filterinfo;
     477    InfoFilterOptionsRequest_t filteroptions_request;
     478    InfoFilterOptionsResponse_t filteroptions;
     479    rproto->get_filterinfo (arg_c, filterinfo, err, logout);
    477480    if (err == noError) {
    478       textout << outconvert
    479           << "<table>\n"
    480           << "<tr><th>supported fields</th><td>";
    481       text_tset::iterator sup_here = metainfo.supportedFields.begin();
    482       text_tset::iterator sup_end = metainfo.supportedFields.end();
    483       bool sup_first = true;
    484       while (sup_here != sup_end) {
    485     if (!sup_first) textout << outconvert << ", ";
    486     sup_first = false;
    487     textout << outconvert << "\"" << *sup_here << "\"";
    488     sup_here++;
    489       }
    490       textout << outconvert << "</td></tr>\n"
    491    
    492           << "<tr><th>supported languages</th><td>";
    493       sup_here = metainfo.supportedLanguages.begin();
    494       sup_end = metainfo.supportedLanguages.end();
    495       sup_first = true;
    496       while (sup_here != sup_end) {
    497     if (!sup_first) textout << outconvert << ", ";
    498     sup_first = false;
    499     textout << outconvert << "\"" << *sup_here << "\"";
    500     sup_here++;
    501       }
    502       textout << outconvert << "</td></tr>\n"
    503           << "</table>\n";
    504 
    505     } else {
    506       textout << outconvert << "Error (" << get_comerror_string (err)
    507           << ") while getting metadata information\n";
    508     }
    509     */
    510     textout << outconvert << "<hr>\n";
    511     /* // this needs some work
    512     InfoFilterOptionsResponse_t filterinfo;
    513     rproto->get_filteroptions (arg_c, filterinfo, err, logout);
    514     if (err == noError) {
    515       FilterDescript_tmap::iterator filter_here =
    516     filterinfo.filterOptions.begin();
    517       FilterDescript_tmap::iterator filter_end =
    518     filterinfo.filterOptions.end();
    519       while (filter_here != filter_end) {
     481      text_tset::iterator filternames_here = filterinfo.filterNames.begin();
     482      text_tset::iterator filternames_end = filterinfo.filterNames.end();
     483      while (filternames_here != filternames_end) {
    520484    textout << outconvert
    521         << "<h3>Filter options for \"" << (*filter_here).first << "\"</h3>\n"
     485        << "<hr>\n"
     486        << "<h3>Filter options for \"" << (*filternames_here) << "\"</h3>\n"
    522487        << "<table>\n"
    523488        << "<tr><th>option name</th><th>type</th><th>repeatable</th>"
    524489        << "<th>default value</th><th>valid values</th></tr>\n";
    525490
    526     FilterOption_tmap::iterator filteropt_here =
    527       (*filter_here).second.filterOptions.begin();
    528     FilterOption_tmap::iterator filteropt_end =
    529       (*filter_here).second.filterOptions.end();
    530     while (filteropt_here != filteropt_end) {
     491    filteroptions_request.clear();
     492    filteroptions_request.filterName = *filternames_here;
     493    rproto->get_filteroptions (arg_c, filteroptions_request,
     494                   filteroptions, err, logout);
     495    if (err == noError) {
     496      FilterOption_tmap::iterator filteropt_here =
     497        filteroptions.filterOptions.begin();
     498      FilterOption_tmap::iterator filteropt_end =
     499        filteroptions.filterOptions.end();
     500      while (filteropt_here != filteropt_end) {
     501        textout << outconvert
     502            << "<tr><td>\""
     503            << (*filteropt_here).second.name
     504            << "\"</td>\n"
     505         
     506            << "<td>";
     507        text_t type_string;
     508        switch ((*filteropt_here).second.type) {
     509        case FilterOption_t::booleant: type_string = "boolean"; break;
     510        case FilterOption_t::integert: type_string = "integer"; break;
     511        case FilterOption_t::enumeratedt: type_string = "enumerated"; break;
     512        case FilterOption_t::stringt: type_string = "string"; break;
     513        }
     514        textout << outconvert
     515            << type_string
     516            << "</td>\n"
     517         
     518            << "<td>";
     519        text_t repeat_string;
     520        switch ((*filteropt_here).second.repeatable) {
     521        case FilterOption_t::onePerQuery: repeat_string = "one per query"; break;
     522        case FilterOption_t::onePerTerm: repeat_string = "one per term"; break;
     523        case FilterOption_t::nPerTerm: repeat_string = "n per term"; break;
     524        }
     525        textout << outconvert
     526            << repeat_string
     527            << "</td>\n"
     528         
     529            << "<td>\""
     530            << (*filteropt_here).second.defaultValue
     531            << "\"</td>\n"
     532         
     533            << "<td>";
     534       
     535        text_tarray::iterator valid_here =
     536          (*filteropt_here).second.validValues.begin();
     537        text_tarray::iterator valid_end =
     538          (*filteropt_here).second.validValues.end();
     539        bool valid_first = true;
     540        while (valid_here != valid_end) {
     541          if (!valid_first) textout << outconvert << ", ";
     542          valid_first = false;
     543          textout << outconvert << "\"" << *valid_here << "\"";
     544          valid_here++;
     545        }
     546        textout << outconvert
     547            << "</td></tr>\n";
     548
     549        filteropt_here++;
     550      }
     551
    531552      textout << outconvert
    532           << "<tr><td>\""
    533           << (*filteropt_here).second.name
    534           << "\"</td>\n"
    535 
    536           << "<td>";
    537       text_t type_string;
    538       switch ((*filteropt_here).second.type) {
    539       case FilterOption_t::booleant: type_string = "boolean"; break;
    540       case FilterOption_t::integert: type_string = "integer"; break;
    541       case FilterOption_t::enumeratedt: type_string = "enumerated"; break;
    542       case FilterOption_t::stringt: type_string = "string"; break;
    543       }
    544       textout << outconvert
    545           << type_string
    546           << "</td>\n"
    547        
    548           << "<td>";
    549       text_t repeat_string;
    550       switch ((*filteropt_here).second.repeatable) {
    551       case FilterOption_t::onePerQuery: repeat_string = "one per query"; break;
    552       case FilterOption_t::onePerTerm: repeat_string = "one per term"; break;
    553       case FilterOption_t::nPerTerm: repeat_string = "n per term"; break;
    554       }
    555       textout << outconvert
    556           << repeat_string
    557           << "</td>\n"
    558        
    559           << "<td>\""
    560           << (*filteropt_here).second.defaultValue
    561           << "\"</td>\n"
    562 
    563           << "<td>";
    564 
    565       text_tarray::iterator valid_here =
    566         (*filteropt_here).second.validValues.begin();
    567       text_tarray::iterator valid_end =
    568         (*filteropt_here).second.validValues.end();
    569       bool valid_first = true;
    570       while (valid_here != valid_end) {
    571         if (!valid_first) textout << outconvert << ", ";
    572         valid_first = false;
    573         textout << outconvert << "\"" << *valid_here << "\"";
    574         valid_here++;
    575       }
    576       textout << outconvert
    577           << "</td></tr>\n";
    578 
    579       filteropt_here++;
     553          << "</table>\n";
     554
     555    } else {
     556      textout << outconvert << "Error (" << get_comerror_string (err)
     557          << ") while getting filter option information\n";
    580558    }
    581559
    582     textout << outconvert
    583         << "</table>\n";
    584 
    585     filter_here++;
     560    filternames_here++;
    586561      }
    587562
    588563    } else {
    589564      textout << outconvert << "Error (" << get_comerror_string (err)
    590           << ") while getting filter option information\n";
    591     }
    592     */
     565          << ") while getting filter information\n";
     566    }
    593567  }
    594568 
Note: See TracChangeset for help on using the changeset viewer.