Changeset 196


Ignore:
Timestamp:
1999-03-10T09:58:50+13:00 (25 years ago)
Author:
rjmcnab
Message:

Added dummy filter and metadata results.

Location:
trunk/gsdl/src/colservr
Files:
2 edited

Legend:

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

    r191 r196  
    1212/*
    1313   $Log$
     14   Revision 1.4  1999/03/09 20:58:50  rjmcnab
     15   Added dummy filter and metadata results.
     16
    1417   Revision 1.3  1999/03/08 05:07:42  rjmcnab
    1518   Made some alterations to fit with the changes to the comtypes. Added the
     
    105108  qfopt7.defaultValue = "";
    106109
     110  // -- onePerTerm  Language  enumerated
     111  FilterOption_t &qfopt8 = queryfilter.filterOptions["Language"];
     112  qfopt8.name = "Language";
     113  qfopt8.type = FilterOption_t::enumeratedt;
     114  qfopt8.repeatable = FilterOption_t::onePerTerm;
     115  qfopt8.defaultValue = "";
     116
    107117
    108118  // set up the BrowseFilter information
     
    143153// it contains. The configuration should take place just before initialisation.
    144154void collectserver::configure (const text_t &key, const text_tarray &cfgline) {
    145   if (key == "indexmap") configinfo.indexmap = cfgline;
    146   else if (key == "subcollectionmap") configinfo.subcollectionmap = cfgline;
    147   else if (key == "languagemap") configinfo.languagemap = cfgline;
    148  
    149   else if (cfgline.size() >= 1) {
     155  if (key == "indexmap") {
     156    configinfo.indexmap.importmap (cfgline);
     157
     158    // update the list of indexes in the filter information
     159    text_tarray options;
     160    configinfo.indexmap.gettoarray (options);
     161    update_enumfiltopt ("Index", options);
     162
     163  } else if (key == "subcollectionmap") {
     164    configinfo.subcollectionmap.importmap (cfgline);
     165
     166    // update the list of subcollections in the filter information
     167    text_tarray options;
     168    configinfo.subcollectionmap.gettoarray (options);
     169    update_enumfiltopt ("Subcollection", options);
     170
     171  } else if (key == "languagemap") {
     172    configinfo.languagemap.importmap (cfgline);
     173
     174    // update the list of languages in the filter information
     175    text_tarray options;
     176    configinfo.languagemap.gettoarray (options);
     177    update_enumfiltopt ("Language", options);
     178 
     179  } else if (cfgline.size() >= 1) {
    150180    const text_t &value = cfgline[0];
    151181    if (key == "gsdlhome") configinfo.gsdlhome = value;
     
    206236void collectserver::get_filteroptions (InfoFilterOptionsResponse_t &response,
    207237                       comerror_t &err, ostream &/*logout*/) {
    208 
     238  response = filterinfo;
    209239  err = noError;
    210240}
     
    213243                FilterResponse_t &response,
    214244                comerror_t &err, ostream &/*logout*/) {
     245  response.clear();
     246
    215247  if (request.filterName == "QueryFilter") {
    216248    // return documents
    217 
    218 
     249    response.docsFound = 2;
     250    response.isApprox = false;
     251   
     252    // fill in the term info
     253    TermInfo_t terminfo;
     254    terminfo.term = "the";
     255    terminfo.freq = 2;
     256    terminfo.matchTerms.push_back ("the");
     257    terminfo.matchTerms.push_back ("The");
     258    response.termInfo.push_back (terminfo);
     259
     260    // fill in the document info
     261    ResultDocInfo_t resultdoc;
     262    resultdoc.OID = "HASH1234";
     263    resultdoc.ranking = 0.8;
     264    resultdoc.docFreq.push_back (10);
     265    response.docInfo.push_back (resultdoc);
     266
     267    resultdoc.clear();
     268    resultdoc.OID = "HASH2345";
     269    resultdoc.ranking = 0.5;
     270    resultdoc.docFreq.push_back (5);
     271    response.docInfo.push_back (resultdoc);
     272
     273  } else if (request.filterName == "BrowseFilter") {
     274    // return documents
     275    response.docsFound = 2;
     276    response.isApprox = false;
     277   
     278    // fill in the document info
     279    ResultDocInfo_t resultdoc;
     280    resultdoc.OID = "HASH2345";
     281    response.docInfo.push_back (resultdoc);
     282
     283    resultdoc.clear();
     284    resultdoc.OID = "HASH3456";
     285    response.docInfo.push_back (resultdoc);
     286   
    219287  } else {
     288    err = protocolError;
     289    return;
    220290  }
    221 
    222 
    223291
    224292  err = noError;
     
    227295void collectserver::get_metadataoptions (MetadataInfoResponse_t &response,
    228296                     comerror_t &err, ostream &/*logout*/) {
     297  response.clear();
     298
     299  response.supportedFields.insert ("Title");
     300  response.supportedFields.insert ("Creator");
     301
     302  response.supportedLanguages.insert ("en");
     303
    229304  err = noError;
    230305}
     
    233308                  MetadataResponse_t &response,
    234309                  comerror_t &err, ostream &/*logout*/) {
     310  response.clear();
     311
     312  text_tarray::const_iterator OIDs_here, OIDs_end, fields_here, fields_end,
     313    languages_here, languages_end;
     314 
     315  // for each object ID
     316  OIDs_here = request.OIDs.begin();
     317  OIDs_end = request.OIDs.end();
     318  while (OIDs_here != OIDs_end) {
     319   
     320    // and each field
     321    fields_here = request.fields.begin();
     322    fields_end = request.fields.end();
     323    while (fields_here != fields_end) {
     324     
     325      // and each language
     326      languages_here = request.languages.begin();
     327      languages_end = request.languages.end();
     328      while (languages_here != languages_end) {
     329   
     330    // return the metadata
     331    text_t metadata = "Place holder";
     332    if (*OIDs_here == "HASH1234") {
     333      if (*fields_here == "Title") metadata="The 1234 book";
     334      else if (*fields_here == "Creator") metadata="ME";
     335     
     336    } else if (*OIDs_here == "HASH2345") {
     337      if (*fields_here == "Title") metadata="2345, come alive";
     338      else if (*fields_here == "Creator") metadata="Another person";
     339
     340    } else if (*OIDs_here == "HASH3456") {
     341      if (*fields_here == "Title") metadata="As easy as 3456";
     342      else if (*fields_here == "Creator") metadata="Bricks";
     343    }
     344
     345    response.metadata.push_back (metadata);
     346    languages_here++;
     347      }
     348     
     349      fields_here++;
     350    }
     351
     352    OIDs_here++;
     353  }
     354
    235355  err = noError;
    236356}
    237357
     358void collectserver::update_enumfiltopt (text_t optionname,
     359                    const text_tarray &options) {
     360  // update this option for each of the filters
     361  FilterDescript_tmap::iterator filteropthere = filterinfo.filterOptions.begin();
     362  FilterDescript_tmap::iterator filteroptend = filterinfo.filterOptions.end();
     363 
     364  while (filteropthere != filteroptend) {
     365    // see if this filter has an option with this name
     366    FilterOption_tmap &fotm = (*filteropthere).second.filterOptions;
     367    FilterOption_tmap::iterator fotm_iterator = fotm.find(optionname);
     368    if (fotm_iterator != fotm.end()) {
     369      // set the valid values to be the options
     370      (*fotm_iterator).second.validValues = options;
     371
     372      // make sure the default is a valid value
     373      (*fotm_iterator).second.check_defaultValue();
     374    }
     375   
     376    filteropthere++;
     377  }
     378}
    238379
    239380
  • trunk/gsdl/src/colservr/collectserver.h

    r191 r196  
    1717#include "text_t.h"
    1818#include "comtypes.h"
     19#include "maptools.h"
    1920
    2021#if defined(GSDL_USE_OBJECTSPACE)
     
    3940  text_t collection;
    4041  text_t collectdir;
    41   text_tarray indexmap;
    42   text_tarray subcollectionmap;
    43   text_tarray languagemap;
     42  stringmap indexmap;
     43  stringmap subcollectionmap;
     44  stringmap languagemap;
    4445};
    4546
     
    5051  ColInfoResponse_t collectinfo;
    5152  InfoFilterOptionsResponse_t filterinfo;
     53
    5254public:
    5355  collectserver ();
     
    8486                 MetadataResponse_t &response,
    8587                 comerror_t &err, ostream &logout);
     88protected:
     89  void update_enumfiltopt (text_t optionname, const text_tarray &options);
    8690};
    8791
Note: See TracChangeset for help on using the changeset viewer.