Changeset 9916


Ignore:
Timestamp:
2005-05-20T11:23:29+12:00 (19 years ago)
Author:
kjdon
Message:

tidying up after someone, who will remain nameless (DAVIDB), refactored the code and moved all the common (NOT) code to a base class, and commited it without testing! and broke the lucene document retrieval. I have added the old get_document method back in here.

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

Legend:

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

    r9346 r9916  
    2525
    2626#include "lucenegdbmsource.h"
     27#include "fileutil.h"
     28#include "OIDtools.h"
     29#include "expat_document.h"
     30#include "lucenesearch.h"
    2731
    2832lucenegdbmsourceclass::lucenegdbmsourceclass ()
     
    3539}
    3640
     41bool lucenegdbmsourceclass::get_document (const text_t &OID, text_t &doc,
     42                      comerror_t &err, ostream &logout) {
     43
     44  outconvertclass text_t2ascii;
     45  err = noError;
     46  if (gdbmptr == NULL) {
     47    // most likely a configuration problem
     48    logout << text_t2ascii
     49       << "configuration error: lucenegdbmsource contains a null gdbmclass\n\n";
     50    err = configurationError;
     51    return true;
     52  }
     53
     54  // open the database
     55  gdbmptr->setlogout(&logout);
     56  if (!gdbmptr->opendatabase (gdbm_filename, GDBM_READER, 100, false)) {
     57    // most likely a system problem (we have already checked that the
     58    // gdbm database exists)
     59    logout << text_t2ascii
     60       << "system problem: open on gdbm database \""
     61       << gdbm_filename << "\" failed\n\n";
     62    err = systemProblem;
     63    return true;
     64  }
     65
     66  text_t tOID = OID;
     67  if (needs_translating (OID))
     68    translate_OID (OID, tOID, err, logout);
     69  infodbclass info;
     70  if (!gdbmptr->getinfo(tOID, info)) return false;
     71 
     72  if (info["hastxt"].getint() == 0) { // there is no text for this section
     73    return false; // true??
     74  }
     75  int docnum = info["docnum"].getint();
     76
     77  // get the parent id
     78  text_t parent_OID;
     79  get_top(tOID, parent_OID);
     80 
     81  // locate the parent info ingdbm db
     82  if (!gdbmptr->getinfo(parent_OID, info)) return false;
     83 
     84  text_t archive_dir = info["assocfilepath"];
     85  text_t full_path_to_doc = filename_cat(collectdir, "index", "text", archive_dir, "doc.xml");
     86 
     87  doc.clear();
     88  expat_document(full_path_to_doc, ((lucenesearchclass*)textsearchptr)->gdbm_level, text_t(docnum), doc);
     89  return true;
     90}
  • trunk/gsdl/src/colservr/lucenegdbmsource.h

    r9346 r9916  
    4242  virtual ~lucenegdbmsourceclass ();
    4343
     44  bool get_document (const text_t &OID, text_t &doc,
     45             comerror_t &err, ostream &logout);
     46
    4447};
    4548
Note: See TracChangeset for help on using the changeset viewer.