Changeset 27534 for main


Ignore:
Timestamp:
2013-06-04T15:56:26+12:00 (11 years ago)
Author:
kjdon
Message:

more changes for super collection stuff. Now can handle having collections in a super colleciton that are not in the main collection list

Location:
main/trunk/greenstone2/runtime-src/src/oaiservr
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/oaiservr/abstractlistaction.cpp

    r27528 r27534  
    8484  }
    8585
    86   // Case for no "set" argument present -- output all records in all collections
    87   // or we are a super collection
     86  // Case for no "set" argument present - output all records in all collections & super colls
     87  // Case for super collection set - output all records in all collections in this super coll
    8888  else
    8989  {
     
    9494      collections = this->configuration->getSuperCollectionCollections(set_name);
    9595    } else {
    96       collections = this->configuration->getCollectionsList();
     96     
     97      collections = this->configuration->getAllCollectionsList();//this->configuration->getCollectionsList();
     98   
    9799    }
    98100    if (collections.size() == 0)
     
    121123    {
    122124      // If output_content_for_set() returns false a resumption token has been output, so it's time to stop
    123       if (output_content_for_set(output, protocol, params, *collection_iterator, "", "") == false)
     125      if (output_content_for_set(output, protocol, params, *collection_iterator, "", set_name) == false)
    124126      {
    125127    return true;
  • main/trunk/greenstone2/runtime-src/src/oaiservr/listidsaction.cpp

    r27528 r27534  
    210210
    211211    // Check the collection is one that is in the list in the oai.cfg file
    212     text_tarray &collections = this->configuration->getCollectionsList();
    213     bool collection_found = false;
    214     for (int c = 0; c < collections.size(); c++)
    215     {
    216       if (collections[c] == collection)
    217       {
    218     collection_found = true;
    219     break;
    220       }
    221     }
    222 
    223     // The collection was not found
    224     if (!collection_found)
    225     {
    226       this->errorType = "badArgument";
    227       return false;
    228     }
     212    if (!this->configuration->isValidCollection(collection)) {
     213      this->errorType = "badArgument";
     214      return false;
     215    }     
    229216
    230217    // Check the child set if it was given
  • main/trunk/greenstone2/runtime-src/src/oaiservr/listrecsaction.cpp

    r24412 r27534  
    165165    text_t set = params["set"];
    166166
     167    // Is the set a super collection??
     168    text_tarray &super_collections = this->configuration->getSuperCollectionsList();
     169    bool super_collection_found = false;
     170    for (int c = 0; c < super_collections.size(); c++)
     171    {
     172      if (super_collections[c] == set)
     173      {
     174    super_collection_found = true;
     175    break;
     176      }
     177    }
     178    if (super_collection_found) {
     179      this->errorType = "";
     180      return true;
     181    }
     182
    167183    // Extract the collection name from the set specification
    168184    text_t collection = "";
     
    180196   
    181197    // Check the collection is one that is in the list in the oai.cfg file
    182     text_tarray &collections = this->configuration->getCollectionsList();
    183     bool collection_found = false;
    184     for (int c = 0; c < collections.size(); c++)
    185     {
    186       if (collections[c] == collection)
    187       {
    188     collection_found = true;
    189     break;
    190       }
    191     }
    192 
    193     // The collection was not found
    194     if (!collection_found)
    195     {
    196       this->errorType = "badArgument";
    197       return false;
    198     }
     198    if (!this->configuration->isValidCollection(collection)) {
     199      this->errorType = "badArgument";
     200      return false;
     201    }     
    199202
    200203    // Check the child set if it was given
  • main/trunk/greenstone2/runtime-src/src/oaiservr/listsetsaction.cpp

    r27528 r27534  
    124124  }
    125125
     126  // if no resumption token, output the super colls. Otherwise, start from
     127  // the collection list correct position.
     128  // Assume for now that super coll list is always first in the list of sets,
     129  // and we never issue a resumption token part way through the list of super colls
     130  // TODO handle resumption tokens properly.
     131  text_t set_name ="";
     132  if (position == "") {
     133    text_tarray& supercolls = this->configuration->getSuperCollectionsList();
     134    text_tarray::iterator supercoll_iterator = supercolls.begin();
     135    while (supercoll_iterator != supercolls.end()) {
     136      set_name = (*supercoll_iterator);
     137      output_content_for_supercol(output, set_name);
     138      supercoll_iterator++;
     139    }
     140  }
     141
     142
    126143  // Get a list of the collections available
    127144  text_tarray& collections = this->configuration->getCollectionsList();
    128145  if (collections.size() == 0)
    129146  {
    130     return false;
    131   }
    132 
    133   // if no resumption token, output the super colls. Otherwise, start from
    134   // the collection list correct position.
    135   // Assume for now that super coll list is always in the first list
    136   text_t set_name ="";
    137   if (position == "") {
    138     text_tarray& supercolls = this->configuration->getSuperCollectionsList();
    139     if (collections.size() != 0) {
    140       text_tarray::iterator supercoll_iterator = supercolls.begin();
    141       while (supercoll_iterator != supercolls.end()) {
    142     set_name = (*supercoll_iterator);
    143     output_content_for_supercol(output, set_name);
    144     supercoll_iterator++;
    145       }
    146     }
    147   }
     147    if (this->setsOutput ==0) {
     148      // we had no super colls either
     149      return false;
     150    }
     151    return true;
     152  }
     153
    148154  // Get the current collection from the position value
    149155  text_t collection_name = "";
  • main/trunk/greenstone2/runtime-src/src/oaiservr/oaiaction.cpp

    r27528 r27534  
    414414    if(oaiVersion >= 200){
    415415
    416       // A doc is always a member of its collection set
    417       output << "      <setSpec>" << collection_id << "</setSpec>" << endl;
     416      // A doc is only a member of its collection set if hte collection is valid
     417      // Can have super collecitons containging collecitons that are not individually valid
     418      if (this->configuration->isValidCollection(collection_id)) {
     419    output << "      <setSpec>" << collection_id << "</setSpec>" << endl;
     420      }
    418421      // are we part of a super collection?
    419422      text_tarray super_colls = this->configuration->getSuperCollectionsForThisCollection(collection_id);
  • main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.cpp

    r27528 r27534  
    110110  }
    111111  return 200;
     112}
     113
     114bool oaiconfig::isValidCollection(const text_t &collection)
     115{
     116  for (int c = 0; c < this->collectList.size(); c++)
     117    if (this->collectList[c] == collection) {
     118      return true;
     119    }
     120  return false;
    112121}
    113122
     
    208217    for (int c = 0; c < cfgline.size(); ++c) {
    209218      this->collectList.push_back(cfgline[c]);
     219      addToAllCollectionsList(cfgline[c]);
    210220    }
    211221  }
    212222  else if (key == "oaisupercollection" && cfgline.size() > 1) {
    213223
    214     // Configure a hierarchical super set
     224    // Configure a super collection set
    215225    // The line should read
    216226    //
     
    240250      }
    241251      this->collectMap[sub_coll]->superCollectList.push_back(super_set);
     252      addToAllCollectionsList(sub_coll);
    242253    }
    243254  }
     
    358369  }
    359370}
    360 
     371 
     372void oaiconfig::addToAllCollectionsList(const text_t coll_name) {
     373
     374  for (int c=0; c<this->allCollectList.size(); c++) {
     375    if (allCollectList[c] == coll_name) return;
     376  }
     377  this->allCollectList.push_back(coll_name);
     378 
     379}
    361380
    362381text_t oaiconfig::generateBaseServerURL() {
     
    481500}
    482501
    483 text_tarray oaiconfig::getSuperCollectionsForThisCollection(const text_t &collection) {
     502
     503text_tarray oaiconfig::getSuperCollectionsForThisCollection(const text_t &collection)
     504{
    484505
    485506  text_tarray super_colls;
  • main/trunk/greenstone2/runtime-src/src/oaiservr/oaiconfig.h

    r27528 r27534  
    6363  virtual void  configure(const text_t &key, const text_tarray &cfgline);
    6464  text_tarray & getCollectionsList() { return this->collectList; }
     65  // get a list of all collections - those part of a super coll and those individual ones
     66  text_tarray & getAllCollectionsList() {return this->allCollectList; }
    6567  text_tarray & getSuperCollectionsList() { return this->superCollectList; }
     68  // get the list of collections for this super coll
    6669  text_tarray & getSuperCollectionCollections(const text_t super_coll) {
    6770    return this->superCollectMap[super_coll]->collectionList;
    6871  }
     72  // is this collection valid
     73  bool isValidCollection(const text_t &collection);
     74  // what super collections is this collection part of?
    6975  text_tarray getSuperCollectionsForThisCollection(const text_t &collection);
    7076  text_tset & getMetadataSet() { return this->metadataSet; }
     
    8692 private:
    8793  bool configureCollection(const text_t &gsdlhome, const text_t &collection);
     94  void addToAllCollectionsList(const text_t coll_name);
    8895  text_t generateBaseServerURL();
    8996  text_t    repositoryName; // human readable name
     
    106113  text_tarray superCollectList; //a list of super collections. may be empty
    107114  oaisupercollectmap superCollectMap; // The configuration of the super collections
     115  text_tarray allCollectList; //a list of all collections, includes those in collectList and those that are part of a super collection and not in collectList
    108116};
    109117#endif
Note: See TracChangeset for help on using the changeset viewer.