Ignore:
Timestamp:
06/23/10 13:52:02 (11 years ago)
Author:
kjdon
Message:

new toOID takes an extra arg, repos_id, so its generates ids like oai:repos-id:collname:doc-id. old version is still used for set spec ids which remain like demo:CL5. another method to extrac the collection name from a full id

File:
1 edited

Legend:

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

    r20589 r22285  
    4545 *  that use ':' instead.
    4646 */
     47void oaiclassifier::toOAI(const text_t repos_id, const text_t &collection, text_t &classifier)
     48{
     49 
     50  text_t tmp = "oai:";
     51  tmp.append(repos_id);
     52  tmp.append(":");
     53  tmp.append(collection);
     54  toOAI(tmp, classifier);
     55
     56}
     57
     58/**
     59 *  Called to convert GS classifier/document identifiers that use
     60 *  a '.' to separate levels in the hierarchy into OAI identifiers
     61 *  that use ':' instead.
     62 */
    4763void oaiclassifier::toOAI(const text_t &collection, text_t &classifier)
    4864{
     
    5672 
    5773  classifier = tmp;
     74}
     75
     76void  oaiclassifier::getCollectionFromOAIID(const text_t oai_id, text_t &collection_id) {
     77
     78  // id is like oai:repos-id:collection:OID, we just want the collection bit
     79
     80  text_t::const_iterator begin = oai_id.begin();
     81  text_t::const_iterator end = oai_id.end();
     82  text_t::const_iterator colon = findchar(begin, end, ':'); // 1
     83  if (colon != end) {
     84    colon = findchar(colon+1, end, ':'); // 2
     85  }
     86  text_t::const_iterator third_colon;
     87  if (colon !=end) {
     88    third_colon = findchar(colon+1, end, ':');
     89  }
     90  if (third_colon != end) {
     91    collection_id = substr(colon+1, third_colon);
     92  }
    5893}
    5994
Note: See TracChangeset for help on using the changeset viewer.