Changeset 32614

Show
Ignore:
Timestamp:
20.11.2018 10:50:17 (3 weeks ago)
Author:
kjdon
Message:

some changes to arcinfo to handle it holding the reverse lookup db too (from archiveinf-src) - make changes in this object, then write out the complete db at the end of import

Files:
1 modified

Legend:

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

    r31187 r32614  
    170170} 
    171171 
    172 sub load_revinfo_UNTESTED 
     172sub load_rev_info 
    173173{ 
    174174    my $self = shift (@_); 
     
    183183    my $vals = $rev_infodb_map->{$srcfile}; 
    184184 
    185     $srcfile = &util::abspath_to_placeholders($srcfile); 
    186  
     185    $srcfile = &util::placeholders_to_abspath($srcfile); 
    187186    foreach my $OID ($vals =~ m/^<oid>(.*)$/gm) { 
    188187        $self->add_reverseinfo($srcfile,$OID); 
     
    249248    my $self = shift (@_); 
    250249    my ($rev_filename) = @_; 
    251  
    252250    # Output reverse lookup database 
    253251 
    254252    my $rev_infodb_map = $self->{'reverse-info'}; 
    255     my $rev_infodb_handle  
    256     = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $rev_filename, "append"); 
     253    my $rev_infodb_handle 
     254    = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $rev_filename); 
     255#   = &dbutil::open_infodb_write_handle($self->{'infodbtype'}, $rev_filename, "append"); 
    257256 
    258257    foreach my $key ( keys %$rev_infodb_map ) { 
    259258    my $val_hash = $rev_infodb_map->{$key}; 
    260  
    261259    $key = &util::abspath_to_placeholders($key);     
    262260 
     
    270268    my $self = shift (@_); 
    271269    my ($filename) = @_; 
     270 
    272271    if ($filename =~ m/(contents)|(\.inf)$/) { 
    273272    $self->_save_info_txt($filename); 
     
    395394    } 
    396395 
     396    for (@$existing_oid) { 
     397    if ($_ eq $OID) { 
     398        return; # already in the list 
     399    } 
     400    } 
    397401    push(@$existing_oid,$OID); 
     402     
     403} 
     404 
     405sub remove_reverseinfo { 
     406     my $self = shift (@_); 
     407     my ($key, $OID) = @_; 
     408 
     409     my $existing_key = $self->{'reverse-info'}->{$key}; 
     410     if (!defined $existing_key) { 
     411     ###print STDERR "trying to remove entry for $key, but its not there!\n"; 
     412     return; 
     413     } 
     414     if (!defined $OID) { 
     415     ###print STDERR "no oid defined, removing whole entry\n"; 
     416     delete $self->{'reverse-info'}->{$key}; 
     417     return; 
     418     } 
     419     my $existing_oid = $existing_key->{'oid'}; 
     420     if (!defined $existing_oid) { 
     421     ###print STDERR "trying to remove entry for $key, but it has no oid field!\n"; 
     422     return; 
     423     } 
     424     for my $i (0..scalar(@$existing_oid)) { 
     425     if (@$existing_oid[$i] eq $OID) { 
     426         splice @$existing_oid, $i, 1; 
     427         if (scalar (@$existing_oid) ==0) { 
     428         ###print STDERRQ "have removed all oids, delete the main key\n"; 
     429         delete $self->{'reverse-info'}->{$key}; 
     430         } 
     431         return; 
     432     } 
     433     } 
     434} 
     435sub get_reverseinfo { 
     436    my $self = shift (@_); 
     437    my ($key) = @_; 
     438 
     439    if ($self->{'reverse-info'}->{$key}) { 
     440    return $self->{'reverse-info'}->{$key}->{'oid'}; 
     441    } 
     442    return undef; 
    398443} 
    399444