From: Dobrica Pavlinusic Date: Tue, 26 Sep 2006 10:23:04 +0000 (+0000) Subject: r1018@llin: dpavlin | 2006-09-26 12:20:52 +0200 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=2432a6b1731948422022d534064aa1b8682d4e9c;p=webpac2 r1018@llin: dpavlin | 2006-09-26 12:20:52 +0200 correct creation of lookups (by database and input) git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@712 07558da8-63fa-0310-ba24-9fe276d99e06 --- diff --git a/conf/log.conf b/conf/log.conf index c796592..69c0c83 100644 --- a/conf/log.conf +++ b/conf/log.conf @@ -7,7 +7,7 @@ log4perl.rootLogger=INFO, LOG, SCREEN # you can specify methods from WebPAC here also! #log4perl.logger.main=INFO -#log4perl.logger.main=DEBUG +log4perl.logger.main=DEBUG #log4perl.logger.WebPAC=DEBUG diff --git a/conf/lookup/ffkk-arti.pl b/conf/lookup/ffkk-arti.pl index 104bd7b..f81d60c 100644 --- a/conf/lookup/ffkk-arti.pl +++ b/conf/lookup/ffkk-arti.pl @@ -1,17 +1,17 @@ marc('777','v', lookup( - sub { 'ffkk/perl' . rec('000') }, + sub { 'ffkk/peri' . rec('000') }, 'ffkk','peri', sub { rec('11') } ) || lookup( - sub { 'ffkk/perl' . rec('000') }, + sub { 'ffkk/peri' . rec('000') }, 'ffkk','peri', sub { first(rec(200,'a')) . ' ' . first(rec('200','e')) }, ) || lookup( - sub { "ffkk/perl" . rec('000') }, + sub { "ffkk/peri" . rec('000') }, 'ffkk','peri', sub { rec(200,'a') }, sub { rec(900,'x') }, diff --git a/lib/WebPAC/Normalize.pm b/lib/WebPAC/Normalize.pm index 2bbdc37..6abf00c 100644 --- a/lib/WebPAC/Normalize.pm +++ b/lib/WebPAC/Normalize.pm @@ -962,7 +962,7 @@ sub lookup { Save value into lookup. - save_into_lookup($key,sub { + save_into_lookup($database,$input,$key,sub { # code which produce one or more values }); @@ -971,13 +971,15 @@ This function shouldn't be called directly, it's called from code created by L{'000'}->[0] || die "mfn not defined or zero"; foreach my $v ( $coderef->() ) { - $lookup->{$k}->{$v}->{$mfn}++; - warn "# lookup $k $v $mfn saved\n" if ($debug > 1); + $lookup->{$database}->{$input}->{$key}->{$v}->{$mfn}++; + warn "# saved lookup $database/$input/$key [$v] $mfn\n"; #if ($debug > 1); } } diff --git a/lib/WebPAC/Parser.pm b/lib/WebPAC/Parser.pm index d3d54d2..667a930 100644 --- a/lib/WebPAC/Parser.pm +++ b/lib/WebPAC/Parser.pm @@ -296,13 +296,15 @@ sub _parse_lookups { $log->debug("key = $key"); - my $create = "save_into_lookup('$key', $e[7] $e[8] );\n"; - - $log->debug("create: $create"); - return $self->_lookup_error("invalid database $e[3] in $path" ) unless $self->valid_database( $e[3] ); return $self->_lookup_error("invalid input $e[5] of database $e[3] in $path", ) unless $self->valid_database_input( $e[3], $e[5] ); + my $create = qq{ + save_into_lookup($e[3],$e[5],'$key', $e[7] $e[8] ); + }; + + $log->debug("create: $create"); + # save code to create this lookup $self->{_lookup_create}->{ _q($e[3]) }->{ _q($e[5]) } .= $create; $self->{_lookup_create_key}->{ _q($e[3]) }->{ _q($e[5]) }->{ _q($key) }++; diff --git a/run.pl b/run.pl index 93363eb..6b7311f 100755 --- a/run.pl +++ b/run.pl @@ -391,10 +391,12 @@ while (my ($database, $db_config) = each %{ $config->databases }) { my $lookup_data = WebPAC::Normalize::_get_lookup(); - $log->debug("created following lookups: ", dump( $lookup_data )); + if (defined( $lookup_data->{$database}->{$input_name} )) { + $log->debug("created following lookups: ", dump( $lookup_data )); - foreach my $key (keys %$lookup_data) { - $store->save_lookup( $database, $input_name, $key, $lookup_data->{$key} ); + foreach my $key (keys %{ $lookup_data->{$database}->{$input_name} }) { + $store->save_lookup( $database, $input_name, $key, $lookup_data->{$database}->{$input_name}->{$key} ); + } } my $report_fh;