Changeset 9929


Ignore:
Timestamp:
2005-05-23T16:18:43+12:00 (19 years ago)
Author:
kjdon
Message:

modifications so that collectionmeta are read from the config file, not from the gdbm database, therefore they will update without rebuilding

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

Legend:

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

    r9904 r9929  
    2929#include "OIDtools.h"
    3030#include <assert.h>
     31#include "display.h"
    3132
    3233
     
    8687    else if (key == "numbytes") collectinfo.numBytes = value.getint();
    8788    else if (key == "collectionmeta") {
    88       if (cfgline.size() == 2)
    89     collectinfo.collectionmeta[cfgline[0]] = cfgline[1];
    90       else if (cfgline.size() == 3 &&
    91            collectinfo.collectionmeta[cfgline[0]].empty() )
    92     collectinfo.collectionmeta[cfgline[0]] = cfgline[2];
    93     } else if (key == "collectionmacro") {
     89      text_t params;
     90      if (cfgline.size() == 3) {
     91    // get the params for later
     92    text_t::const_iterator first=cfgline[1].begin()+1;
     93    text_t::const_iterator last=cfgline[1].end()-1;
     94    params=substr(first, last);
     95      }
     96     
     97      text_t meta_name = cfgline[0];
     98      if (*(meta_name.begin())=='.') {
     99    // a .xxx collectionmeta. strip off the . and
     100    // look it up in the indexmap to get the actual value
     101   
     102    text_t name = substr(cfgline[0].begin()+1,cfgline[0].end());
     103    text_t new_name;
     104    if (indexmap.from2to(name, new_name)) {
     105      meta_name = new_name;
     106    }
     107      } else {
     108    // add them to collectionmeta
     109    text_tmap lang_map = collectinfo.collectionmeta[cfgline[0]];
     110    if (cfgline.size() == 2) {
     111      lang_map[g_EmptyText] = cfgline[1];
     112    } else if (cfgline.size() == 3 ) {
     113      // get the lang out of params
     114      paramhashtype params_hash;
     115      splitparams(params, params_hash);
     116     
     117      text_t lang = params_hash["l"];
     118      lang_map[lang] = cfgline[2];
     119      if (lang_map[g_EmptyText].empty()) {
     120        // want the first one as the default if no default specified
     121        lang_map[g_EmptyText] = cfgline[2];
     122      }
     123    }
     124    collectinfo.collectionmeta[cfgline[0]] = lang_map;
     125   
     126      }
     127     
     128      // add all collectionmeta to macro list
     129      if (cfgline.size() == 2) // no params for this macro
     130    collectinfo.collection_macros
     131      .insert( make_pair(meta_name, make_pair(g_EmptyText,cfgline[1])) );
     132      else if (cfgline.size() == 3) {// has params
     133    // can we somehow add this is with no params if there is not already
     134    // a no params entry??
     135    collectinfo.collection_macros
     136      .insert( make_pair(meta_name, make_pair(params,cfgline[2])) );
     137      }
     138    }
     139    else if (key == "collectionmacro") {
     140      text_t nobrackets;
     141      // add all to macro list
    94142      if (cfgline.size() == 2) // no params for this macro
    95143    collectinfo.collection_macros
     
    99147    text_t::const_iterator first=cfgline[1].begin()+1;
    100148    text_t::const_iterator last=cfgline[1].end()-1;
    101     text_t nobrackets=substr(first, last);
     149    nobrackets=substr(first, last);
    102150    collectinfo.collection_macros
    103151      .insert( make_pair(cfgline[0], make_pair(nobrackets,cfgline[2])) );
     
    141189       }
    142190
     191    // store all the mappings for use when collection meta is read later
     192    // (build.cfg read before collect.cfg)
     193    else if (key == "indexmap" || key == "indexfieldmap" || key == "subcollectionmap" || key == "languagemap") {
     194      indexmap.importmap (cfgline, true);
     195     
     196    }
    143197    // In the map the key-value pair contain the same
    144198    // data i.e key == data, if key is 2 then data is 2
     
    176230       }
    177231  }
    178 
     232 
    179233  // configure the filters
    180234  filtermapclass::iterator filter_here = filters.begin();
     
    200254}
    201255
     256
    202257void collectserver::configure (const text_t &key, const text_t &value) {
    203258  text_tarray cfgline;
     
    228283
    229284bool collectserver::init (ostream &logout) {
     285  // delete the indexmap
     286  indexmap.clear();
     287
    230288  // init the filters
    231289  filtermapclass::iterator filter_here = filters.begin();
  • trunk/gsdl/src/colservr/collectserver.h

    r4774 r9929  
    3838#include "cfgread.h"
    3939#include "cnfgable.h"
     40#include "maptools.h"
    4041
    4142#if defined(GSDL_USE_OBJECTSPACE)
     
    7172  filtermapclass filters;
    7273  sourcelistclass sources;
     74
     75  // some stuff to remember while we are configuring
     76  stringmap indexmap;
    7377
    7478public:
  • trunk/gsdl/src/colservr/maptools.cpp

    r9620 r9929  
    3434
    3535void stringmap::importmap (const text_tarray &maparray) {
    36   clear ();
     36  importmap(maparray, false);
     37}
     38
     39void stringmap::importmap (const text_tarray &maparray, bool keepold) {
     40  if (!keepold) {
     41    clear ();
     42  }
    3743 
    3844  text_tarray::const_iterator here = maparray.begin();
  • trunk/gsdl/src/colservr/maptools.h

    r1285 r9929  
    4343
    4444  void importmap (const text_tarray &maparray);
     45  void importmap (const text_tarray &maparray, bool keepold);
    4546  void exportmap (text_tarray &maparray) const;
    4647
Note: See TracChangeset for help on using the changeset viewer.