Changeset 9030


Ignore:
Timestamp:
2005-02-14T17:20:06+13:00 (19 years ago)
Author:
davidb
Message:

Update of collectset API argument to fit in with Stefan's apache module code.

File:
1 edited

Legend:

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

    r8032 r9030  
    3535#include "mgppqueryfilter.h"
    3636#include "mggdbmsource.h"
    37 
    38 #ifdef USE_LUCENE
    3937#include "lucenequeryfilter.h"
    4038#include "lucenegdbmsource.h"
    41 #endif
    4239
    4340#include "fileutil.h"
     
    139136        cserver->add_source (mggdbmsource);   
    140137      } else if (buildtype == "lucene") {
    141 #ifdef USE_LUCENE
    142138        lucenesearch = new lucenesearchclass();
    143139       
     
    153149        lucenegdbmsource->set_textsearchptr (lucenesearch);
    154150        cserver->add_source (lucenegdbmsource);   
    155 #else
    156         cerr << "Warning: Greenstone not compiled with Lucene support" << endl;
    157 #endif   
    158151  }
    159152
     
    241234}
    242235
     236
     237void collectset::add_all_collections(const text_t &gsdlhome) {
     238
     239  text_tarray collections;
     240  text_t collectdir = filename_cat(gsdlhome, "collect");
     241  if (read_dir(collectdir, collections)) {
     242
     243    text_tarray::const_iterator thiscol = collections.begin();
     244    text_tarray::const_iterator endcol = collections.end();
     245
     246    while (thiscol != endcol) {
     247   
     248      // ignore the modelcol
     249      if (*thiscol == "modelcol") {
     250    thiscol ++;
     251    continue;
     252      }
     253   
     254      // create collection server and add to null protocol
     255      this->add_collection (*thiscol, gsdlhome);
     256   
     257      thiscol ++;
     258    }
     259  }
     260}
     261
    243262// add_collection sets up the collectionserver and calls
    244263// add_collectserver
    245 void collectset::add_collection (const text_t &collection, void *recpt,
    246                  const text_t &gsdlhome, const text_t &gdbmhome) {
     264void collectset::add_collection (const text_t &collection,
     265                 const text_t &gsdlhome) {
    247266
    248267  // if an old collection server exists for this collection we should
     
    331350
    332351  } else if (buildtype == "lucene") {
    333 #ifdef USE_LUCENE     
    334352    lucenesearch = new lucenesearchclass();
    335353
     
    345363    lucenegdbmsource->set_textsearchptr (lucenesearch);
    346364    cserver->add_source (lucenegdbmsource);
    347 #else
    348     cerr << "Warning: Greenstone not compiled with Lucene support" << endl;
    349 #endif   
    350    
    351365  }
    352366
     
    365379  cservers.addcollectserver (cserver);
    366380}
     381
     382void collectset::remove_all_collections () {
     383
     384  // first unload any cached mg databases
     385  if (mgsearch != NULL) {
     386    mgsearch->unload_database();
     387  }
     388
     389  // now delete the collection server objects
     390  collectservermapclass::iterator here = cservers.begin();
     391  collectservermapclass::iterator end = cservers.end();
     392
     393  while (here != end) {
     394    if ((*here).second.c != NULL) {
     395      delete (*here).second.c;
     396    }
     397    here ++;
     398  }
     399  cservers.clear();
     400}
     401
    367402
    368403// remove_collection deletes the collection server of collection.
Note: See TracChangeset for help on using the changeset viewer.