Ignore:
Timestamp:
1999-10-10T21:14:12+13:00 (25 years ago)
Author:
sjboddie
Message:
  • metadata now returns mp rather than array
  • redesigned browsing support (although it's not finished so

won't currently work ;-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/OIDtools.cpp

    r533 r649  
    2828/*
    2929   $Log$
     30   Revision 1.17  1999/10/10 08:14:02  sjboddie
     31   - metadata now returns mp rather than array
     32   - redesigned browsing support (although it's not finished so
     33   won't currently work ;-)
     34
    3035   Revision 1.16  1999/09/07 04:56:51  sjboddie
    3136   added GPL notice
     
    135140
    136141// get_info does a protocol call and returns (in response) the metadata
    137 // associated with OID. The metadata array should be loaded with whatever
     142// associated with OID. Metadata should be loaded with whatever
    138143// metadata fields are to be requested.
    139144
    140145bool get_info (const text_t &OID, const text_t &collection,
    141            const text_tarray &metadata, bool getParents,
     146           const text_tset &metadata, bool getParents,
    142147           recptproto *collectproto, FilterResponse_t &response,
    143148           ostream &logout) {
     
    163168    return false;
    164169  }
    165 
    166   // check the result to make sure we have the right amount of metadata
    167   if (!response.docInfo.empty() &&
    168       response.docInfo[0].metadata.size() != metadata.size()) return false;
    169170 
    170171  return true;
     
    172173
    173174bool get_info (const text_tarray &OIDs, const text_t &collection,
    174            const text_tarray &metadata, bool getParents,
     175           const text_tset &metadata, bool getParents,
    175176           recptproto *collectproto, FilterResponse_t &response,
    176177           ostream &logout) {
     
    198199  }
    199200
    200   // check the result to make sure we have the right amount of metadata
    201   if (!response.docInfo.empty() &&
    202       response.docInfo[0].metadata.size() != metadata.size()) return false;
    203 
    204201  return true;
    205202}
     
    210207
    211208  FilterResponse_t response;
    212   text_tarray metadata;
    213   metadata.push_back ("haschildren");
     209  text_tset metadata;
     210  metadata.insert ("haschildren");
    214211
    215212  if (get_info (OID, collection, metadata, false, collectproto, response, logout)) {
    216     if (response.docInfo[0].metadata[0].values[0] == "1")
     213    if (response.docInfo[0].metadata["haschildren"].values[0] == "1")
    217214      return true;
    218215  }
     
    222219
    223220// get_children does a protocol call and returns (in response) the OIDs and
    224 // metadata of all the children of OID. The metadata array should be loaded
     221// metadata of all the children of OID. The metadata set should be loaded
    225222// with whatever metadata fields are to be requested.
    226223
    227224bool get_children (const text_t &OID, const text_t &collection,
    228            const text_tarray &metadata, bool getParents,
     225           const text_tset &metadata, bool getParents,
    229226           recptproto *collectproto, FilterResponse_t &response,
    230227           ostream &logout) {
     
    323320}
    324321
    325 void recurse_contents (const ResultDocInfo_t section, const bool &classify,
    326                int &totalcols, const text_t &collection,
    327                const text_tarray &metadata, recptproto *collectproto,
    328                FilterResponse_t &response, ostream &logout) {
    329  
    330   int metasize = section.metadata.size();
    331 
    332   int haschildren = section.metadata[metasize-2].values[0].getint();
    333   const text_t &doctype = section.metadata[metasize-1].values[0];
    334   int cols;
    335 
    336   if ((haschildren == 1) && ((!classify) || (doctype == "classify"))) {
    337     text_t parent = response.docInfo.back().OID;
    338     int parentcols = countchar (parent.begin(), parent.end(), '.');
     322static void recurse_contents (ResultDocInfo_t section, const bool &is_classify,
     323                  const text_t &collection, const text_tset &metadata,
     324                  recptproto *collectproto, FilterResponse_t &response,
     325                  ostream &logout) {
     326
     327  int haschildren = section.metadata["haschildren"].values[0].getint();
     328  const text_t &doctype = section.metadata["doctype"].values[0];
     329
     330  if ((haschildren == 1) && ((!is_classify) || (doctype == "classify"))) {
    339331    FilterResponse_t tmp;
    340332    bool getParents = false;
    341333    get_children (section.OID, collection, metadata, getParents, collectproto, tmp, logout);
    342     ResultDocInfo_tarray::const_iterator thisdoc = tmp.docInfo.begin();
    343     ResultDocInfo_tarray::const_iterator lastdoc = tmp.docInfo.end();
     334    ResultDocInfo_tarray::iterator thisdoc = tmp.docInfo.begin();
     335    ResultDocInfo_tarray::iterator lastdoc = tmp.docInfo.end();
    344336    while (thisdoc != lastdoc) {
    345       if (((*thisdoc).metadata[metasize-1].values[0] != "classify") && (classify))
    346     cols = parentcols + 1;
    347       else
    348     cols = countchar ((*thisdoc).OID.begin(), (*thisdoc).OID.end(), '.');
    349       if (cols > totalcols) totalcols = cols;
    350337      response.docInfo.push_back (*thisdoc);
    351       recurse_contents (*thisdoc, classify, totalcols, collection,
    352             metadata, collectproto, response, logout);
     338      recurse_contents (*thisdoc, is_classify, collection, metadata,
     339            collectproto, response, logout);
    353340      thisdoc ++;
    354341    }
     
    358345// get_contents returns OIDs and metadata of all contents
    359346// below (and including) OID.
    360 void get_contents (const text_t &topOID, const text_t &classifytype,
    361            text_tarray &metadata, int &totalcols,
    362            const text_t &collection, recptproto *collectproto,
    363            FilterResponse_t &response, ostream &logout) {
     347void get_contents (const text_t &topOID, const bool &is_classify,
     348           text_tset &metadata, const text_t &collection,
     349           recptproto *collectproto, FilterResponse_t &response,
     350           ostream &logout) {
    364351
    365352  if (topOID.empty()) return;
    366   bool classify = false;
    367353  response.clear();
    368354
    369   metadata.push_back("haschildren");
    370   metadata.push_back("doctype");
    371 
    372   // we don't want to recurse all the way down through each document
    373   // if we're expanding top level contents
    374   if (classifytype == "classify") classify = true;
    375 
    376   // update totalcols
    377   totalcols = countchar (topOID.begin(), topOID.end(), '.');
     355  metadata.insert ("haschildren");
     356  metadata.insert ("doctype");
    378357
    379358  // get topOIDs info
    380359  if (get_info (topOID, collection, metadata, false, collectproto, response, logout))
    381       recurse_contents (response.docInfo[0], classify, totalcols, collection,
     360      recurse_contents (response.docInfo[0], is_classify, collection,
    382361            metadata, collectproto, response, logout);
    383362}
Note: See TracChangeset for help on using the changeset viewer.