Changeset 13315


Ignore:
Timestamp:
2006-11-22T17:15:40+13:00 (18 years ago)
Author:
shaoqun
Message:

uses the stardand method to set doc ID and new param list for the read method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/DBPlug.pm

    r12741 r13315  
    8484}
    8585
    86 
    8786sub read {
    8887    my $self = shift (@_);
    89     my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_;
    90 
    91    
    92     # see if we can handle the passed file...
    93     my ($block_status,$filename) = $self->read_block(@_);   
    94     return $block_status if ((!defined $block_status) || ($block_status==0));
     88    my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs,$total_count,$gli) = @_;
     89       
     90     #see if we can handle the passed file...
     91     my ($block_status,$filename) = $self->read_block(@_);   
     92     return $block_status if ((!defined $block_status) || ($block_status==0));
    9593
    9694    my $outhandle = $self->{'outhandle'};
     
    9997    print $outhandle "DBPlug: processing $file\n"
    10098    if $self->{'verbosity'} > 1;
     99   
    101100    require DBI; # database independent stuff
    102101
    103102    # calculate the document hash, for document ids
    104     my $hash="";
    105 
    106     my $osexe = &util::get_os_exe();
    107     my $hashfile_exe = &util::filename_cat($ENV{'GSDLHOME'},"bin",
    108                        $ENV{'GSDLOS'},"hashfile$osexe");
    109     if (-e "$hashfile_exe") {
    110     $hash = `hashfile$osexe \"$filename\"`;
    111     $hash =~ /:\s*([0-9a-f]+)/i;
    112     $hash="HASH$1";
    113     }
    114 
    115 
     103    my $hash="0";
     104
     105   
    116106    # default options - may be overridden by config file
    117107    my $language=undef;
     
    133123    my %callbacks=();
    134124
     125
    135126    # read in config file.
    136127    if (!open (CONF, $filename)) {
    137128        print $outhandle "DBPlug: can't read $filename: $!\n";
    138129        return 0;
    139     }
     130    }
     131   
    140132    my $line;
    141133    my $statement="";
     
    200192    close CONF;
    201193
     194   
    202195    if (!defined($db)) {
    203196    print $outhandle "DBPlug: error: $filename does not specify a db!\n";
     
    230223    }
    231224
     225 
    232226    $statement_hand=$dbhandle->prepare($sql_query);
    233227    $statement_hand->execute;
    234228    if ($statement_hand->err) {
    235         print $outhandle "Error: " . $statement_hand->errstr . "\n";
     229        print $outhandle "Error:" . $statement_hand->errstr . "\n";
    236230    return undef;
    237231    }
     
    342336    }
    343337
     338
    344339    if (!defined $unique_id) {
    345         $doc_obj->set_OID($hash . "s$count");
     340             $doc_obj->set_OID();
     341             my $id = $doc_obj->get_OID();     
     342         $doc_obj->set_OID($id."s$count");
    346343    } else {
    347344        # use our id from the database...
     
    352349        # process the document
    353350    $processor->process($doc_obj);
    354 
    355351
    356352    $count++;
Note: See TracChangeset for help on using the changeset viewer.