Changeset 2327


Ignore:
Timestamp:
2001-04-20T11:44:50+12:00 (23 years ago)
Author:
sjboddie
Message:

* empty log message *

Location:
trunk/gsdl/perllib
Files:
8 edited

Legend:

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

    r2326 r2327  
    4141# classification
    4242
     43my $OIDcount = 0;
     44
    4345sub new {
    4446    my $class = shift (@_);
     
    5052              'subsections'=>{},
    5153              'metadata'=>[],
    52               'text'=>""}, $class;
     54              'text'=>"",
     55              'OIDtype'=>"hash"}, $class;
    5356
    5457    $self->set_source_filename ($source_filename) if defined $source_filename;
     
    9396}
    9497
     98sub set_OIDtype {
     99    my $self = shift (@_);
     100    my ($type) = @_;
     101
     102    if ($type eq "incremental") {
     103    $self->{'OIDtype'} = $type;
     104    } else {
     105    $self->{'OIDtype'} = "hash";
     106    }
     107}
    95108
    96109sub set_source_filename {
     
    285298}
    286299
     300# calculate OID by hashing the contents of the document
    287301sub _calc_OID {
    288302    my $self = shift (@_);
     
    309323# methods dealing with OID, not groups of them.
    310324
    311 # if $OID is not provided one is calculated from hashing the
    312 # current contents of the document
    313 # An OID are actually stored as metadata of the document
     325# if $OID is not provided one is calculated
    314326sub set_OID {
    315327    my $self = shift (@_);
    316328    my ($OID) = @_;
    317329
    318     # if an OID wasn't provided then feed this document to
    319     # hashfile.exe
     330    # if an OID wasn't provided claculate one
    320331    if (!defined $OID) {
    321332    $OID = "NULL";
    322333
    323     my $filename = $self->get_source_filename();
    324     if (defined($filename) && -e $filename) {
    325 
    326         $OID = $self->_calc_OID ($filename);
    327 
     334    if ($self->{'OIDtype'} eq "incremental") {
     335        $OID = "D" . $OIDcount;
     336        $OIDcount ++;
     337       
    328338    } else {
    329 
    330         # this warning causes more confusion than it's worth I think
    331         # -- sorry Gordon.
    332 #       print STDERR "doc::set_OID source filename undefined/non-existant (continuing)\n";
     339        # "hash" OID - feed file to hashfile.exe
     340        my $filename = $self->get_source_filename();
     341        if (defined($filename) && -e $filename) {
     342
     343        $OID = $self->_calc_OID ($filename);
     344
     345        } else {
     346        $filename = &util::get_tmp_filename();
     347        if (!open (OUTFILE, ">$filename")) {
     348            print STDERR "doc::set_OID could not write to $filename\n";
     349        } else {
     350            $self->output_section('OUTFILE', $self->get_top_section(),
     351                      undef, 1);
     352            close (OUTFILE);
     353        }
    333354       
    334         $filename = &util::get_tmp_filename();
    335         if (!open (OUTFILE, ">$filename")) {
    336         print STDERR "doc::set_OID could not write to $filename\n";
    337         } else {
    338         $self->output_section('OUTFILE', $self->get_top_section(),
    339                       undef, 1);
    340         close (OUTFILE);
     355        $OID = $self->_calc_OID ($filename);
     356        &util::rm ($filename);
    341357        }
    342        
    343         $OID = $self->_calc_OID ($filename);
    344         &util::rm ($filename);
    345358    }
    346359    }
  • trunk/gsdl/perllib/docproc.pm

    r537 r2327  
    3333    my $self = {};
    3434
     35    $self->{'OIDtype'} = "hash";
     36
    3537    return bless $self, $class;
    3638}
     
    4345}
    4446
     47# OIDtype may be "hash" or "incremental"
     48sub set_OIDtype {
     49    my $self = shift (@_);
     50    my ($type) = @_;
     51
     52    if ($type eq "incremental") {
     53    $self->{'OIDtype'} = $type;
     54    } else {
     55    $self->{'OIDtype'} = "hash";
     56    }
     57}
     58
     59
    45601;
    4661
  • trunk/gsdl/perllib/plugins/BasPlug.pm

    r2235 r2327  
    285285    # create a new document
    286286    my $doc_obj = new doc ($filename, "indexed_doc");
     287    $doc_obj->set_OIDtype ($processor->{'OIDtype'});
    287288    $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Language", $language);
    288289    $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Encoding", $encoding);
  • trunk/gsdl/perllib/plugins/ConvertToPlug.pm

    r2241 r2327  
    265265    # create a new document
    266266    my $doc_obj = new doc ($conv_filename, "indexed_doc");
    267 
     267    $doc_obj->set_OIDtype ($processor->{'OIDtype'});
    268268    $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Language",
    269269                $language);
  • trunk/gsdl/perllib/plugins/FOXPlug.pm

    r537 r2327  
    229229    # create a new document
    230230    my $doc_obj = new doc ($file, "indexed_doc");
     231    $doc_obj->set_OIDtype ($processor->{'OIDtype'});
    231232    my $section = $doc_obj->get_top_section();
    232233
  • trunk/gsdl/perllib/plugins/HBPlug.pm

    r1424 r2327  
    227227    # create a new document
    228228    my $doc_obj = new doc ($file, "indexed_doc");
     229    $doc_obj->set_OIDtype ($processor->{'OIDtype'});
    229230
    230231    # copy the book cover if it exists
  • trunk/gsdl/perllib/plugins/ImagePlug.pm

    r2230 r2327  
    272272    # create a new document
    273273    my $doc_obj = new doc ($filename, "indexed_doc");
    274    
     274    $doc_obj->set_OIDtype ($processor->{'OIDtype'});   
     275
    275276    #run convert to get the thumbnail and extract size and type info
    276277    my $result = run_convert($self, $filename, $file, $doc_obj);
  • trunk/gsdl/perllib/plugins/SplitPlug.pm

    r2007 r2327  
    165165    # create a new document
    166166    my $doc_obj = new doc ($filename, "indexed_doc");
     167    $doc_obj->set_OIDtype ($processor->{'OIDtype'});
    167168    $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Language", $language);
    168169    $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Encoding", $encoding);
Note: See TracChangeset for help on using the changeset viewer.