--- trunk/run.pl 2006/09/25 16:07:20 709 +++ trunk/run.pl 2006/09/25 18:58:43 710 @@ -9,7 +9,7 @@ use WebPAC::Common 0.02; use WebPAC::Parser 0.04; use WebPAC::Input 0.13; -use WebPAC::Store 0.03; +use WebPAC::Store 0.10; use WebPAC::Normalize 0.11; use WebPAC::Output::TT; use WebPAC::Validate 0.06; @@ -294,7 +294,7 @@ $log->info("working on database '$database' in $db_path"); } - my $db = new WebPAC::Store( + my $store = new WebPAC::Store( path => $db_path, database => $database, debug => $debug, @@ -316,7 +316,9 @@ foreach my $input (@inputs) { - next if ($only_input && ($input->{name} !~ m#$only_input#i && $input->{type} !~ m#$only_input#i)); + my $input_name = $input->{name} || $log->logdie("input without a name isn't valid: ",dump($input)); + + next if ($only_input && ($input_name !~ m#$only_input#i && $input->{type} !~ m#$only_input#i)); my $type = lc($input->{type}); @@ -326,7 +328,7 @@ my @lookups = $parser->have_lookup_create($database, $input); - $log->info("working on input '$input->{name}' in $input->{path} [type: $input->{type}] using $input_module", + $log->info("working on input '$input_name' in $input->{path} [type: $input->{type}] using $input_module", @lookups ? " creating lookups: ".join(", ", @lookups) : "" ); @@ -349,7 +351,7 @@ $log->logdie("can't create input using $input_module") unless ($input); if (defined( $input->{lookup} )) { - $log->warn("$database/", $input->{name}, " has depriciated lookup definition, removing it..."); + $log->warn("$database/$input_name has depriciated lookup definition, removing it..."); delete( $input->{lookup} ); } @@ -387,14 +389,20 @@ %{ $input }, ); - $log->debug("created following lookups: ", dump( WebPAC::Normalize::_get_lookup() ) ); + my $lookup_data = WebPAC::Normalize::_get_lookup(); + + $log->debug("created following lookups: ", dump( $lookup_data )); + + foreach my $key (keys %$lookup_data) { + $store->save_lookup( $database, $input_name, $key, $lookup_data->{$key} ); + } my $report_fh; if ($stats || $validate) { - my $path = "out/report/" . $database . '-' . $input->{name} . '.txt'; + 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 ", + 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"); } @@ -405,7 +413,7 @@ if ($marc_normalize) { @norm_array = ( { path => $marc_normalize, - output => $marc_output || 'out/marc/' . $database . '-' . $input->{name} . '.marc', + output => $marc_output || "out/marc/${database}-${input_name}.marc", } ); } @@ -461,14 +469,14 @@ marc_encoding => 'utf-8', ); - $db->save_ds( + $store->save_ds( id => $mfn, ds => $ds, - prefix => $input->{name}, + prefix => $input_name, ) if ($ds && !$stats); $indexer->add( - id => $input->{name} . "/" . $mfn, + id => "${input_name}/${mfn}", ds => $ds, type => $config->get($indexer_config)->{type}, ) if ($indexer && $ds);