Changeset 7414


Ignore:
Timestamp:
2004-05-25T11:02:29+12:00 (20 years ago)
Author:
mdewsnip
Message:

(Human Info) Added a language parameter to most methods.

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

Legend:

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

    r2261 r7414  
    6666    if (*here == '.') parents.push_back(thisparent);
    6767    thisparent.push_back(*here);
    68     here ++;
     68    ++here;
    6969  }
    7070}
     
    7575// metadata fields are to be requested.
    7676
    77 bool get_info (const text_t &OID, const text_t &collection,
     77bool get_info (const text_t &OID, const text_t &collection, const text_t &lang,
    7878           const text_tset &metadata, bool getParents,
    7979           recptproto *collectproto, FilterResponse_t &response,
     
    8787
    8888  request.filterName = "NullFilter";
     89  request.filterLang = lang;
    8990  request.filterResultOptions = FRmetadata;
    9091  request.getParents = getParents;
     
    107108
    108109// overloaded, to allow "custom" filter options.
    109 bool get_info (const text_t &OID, const text_t &collection,
     110bool get_info (const text_t &OID, const text_t &collection, const text_t &lang,
    110111           const text_tset &metadata, const OptionValue_tarray &options,
    111112           bool getParents,
     
    119120
    120121  request.filterName = "NullFilter";
     122  request.filterLang = lang;
    121123  request.filterResultOptions = FRmetadata;
    122124  request.getParents = getParents;
     
    139141}
    140142
    141 bool get_info (const text_tarray &OIDs, const text_t &collection,
     143bool get_info (const text_tarray &OIDs, const text_t &collection, const text_t &lang,
    142144           const text_tset &metadata, bool getParents,
    143145           recptproto *collectproto, FilterResponse_t &response,
     
    151153
    152154  request.filterName = "NullFilter";
     155  request.filterLang = lang;
    153156  request.filterResultOptions = FRmetadata;
    154157  request.getParents = getParents;
     
    172175
    173176// has_children returns true if OID has children
    174 bool has_children (const text_t &OID, const text_t &collection,
     177bool has_children (const text_t &OID, const text_t &collection, const text_t &lang,
    175178           recptproto *collectproto, ostream &logout) {
    176179
     
    179182  metadata.insert ("haschildren");
    180183
    181   if (get_info (OID, collection, metadata, false, collectproto, response, logout)) {
     184  if (get_info (OID, collection, lang, metadata, false, collectproto,   response, logout)) {
    182185    if (response.docInfo[0].metadata["haschildren"].values[0] == "1")
    183186      return true;
     
    191194// with whatever metadata fields are to be requested.
    192195
    193 bool get_children (const text_t &OID, const text_t &collection,
     196bool get_children (const text_t &OID, const text_t &collection, const text_t &lang,
    194197           const text_tset &metadata, bool getParents,
    195198           recptproto *collectproto, FilterResponse_t &response,
     
    206209  request.filterOptions.push_back (option);
    207210  request.filterName = "BrowseFilter";
     211  request.filterLang = lang;
    208212  request.filterResultOptions = FROID | FRmetadata;
    209213  request.fields = metadata;
     
    250254    if (*here == '"') temp += parent;
    251255    else temp.push_back (*here);
    252     here ++;
     256    ++here;
    253257  }
    254258  OID = temp;
     
    290294
    291295static void recurse_contents (ResultDocInfo_t section, const bool &is_classify,
    292                   const text_t &collection, const text_tset &metadata,
     296                  const text_t &collection, const text_t &lang,
     297                  const text_tset &metadata,
    293298                  recptproto *collectproto, FilterResponse_t &response,
    294299                  ostream &logout) {
     
    300305    FilterResponse_t tmp;
    301306    bool getParents = false;
    302     get_children (section.OID, collection, metadata, getParents, collectproto, tmp, logout);
     307    get_children (section.OID, collection, lang, metadata, getParents, collectproto, tmp, logout);
    303308    ResultDocInfo_tarray::iterator thisdoc = tmp.docInfo.begin();
    304309    ResultDocInfo_tarray::iterator lastdoc = tmp.docInfo.end();
    305310    while (thisdoc != lastdoc) {
    306311      response.docInfo.push_back (*thisdoc);
    307       recurse_contents (*thisdoc, is_classify, collection, metadata,
     312      recurse_contents (*thisdoc, is_classify, collection, lang, metadata,
    308313            collectproto, response, logout);
    309       thisdoc ++;
     314      ++thisdoc;
    310315    }
    311316  }
     
    315320// below (and including) OID.
    316321void get_contents (const text_t &topOID, const bool &is_classify,
    317            text_tset &metadata, const text_t &collection,
     322           text_tset &metadata, const text_t &collection, const text_t &lang,
    318323           recptproto *collectproto, FilterResponse_t &response,
    319324           ostream &logout) {
     
    326331
    327332  // get topOIDs info
    328   if (get_info (topOID, collection, metadata, false, collectproto, response, logout))
    329       recurse_contents (response.docInfo[0], is_classify, collection,
    330             metadata, collectproto, response, logout);
     333  if (get_info (topOID, collection, lang, metadata, false, collectproto, response, logout)) {
     334    recurse_contents (response.docInfo[0], is_classify, collection, lang,
     335              metadata, collectproto, response, logout);
     336  }
    331337}
    332338
  • trunk/gsdl/src/recpt/OIDtools.h

    r1347 r7414  
    3131#include "recptproto.h"
    3232
     33void get_oid (const text_t &OID, text_t &to, size_t level);
     34
    3335// returns (in top) the top level of OID (i.e. everything
    3436// up until the first dot)
     
    4547// associated with OID. Metadata should be loaded with whatever
    4648// metadata fields are to be requested
    47 bool get_info (const text_t &OID, const text_t &collection,
     49bool get_info (const text_t &OID, const text_t &collection, const text_t &lang,
    4850           const text_tset &metadata, bool getParents,
    4951           recptproto *collectproto, FilterResponse_t &response,
    5052           ostream &logout);
    51 bool get_info (const text_t &OID, const text_t &collection,
     53bool get_info (const text_t &OID, const text_t &collection, const text_t &lang,
    5254           const text_tset &metadata, const OptionValue_tarray &options,
    5355           bool getParents,
    5456           recptproto *collectproto, FilterResponse_t &response,
    5557           ostream &logout);
    56 bool get_info (const text_tarray &OIDs, const text_t &collection,
     58bool get_info (const text_tarray &OIDs, const text_t &collection, const text_t &lang,
    5759           const text_tset &metadata, bool getParents,
    5860           recptproto *collectproto, FilterResponse_t &response,
     
    6062
    6163// has_children returns true if OID has children
    62 bool has_children (const text_t &OID, const text_t &collection,
     64bool has_children (const text_t &OID, const text_t &collection, const text_t &lang,
    6365           recptproto *collectproto, ostream &logout);
     66bool has_text(const text_t &OID, const text_t &collection, const text_t &lang,
     67           recptproto *collectproto, ostream &logout);
     68
     69inline bool has_text(MetadataInfo_tmap& metadata)
     70{
     71    if (metadata["hastxt"].values.size() > 0) {
     72        return metadata["hastxt"].values[0].getint() != 0;
     73    }
     74    return false;
     75}
     76
     77inline bool has_children(MetadataInfo_tmap& metadata)
     78{
     79    if (metadata["haschildren"].values.size() > 0) {
     80        return metadata["haschildren"].values[0].getint() != 0;
     81    }
     82    return false;
     83}
    6484
    6585// get_children does a protocol call and returns (in response) the OIDs and
    6686// metadata of all the children of OID. The metadata set should be loaded
    6787// with whatever metadata fields are to be requested.
    68 bool get_children (const text_t &OID, const text_t &collection,
     88bool get_children (const text_t &OID, const text_t &collection, const text_t &lang,
    6989           const text_tset &metadata, bool getParents,
    7090           recptproto *collectproto, FilterResponse_t &response,
     
    93113// below (and including) OID.
    94114void get_contents (const text_t &topOID, const bool &is_classify,
    95            text_tset &metadata, const text_t &collection,
     115           text_tset &metadata, const text_t &collection, const text_t &lang,
    96116           recptproto *collectproto, FilterResponse_t &response,
    97117           ostream &logout);
Note: See TracChangeset for help on using the changeset viewer.