From: Dobrica Pavlinusic Date: Thu, 24 Nov 2005 11:47:15 +0000 (+0000) Subject: r9089@llin: dpavlin | 2005-11-24 12:47:02 +0100 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=bcbe9e9c4f2e67c54b14cd89325d51a6e656ee19;p=webpac2 r9089@llin: dpavlin | 2005-11-24 12:47:02 +0100 fixed for new Webpac::DB 0.02 git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@125 07558da8-63fa-0310-ba24-9fe276d99e06 --- diff --git a/lib/WebPAC/Normalize.pm b/lib/WebPAC/Normalize.pm index 89df722..1cb9f93 100644 --- a/lib/WebPAC/Normalize.pm +++ b/lib/WebPAC/Normalize.pm @@ -124,12 +124,6 @@ This structures are used to produce output. my $ds = $webpac->data_structure($rec); -B - -This method will also set C<< $webpac->{'currnet_filename'} >> if there is -C<< >> tag and C<< $webpac->{'headline'} >> if there is -C<< >> tag. - =cut sub data_structure { @@ -140,10 +134,16 @@ sub data_structure { my $rec = shift; $log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o); + $log->debug("data_structure rec = ", sub { Dumper($rec) }); + + $log->logdie("need unique ID (mfn) in field 000 of record ", sub { Dumper($rec) } ) unless (defined($rec->{'000'})); + + my $mfn = $rec->{'000'}->[0] || $log->logdie("field 000 isn't array!"); + my $cache_file; if ($self->{'db'}) { - my $ds = $self->{'db'}->load_ds($rec); + my $ds = $self->{'db'}->load_ds( $mfn ); $log->debug("load_ds( rec = ", sub { Dumper($rec) }, ") = ", sub { Dumper($ds) }); return $ds if ($ds); $log->debug("cache miss, creating"); @@ -195,15 +195,6 @@ sub data_structure { @v = map { $self->apply_format($tag->{'format_name'},$tag->{'format_delimiter'},$_) } @v; } - if ($field eq 'filename') { - $self->{'current_filename'} = join('',@v); - $log->debug("filename: ",$self->{'current_filename'}); - } elsif ($field eq 'headline') { - $self->{'headline'} .= join('',@v); - $log->debug("headline: ",$self->{'headline'}); - next; # don't return headline in data_structure! - } - # delimiter will join repeatable fields if ($tag->{'delimiter'}) { @v = ( join($tag->{'delimiter'}, @v) ); @@ -257,12 +248,9 @@ sub data_structure { } - $log->logdie("there is no current_filename defined! Do you have filename tag in conf/normalize/?.xml") unless ($self->{'current_filename'}); - $self->{'db'}->save_ds( + id => $mfn, ds => $ds, - current_filename => $self->{'current_filename'}, - headline => $self->{'headline'}, ) if ($self->{'db'}); $log->debug("ds: ", sub { Dumper($ds) });