Ignore:
Timestamp:
2010-01-26T17:25:25+13:00 (14 years ago)
Author:
mdewsnip
Message:

Changed IncrementalDocument constructor to take the infodbtype as a parameter, instead of assuming GDBM. Part of making the code less GDBM-specific.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/IncrementalDocument.pm

    r21564 r21645  
    3434sub new()
    3535  {
    36     my ($class, $collection, $oid) = @_;
    37 
    38     #rint STDERR "IncrementalDocument::new($collection, $oid)\n";
     36    my ($class, $collection, $infodbtype, $oid) = @_;
     37
     38    #rint STDERR "IncrementalDocument::new($collection, $infodbtype, $oid)\n";
    3939
    4040    # Test the parameters
     
    4747    # The collection this document object has been loaded from.
    4848    $self->{'collection'} = $collection;
     49
     50    # The infodbtype for the collection
     51    $self->{'infodbtype'} = $infodbtype;
    4952
    5053    # An associative array of information retrieved from the info database
     
    150153    my $collection = $self->{'collection'};
    151154    my $index_text_directory_path = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "index", "text");
    152     my $infodb_file_path = &dbutil::get_infodb_file_path("gdbm", $collection, $index_text_directory_path);
    153     my $text = &dbutil::read_infodb_entry("gdbm", $infodb_file_path, $self->{'oid'});
     155    my $infodb_file_path = &dbutil::get_infodb_file_path($self->{'infodbtype'}, $collection, $index_text_directory_path);
     156    my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $infodb_file_path, $self->{'oid'});
    154157    # For each line in the raw text, extract the key (enclosed in angle
    155158    # brackets) and the value
     
    189192
    190193    my $index_text_directory_path = &util::filename_cat($ENV{'GSDLHOME'}, "collect", $collection, "index", "text");
    191     my $infodb_file_path = &dbutil::get_infodb_file_path("gdbm", $collection, $index_text_directory_path);
    192     my $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $infodb_file_path, "append");
    193     &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $self->{'oid'}, &dbutil::convert_infodb_string_to_hash($text));
    194     &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
     194    my $infodb_file_path = &dbutil::get_infodb_file_path($self->{'infodbtype'}, $collection, $index_text_directory_path);
     195    my $infodb_file_handle = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $infodb_file_path, "append");
     196    &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_file_handle, $self->{'oid'}, &dbutil::convert_infodb_string_to_hash($text));
     197    &dbutil::close_infodb_write_handle($self->{'infodbtype'}, $infodb_file_handle);
    195198
    196199    # There is a little bit of extra complexity when saving an incremental
     
    200203    if($doc_num >= 0)
    201204      {
    202     my $text = &dbutil::read_infodb_entry("gdbm", $infodb_file_path, $doc_num);
     205    my $text = &dbutil::read_infodb_entry($self->{'infodbtype'}, $infodb_file_path, $doc_num);
    203206
    204207        # If there is no reverse lookup, then add one now
    205208        if($text !~ /<section>/)
    206209          {
    207         $infodb_file_handle = &dbutil::open_infodb_write_handle("gdbm", $infodb_file_path, "append");
    208         &dbutil::write_infodb_entry("gdbm", $infodb_file_handle, $doc_num, &dbutil::convert_infodb_string_to_hash("<section>" . $self->{'oid'}));
    209         &dbutil::close_infodb_write_handle("gdbm", $infodb_file_handle);
     210        $infodb_file_handle = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $infodb_file_path, "append");
     211        &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_file_handle, $doc_num, &dbutil::convert_infodb_string_to_hash("<section>" . $self->{'oid'}));
     212        &dbutil::close_infodb_write_handle($self->{'infodbtype'}, $infodb_file_handle);
    210213          }
    211214      }
Note: See TracChangeset for help on using the changeset viewer.