Changeset 13315
- Timestamp:
- 2006-11-22T17:15:40+13:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/DBPlug.pm
r12741 r13315 84 84 } 85 85 86 87 86 sub read { 88 87 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)); 95 93 96 94 my $outhandle = $self->{'outhandle'}; … … 99 97 print $outhandle "DBPlug: processing $file\n" 100 98 if $self->{'verbosity'} > 1; 99 101 100 require DBI; # database independent stuff 102 101 103 102 # 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 116 106 # default options - may be overridden by config file 117 107 my $language=undef; … … 133 123 my %callbacks=(); 134 124 125 135 126 # read in config file. 136 127 if (!open (CONF, $filename)) { 137 128 print $outhandle "DBPlug: can't read $filename: $!\n"; 138 129 return 0; 139 } 130 } 131 140 132 my $line; 141 133 my $statement=""; … … 200 192 close CONF; 201 193 194 202 195 if (!defined($db)) { 203 196 print $outhandle "DBPlug: error: $filename does not specify a db!\n"; … … 230 223 } 231 224 225 232 226 $statement_hand=$dbhandle->prepare($sql_query); 233 227 $statement_hand->execute; 234 228 if ($statement_hand->err) { 235 print $outhandle "Error: 229 print $outhandle "Error:" . $statement_hand->errstr . "\n"; 236 230 return undef; 237 231 } … … 342 336 } 343 337 338 344 339 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"); 346 343 } else { 347 344 # use our id from the database... … … 352 349 # process the document 353 350 $processor->process($doc_obj); 354 355 351 356 352 $count++;
Note:
See TracChangeset
for help on using the changeset viewer.