Changeset 19591

Show
Ignore:
Timestamp:
25.05.2009 15:19:23 (10 years ago)
Author:
kjdon
Message:

strip off namespace and subfield when creating metatags, as the d2m mappings don't allow them

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/runtime-src/src/z3950/z3950server.cpp

    r18178 r19591  
    595595    cerr << "get_marc_record failed" << endl; 
    596596    return false; // failed 
    597   } else { 
    598     FilterResponse_t response; 
    599     // iterate through Response_tlist to find the right response 
    600     RESPONSE_here = Response_tlist.begin(); 
    601     RESPONSE_end = Response_tlist.end(); 
    602     RESPONSE_COLNAMES_here = Response_tlist_colnames.begin(); 
    603     RESPONSE_COLNAMES_end = Response_tlist_colnames.end(); 
    604     RESPONSE_SIZES_here = Response_tlist_sizes.begin(); 
    605     RESPONSE_SIZES_end = Response_tlist_sizes.end(); 
    606     int n = 0; 
    607     while (RESPONSE_here != RESPONSE_end) { 
    608       n += *RESPONSE_SIZES_here; 
    609       if (n >= recnum) { 
    610     response = *RESPONSE_here; 
    611     CollectionName = *RESPONSE_COLNAMES_here; 
    612     recnum = *RESPONSE_SIZES_here - (n - recnum); 
    613     break; 
    614       } 
    615       // these should all have the same number of elements, 
    616       // so only need to check that one is within bounds. 
    617       // may want to combine these into a larger data structure later. 
    618       RESPONSE_here++; 
    619       RESPONSE_COLNAMES_here++; 
    620       RESPONSE_SIZES_here++; 
    621     } 
    622  
    623     // locate the desired record in the response 
     597  } 
     598    
     599  FilterResponse_t response; 
     600  // iterate through Response_tlist to find the right response 
     601  RESPONSE_here = Response_tlist.begin(); 
     602  RESPONSE_end = Response_tlist.end(); 
     603  RESPONSE_COLNAMES_here = Response_tlist_colnames.begin(); 
     604  RESPONSE_COLNAMES_end = Response_tlist_colnames.end(); 
     605  RESPONSE_SIZES_here = Response_tlist_sizes.begin(); 
     606  RESPONSE_SIZES_end = Response_tlist_sizes.end(); 
     607  int n = 0; 
     608  while (RESPONSE_here != RESPONSE_end) { 
     609    n += *RESPONSE_SIZES_here; 
     610    if (n >= recnum) { 
     611      response = *RESPONSE_here; 
     612      CollectionName = *RESPONSE_COLNAMES_here; 
     613      recnum = *RESPONSE_SIZES_here - (n - recnum); 
     614      break; 
     615    } 
     616    // these should all have the same number of elements, 
     617    // so only need to check that one is within bounds. 
     618    // may want to combine these into a larger data structure later. 
     619    RESPONSE_here++; 
     620    RESPONSE_COLNAMES_here++; 
     621    RESPONSE_SIZES_here++; 
     622  } 
     623 
     624  // locate the desired record in the response and gather all the metadata 
    624625     
    625     MetadataInfo_tmap::iterator METAFIELD_here = response.docInfo[recnum-1].metadata.begin(); 
    626     MetadataInfo_tmap::iterator METAFIELD_end = response.docInfo[recnum-1].metadata.end(); 
    627      
    628     while (METAFIELD_here!=METAFIELD_end) { 
     626  MetadataInfo_tmap::iterator METAFIELD_here = response.docInfo[recnum-1].metadata.begin(); 
     627  MetadataInfo_tmap::iterator METAFIELD_end = response.docInfo[recnum-1].metadata.end(); 
     628   
     629  while (METAFIELD_here!=METAFIELD_end) { 
     630    text_t meta_name = METAFIELD_here->first; 
     631    text_t::const_iterator pos = findchar(meta_name.begin(), meta_name.end(), '.'); 
     632    // strip off namespace and subfield 
     633    if (pos != meta_name.end()) { 
     634      meta_name = substr(pos+1, meta_name.end()); 
     635    } 
     636    pos = findchar(meta_name.begin(), meta_name.end(), '^'); 
     637    if (pos != meta_name.end()) { 
     638      meta_name = substr(meta_name.begin(), pos); 
     639    } 
     640    if (meta_name[0] >= 'A' && 
     641    meta_name[0] <= 'Z') { 
    629642      text_tarray::iterator METAVALUE_here = METAFIELD_here->second.values.begin(); 
    630643      text_tarray::iterator METAVALUE_end = METAFIELD_here->second.values.end(); 
    631644      while (METAVALUE_here!=METAVALUE_end) { 
    632     if (METAFIELD_here->first[0] >= 'A' && 
    633         METAFIELD_here->first[0] <= 'Z') { 
    634       metatag *tmptag = new metatag(); 
    635       tmptag->name = METAFIELD_here->first.getcstr(); 
    636       tmptag->type = ""; 
    637       tmptag->scheme = ""; 
    638       tmptag->value = (*METAVALUE_here).getcstr(); 
    639       Metatag_list.push_back(tmptag); 
    640     } 
     645     
     646    metatag *tmptag = new metatag(); 
     647    tmptag->name = meta_name.getcstr(); 
     648    tmptag->type = ""; 
     649    tmptag->scheme = ""; 
     650    tmptag->value = (*METAVALUE_here).getcstr(); 
     651    Metatag_list.push_back(tmptag); 
     652     
    641653    METAVALUE_here++; 
    642654      } 
    643       METAFIELD_here++; 
    644     } 
    645     return true; // succeeded 
    646   } 
     655    } 
     656     
     657    METAFIELD_here++; 
     658  } 
     659  return true; // succeeded 
     660 
    647661} 
    648662