Changeset 271


Ignore:
Timestamp:
1999-06-16T14:00:34+12:00 (25 years ago)
Author:
sjboddie
Message:

Few changes to get getParent filter option to return metadata of
parents as well as current OID

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

Legend:

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

    r259 r271  
    1313/*
    1414   $Log$
     15   Revision 1.9  1999/06/16 02:00:34  sjboddie
     16   Few changes to get getParent filter option to return metadata of
     17   parents as well as current OID
     18
    1519   Revision 1.8  1999/05/10 03:43:47  sjboddie
    1620   lots of changes to lots of files - getting document action going
     
    226230      if (((*source_here).s != NULL) &&
    227231          ((*source_here).s->get_metadata(request.requestParams, request.refParams,
    228                           request.fields, (*resultdoc_here).OID,
    229                           (*resultdoc_here).metadata, err, logout))) {
     232                          request.getParents, request.fields,
     233                          (*resultdoc_here).OID, (*resultdoc_here).metadata,
     234                          err, logout))) {
    230235        if (err != noError) return;
    231236        break;
  • trunk/gsdl/src/colservr/mggdbmsource.cpp

    r259 r271  
    1212/*
    1313   $Log$
     14   Revision 1.9  1999/06/16 02:00:34  sjboddie
     15   Few changes to get getParent filter option to return metadata of
     16   parents as well as current OID
     17
    1418   Revision 1.8  1999/05/10 03:43:48  sjboddie
    1519   lots of changes to lots of files - getting document action going
     
    124128
    125129bool mggdbmsourceclass::get_metadata (const text_t &/*requestParams*/, const text_t &/*refParams*/,
    126                       const text_tarray &fields, const text_t &OID,
    127                       MetadataInfo_tarray &metadata,
    128                       comerror_t &err, ostream &logout) {
     130                      bool getParents, const text_tarray &fields, const text_t &OID,
     131                      MetadataInfo_tarray &metadata, comerror_t &err, ostream &logout) {
    129132  outconvertclass text_t2ascii;
    130133
     
    152155  }
    153156
    154   // get the metadata
    155   infodbclass info;
    156   if (!gdbmptr->getinfo(OID, info)) return false;
    157 
    158   // adjust the metadata
    159   text_t &contains = info["contains"];
    160   if (contains.empty()) info["haschildren"] = 0;
    161   else info["haschildren"] = 1;
    162   contains.clear();
     157  // get the metadata - if getParents is set we need to get
     158  // info for all parents of OID as well as OID
     159  vector<infodbclass> info_array;
     160  text_tarray OIDs;
     161  if (getParents) get_parents_array (OID, OIDs);
     162  OIDs.push_back (OID);
     163
     164  text_tarray::const_iterator this_OID = OIDs.begin();
     165  text_tarray::const_iterator end_OID = OIDs.end();
     166
     167  while (this_OID != end_OID) {
     168    infodbclass info;
     169    if (!gdbmptr->getinfo(*this_OID, info)) return false;
     170
     171    // adjust the metadata
     172    text_t &contains = info["contains"];
     173    if (contains.empty()) info["haschildren"] = 0;
     174    else info["haschildren"] = 1;
     175    contains.clear();
     176
     177    info_array.push_back(info);
     178    this_OID ++;
     179  }
    163180
    164181  // collect together the metadata
     
    172189    this_metadata.clear();
    173190    this_metadata.isRef = false;
    174     pos_metadata = info.getinfo(*fields_here);
     191
     192    vector<infodbclass>::iterator this_info = info_array.begin();
     193    vector<infodbclass>::iterator end_info = info_array.end();
     194
     195    while (this_info != end_info) {
     196
     197      pos_metadata = (*this_info).getinfo(*fields_here);
    175198   
    176     if ((*fields_here == "hasnext" || *fields_here == "hasprevious")) {
    177 
    178       // collect metadata
    179       if (!donenextprevtest) {
    180     donenextprevtest = true;
    181 
    182     // cache parent contents array
    183     text_t thisparent = get_parent (OID);
    184     if (thisparent != parentOID) {
    185       parentOID = thisparent;
    186       parentcontents.erase(parentcontents.begin(), parentcontents.end());
    187       if (gdbmptr->getinfo(parentOID, parentinfo)) {
    188         text_t &parentinfocontains = parentinfo["contains"];
    189       if (!parentinfocontains.empty())
    190         splitchar (parentinfocontains.begin(), parentinfocontains.end(), ';', parentcontents);
     199      if ((*fields_here == "hasnext" || *fields_here == "hasprevious")) {
     200   
     201    // collect metadata
     202    if (!donenextprevtest) {
     203      donenextprevtest = true;
     204     
     205      // cache parent contents array
     206      text_t thisparent = get_parent (OID);
     207      if (thisparent != parentOID) {
     208        parentOID = thisparent;
     209        parentcontents.erase(parentcontents.begin(), parentcontents.end());
     210        if (gdbmptr->getinfo(parentOID, parentinfo)) {
     211          text_t &parentinfocontains = parentinfo["contains"];
     212          if (!parentinfocontains.empty())
     213        splitchar (parentinfocontains.begin(), parentinfocontains.end(), ';', parentcontents);
     214        }
    191215      }
    192     }
    193 
    194     // do tests
    195     text_tarray::const_iterator parentcontents_here = parentcontents.begin();
    196     text_tarray::const_iterator parentcontents_end = parentcontents.end();
    197     text_t shrunk_OID = OID;
    198     shrink_parent (shrunk_OID);
    199     while (parentcontents_here != parentcontents_end) {
    200       if (*parentcontents_here == shrunk_OID) {
    201         if (parentcontents_here == parentcontents.begin()) hasprevious = false;
    202         else hasprevious = true;
    203 
    204         parentcontents_here++;
    205 
    206         if (parentcontents_here == parentcontents.end()) hasnext = false;
    207         else hasnext = true;
    208 
    209         break;
    210       } 
     216     
     217      // do tests
     218      text_tarray::const_iterator parentcontents_here = parentcontents.begin();
     219      text_tarray::const_iterator parentcontents_end = parentcontents.end();
     220      text_t shrunk_OID = OID;
     221      shrink_parent (shrunk_OID);
     222      while (parentcontents_here != parentcontents_end) {
     223        if (*parentcontents_here == shrunk_OID) {
     224          if (parentcontents_here == parentcontents.begin()) hasprevious = false;
     225          else hasprevious = true;
     226         
     227          parentcontents_here++;
     228         
     229          if (parentcontents_here == parentcontents.end()) hasnext = false;
     230          else hasnext = true;
     231         
     232          break;
     233        } 
    211234       
    212       parentcontents_here ++;
    213     }
    214      
     235        parentcontents_here ++;
     236      }
     237   
    215238   
    216       // fill in metadata
    217       if ((*fields_here == "hasnext" && hasnext) ||
    218       (*fields_here == "hasprevious" && hasprevious))
    219     this_metadata.values.push_back("1");
    220       else
    221     this_metadata.values.push_back("0");
    222 
     239    // fill in metadata
     240    if ((*fields_here == "hasnext" && hasnext) ||
     241        (*fields_here == "hasprevious" && hasprevious))
     242      this_metadata.values.push_back("1");
     243    else
     244      this_metadata.values.push_back("0");
     245   
     246      }
     247      else if (pos_metadata != NULL && *fields_here != "contains")
     248    this_metadata.values.push_back(*pos_metadata);
     249      else
     250    this_metadata.values.push_back("");
     251     
     252
     253      this_info++;
    223254    }
    224     else if (pos_metadata != NULL && *fields_here != "contains")
    225       this_metadata.values.push_back(*pos_metadata);
    226     else
    227       this_metadata.values.push_back("");
    228255    metadata.push_back(this_metadata);
    229256   
  • trunk/gsdl/src/colservr/mggdbmsource.h

    r259 r271  
    5353              comerror_t &err, ostream &logout);
    5454  bool get_metadata (const text_t &requestParams, const text_t &refParams,
    55              const text_tarray &fields, const text_t &OID,
    56              MetadataInfo_tarray &metadata,
    57              comerror_t &err, ostream &logout);
     55             bool getParents, const text_tarray &fields, const text_t &OID,
     56             MetadataInfo_tarray &metadata, comerror_t &err, ostream &logout);
    5857  bool get_document (const text_t &OID, text_t &doc,
    5958             comerror_t &err, ostream &logout);
  • trunk/gsdl/src/colservr/source.cpp

    r259 r271  
    1212/*
    1313   $Log$
     14   Revision 1.5  1999/06/16 02:00:33  sjboddie
     15   Few changes to get getParent filter option to return metadata of
     16   parents as well as current OID
     17
    1418   Revision 1.4  1999/05/10 03:43:49  sjboddie
    1519   lots of changes to lots of files - getting document action going
     
    6468// for the given OID then it will return false.
    6569bool sourceclass::get_metadata (const text_t &/*requestParams*/, const text_t &/*refParams*/,
    66                 const text_tarray &/*fields*/, const text_t &/*OID*/,
    67                 MetadataInfo_tarray &metadata,
    68                 comerror_t &err, ostream &/*logout*/) {
     70                bool /*getParents*/, const text_tarray &/*fields*/, const text_t &/*OID*/,
     71                MetadataInfo_tarray &metadata, comerror_t &err, ostream &/*logout*/) {
    6972  metadata.erase(metadata.begin(), metadata.end());
    7073  err = noError;
  • trunk/gsdl/src/colservr/source.h

    r259 r271  
    3838  // for the given OID then it will return false.
    3939  virtual bool get_metadata (const text_t &requestParams, const text_t &refParams,
    40                  const text_tarray &fields, const text_t &OID,
    41                  MetadataInfo_tarray &metadata,
    42                  comerror_t &err, ostream &logout);
     40                 bool getParents, const text_tarray &fields, const text_t &OID,
     41                 MetadataInfo_tarray &metadata, comerror_t &err, ostream &logout);
    4342
    4443  virtual bool get_document (const text_t &OID, text_t &doc,
Note: See TracChangeset for help on using the changeset viewer.