Changeset 21579

Show
Ignore:
Timestamp:
22.01.2010 15:04:29 (9 years ago)
Author:
mdewsnip
Message:

Changed arcinfo.pm to take the infodb type to use for the archiveinf databases as a parameter. If this is not defined, the default infodb type from dbutil will be used (this is likely to always be gdbm). Part of making the code less GDBM-specific.

Files:
1 modified

Legend:

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

    r21568 r21579  
    5454 
    5555sub new { 
    56     my ($class) = @_; 
    57     my $self = {'info'=>{}, 
     56    my $class = shift(@_); 
     57    my $infodbtype = shift(@_); 
     58 
     59    # If the infodbtype wasn't passed in, use the default from dbutil 
     60    if (!defined($infodbtype)) 
     61    { 
     62      $infodbtype = &dbutil::get_default_infodb_type(); 
     63    } 
     64 
     65    my $self = {'infodbtype' => $infodbtype, 
     66        'info'=>{}, 
    5867        'reverse-info'=>{}, 
    5968        'order'=>[], 
     
    93102    my $infodb_map = {}; 
    94103 
    95     &dbutil::read_infodb_file("gdbm", $filename, $infodb_map); 
     104    &dbutil::read_infodb_file($self->{'infodbtype'}, $filename, $infodb_map); 
    96105 
    97106    foreach my $oid ( keys %$infodb_map ) { 
     
    130139    my $infodb_map = {}; 
    131140 
    132     &dbutil::read_infodb_keys("gdbm", $filename, $infodb_map); 
     141    &dbutil::read_infodb_keys($self->{'infodbtype'}, $filename, $infodb_map); 
    133142 
    134143    foreach my $file ( keys %$infodb_map ) { 
     
    163172    my $rev_infodb_map = {}; 
    164173 
    165     &dbutil::read_infodb_file("gdbm", $rev_filename, $rev_infodb_map); 
     174    &dbutil::read_infodb_file($self->{'infodbtype'}, $rev_filename, $rev_infodb_map); 
    166175 
    167176    foreach my $srcfile ( keys %$rev_infodb_map ) { 
     
    200209    # read it in 
    201210    my $infodb_map = {}; 
    202     &dbutil::read_infodb_file("gdbm", $filename, $infodb_map); 
     211    &dbutil::read_infodb_file($self->{'infodbtype'}, $filename, $infodb_map); 
    203212 
    204213    # change index-status values 
     
    218227 
    219228    # write out again 
    220     my $infodb_handle = &dbutil::open_infodb_write_handle("gdbm", $filename); 
     229    my $infodb_handle = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $filename); 
    221230    foreach my $oid ( keys %$infodb_map ) { 
    222231    # consider making the following a method in dbutil 
     
    224233 
    225234    # no need to escape, as $infodb_map->{$oid} hasn't been unescaped 
     235        # GDBM SPECIFIC! 
    226236    print $infodb_handle "[$oid]\n"; 
    227237    print $infodb_handle $infodb_map->{$oid}; 
    228238    print $infodb_handle '-' x 70, "\n"; 
    229239    } 
    230     &dbutil::close_infodb_write_handle("gdbm", $infodb_handle); 
     240    &dbutil::close_infodb_write_handle($self->{'infodbtype'}, $infodb_handle); 
    231241 
    232242} 
     
    240250    my $rev_infodb_map = $self->{'reverse-info'}; 
    241251    my $rev_infodb_handle  
    242     = &dbutil::open_infodb_write_handle("gdbm", $rev_filename, "append"); 
     252    = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $rev_filename, "append"); 
    243253 
    244254    foreach my $key ( keys %$rev_infodb_map ) { 
    245255    my $val_hash = $rev_infodb_map->{$key}; 
    246     &dbutil::write_infodb_entry("gdbm", $rev_infodb_handle, $key, $val_hash); 
    247     } 
    248     &dbutil::close_infodb_write_handle("gdbm", $rev_infodb_handle); 
     256    &dbutil::write_infodb_entry($self->{'infodbtype'}, $rev_infodb_handle, $key, $val_hash); 
     257    } 
     258    &dbutil::close_infodb_write_handle($self->{'infodbtype'}, $rev_infodb_handle); 
    249259 
    250260}