Changeset 15699

Show
Ignore:
Timestamp:
26.05.2008 15:49:58 (11 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Moving the write_infodb_entry() functions from basebuildproc.pm into a new dbutil.pm file, since we need to use these from basebuilder.pm and classify.pm too.

Location:
gsdl/trunk/perllib
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/basebuildproc.pm

    r15698 r15699  
    3232 
    3333use classify; 
     34use dbutil; 
    3435use doc; 
    3536use docproc; 
     
    374375    my $doc_OID = $doc_obj->get_OID(); 
    375376    my $first = 1; 
     377    my $infodb_handle = $self->{'output_handle'}; 
    376378 
    377379    $self->{'doc_mdprefix_fields'} = {}; 
     
    427429        # special case for URL metadata 
    428430        if ($field =~ /^URL$/i) { 
    429             $self->write_infodb_entry($value, { 'section' => [ $section_OID ] }); 
     431            &dbutil::write_infodb_entry($infodb_handle, $value, { 'section' => [ $section_OID ] }); 
    430432        } 
    431433 
     
    504506    }  
    505507     
    506     $self->write_infodb_entry($section_OID, \%section_infodb); 
     508    &dbutil::write_infodb_entry($infodb_handle, $section_OID, \%section_infodb); 
    507509     
    508510    # output a database entry for the document number 
    509511    if ($self->{'db_level'} eq "document") { 
    510         $self->write_infodb_entry($self->{'num_docs'}, { 'section' => [ $doc_OID ] }); 
     512        &dbutil::write_infodb_entry($infodb_handle, $self->{'num_docs'}, { 'section' => [ $doc_OID ] }); 
    511513    } 
    512514    else { 
    513         $self->write_infodb_entry($self->{'num_sections'}, { 'section' => [ $section_OID ] }); 
     515        &dbutil::write_infodb_entry($infodb_handle, $self->{'num_sections'}, { 'section' => [ $section_OID ] }); 
    514516    } 
    515517 
     
    518520    last if ($self->{'db_level'} eq "document"); # if no sections wanted, only add the docs 
    519521    } 
    520 } 
    521  
    522  
    523 sub write_infodb_entry 
    524 { 
    525     my $self = shift(@_); 
    526  
    527     $self->write_infodb_entry_gdbm(@_); 
    528 } 
    529  
    530      
    531 sub write_infodb_entry_gdbm 
    532 { 
    533     my $self = shift(@_); 
    534     my $infodb_key = shift(@_); 
    535     my $infodb_map = shift(@_); 
    536  
    537     my $handle = $self->{'output_handle'}; 
    538  
    539     print $handle "[$infodb_key]\n"; 
    540     foreach my $infodb_value_key (keys(%$infodb_map)) 
    541     { 
    542     foreach my $infodb_value (@{$infodb_map->{$infodb_value_key}}) 
    543     { 
    544         if ($infodb_value =~ /-{70,}/) 
    545         { 
    546         # if value contains 70 or more hyphens in a row we need to escape them 
    547         # to prevent txt2db from treating them as a separator 
    548         $infodb_value =~ s/-/&\#045;/gi; 
    549         } 
    550         print $handle "<$infodb_value_key>" . $infodb_value . "\n"; 
    551     } 
    552     } 
    553     print $handle '-' x 70, "\n"; 
    554522} 
    555523