--- trunk/run.pl 2006/09/11 11:57:18 664 +++ trunk/run.pl 2006/09/13 17:32:49 675 @@ -232,8 +232,6 @@ use WebPAC::Output::EstraierNative; $indexer = new WebPAC::Output::EstraierNative( %{ $indexer_config } ); - $use_indexer = 'hyperestraier'; - } elsif ($use_indexer eq 'kinosearch') { # open KinoSearch @@ -363,6 +361,16 @@ %{ $input }, ); + my $report_fh; + if ($stats || $validate) { + my $path = "out/report/" . $database . '-' . $input->{name} . '.txt'; + open($report_fh, '>', $path) || $log->logdie("can't open $path: $!"); + + print $report_fh "Report for database '$database' input '$input->{name}' records ", + $offset || 1, "-", $limit || $input->{limit} || $maxmfn, "\n\n"; + $log->info("Generating report file $path"); + } + my @norm_array = ref($input->{normalize}) eq 'ARRAY' ? @{ $input->{normalize} } : ( $input->{normalize} ); @@ -392,6 +400,10 @@ # reset position in database $input_db->seek(1); + # generate name of config key for indexer (strip everything after -) + my $indexer_config = $use_indexer; + $indexer_config =~ s/^(\w+)-?.*$/$1/g if ($indexer_config); + foreach my $pos ( 0 ... $input_db->size ) { my $row = $input_db->fetch || next; @@ -408,7 +420,7 @@ if ($validate) { if ( my $errors = $validate->validate_errors( $row, $input_db->dump ) ) { $log->error( "MFN $mfn validation error:\n", - dump( $errors ) + $validate->report_error( $errors ) ); } } @@ -441,7 +453,7 @@ $indexer->add( id => $input->{name} . "/" . $mfn, ds => $ds, - type => $config->{$use_indexer}->{type}, + type => $config->{$indexer_config}->{type}, ) if ($indexer && $ds); if ($marc) { @@ -465,14 +477,23 @@ if ($validate) { my $errors = $validate->report; - $log->info("validation errors:\n$errors\n" ) if ($errors); + if ($errors) { + $log->info("validation errors:\n$errors\n" ); + print $report_fh "$errors\n" if ($report_fh); + } } - $log->info("statistics of fields usage:\n", $input_db->stats) if ($stats); + if ($stats) { + my $s = $input_db->stats; + $log->info("statistics of fields usage:\n$s"); + print $report_fh "Statistics of fields usage:\n$s" if ($report_fh); + } # close MARC file $marc->finish if ($marc); + # close report + close($report_fh) if ($report_fh) } }