--- trunk/run.pl 2007/06/21 12:53:41 866 +++ trunk/run.pl 2007/08/23 20:57:00 884 @@ -299,7 +299,7 @@ # now WebPAC::Store # my $abs_path = abs_path($0); - $abs_path =~ s#/[^/]*$#/#; + $abs_path =~ s#/[^/]*$#/#; # my $db_path = $config->webpac('db_path'); @@ -315,6 +315,20 @@ debug => $debug, ); + # + # prepare output + # + my @outputs; + if (defined( $db_config->{output} )) { + my $module = $db_config->{output}->{module} || $log->logdie("need module in output section of $database"); + $module = 'WebPAC::Output::' . $module unless $module =~ m/::/; + $log->debug("loading output module $module"); + eval "require $module"; + my $out = new $module->new( $db_config->{output} ); + $out->init; + push @outputs, $out; + } + # # now, iterate through input formats @@ -362,6 +376,7 @@ stats => $stats, modify_records => $input->{modify_records}, modify_file => $input->{modify_file}, + input_config => $input, ); $log->logdie("can't create input using $input_module") unless ($input); @@ -506,7 +521,7 @@ my $mfn = $row->{'000'}->[0]; - if (! $mfn || $mfn !~ m#^\d+$#) { + if (! $mfn || $mfn !~ m{^\d+$}) { $log->warn("record $pos doesn't have valid MFN but '$mfn', using $pos"); $mfn = $pos; push @{ $row->{'000'} }, $pos; @@ -568,6 +583,11 @@ $log->info("Created $i instances of MFN $mfn\n") if ($i > 1); } + + foreach my $out ( @outputs ) { + $out->add( $mfn, $ds ) if $out->can('add'); + } + } if ($validate) { @@ -598,6 +618,10 @@ eval { $indexer->finish } if ($indexer && $indexer->can('finish')); + foreach my $out ( @outputs ) { + $out->finish if $out->can('finish'); + } + my $dt = time() - $start_t; $log->info("$total_rows records ", $indexer ? "indexed " : "", sprintf("in %.2f sec [%.2f rec/sec]",