/[webpac2]/trunk/lib/WebPAC/Normalize.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Normalize.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 124 by dpavlin, Sun Nov 20 20:13:39 2005 UTC revision 125 by dpavlin, Thu Nov 24 11:47:15 2005 UTC
# Line 124  This structures are used to produce outp Line 124  This structures are used to produce outp
124    
125   my $ds = $webpac->data_structure($rec);   my $ds = $webpac->data_structure($rec);
126    
 B<Note: historical oddity follows>  
   
 This method will also set C<< $webpac->{'currnet_filename'} >> if there is  
 C<< <filename> >> tag and C<< $webpac->{'headline'} >> if there is  
 C<< <headline> >> tag.  
   
127  =cut  =cut
128    
129  sub data_structure {  sub data_structure {
# Line 140  sub data_structure { Line 134  sub data_structure {
134          my $rec = shift;          my $rec = shift;
135          $log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o);          $log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o);
136    
137            $log->debug("data_structure rec = ", sub { Dumper($rec) });
138    
139            $log->logdie("need unique ID (mfn) in field 000 of record ", sub { Dumper($rec) } ) unless (defined($rec->{'000'}));
140    
141            my $mfn = $rec->{'000'}->[0] || $log->logdie("field 000 isn't array!");
142    
143          my $cache_file;          my $cache_file;
144    
145          if ($self->{'db'}) {          if ($self->{'db'}) {
146                  my $ds = $self->{'db'}->load_ds($rec);                  my $ds = $self->{'db'}->load_ds( $mfn );
147                  $log->debug("load_ds( rec = ", sub { Dumper($rec) }, ") = ", sub { Dumper($ds) });                  $log->debug("load_ds( rec = ", sub { Dumper($rec) }, ") = ", sub { Dumper($ds) });
148                  return $ds if ($ds);                  return $ds if ($ds);
149                  $log->debug("cache miss, creating");                  $log->debug("cache miss, creating");
# Line 195  sub data_structure { Line 195  sub data_structure {
195                                  @v = map { $self->apply_format($tag->{'format_name'},$tag->{'format_delimiter'},$_) } @v;                                  @v = map { $self->apply_format($tag->{'format_name'},$tag->{'format_delimiter'},$_) } @v;
196                          }                          }
197    
                         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!  
                         }  
   
198                          # delimiter will join repeatable fields                          # delimiter will join repeatable fields
199                          if ($tag->{'delimiter'}) {                          if ($tag->{'delimiter'}) {
200                                  @v = ( join($tag->{'delimiter'}, @v) );                                  @v = ( join($tag->{'delimiter'}, @v) );
# Line 257  sub data_structure { Line 248  sub data_structure {
248    
249          }          }
250    
         $log->logdie("there is no current_filename defined! Do you have filename tag in conf/normalize/?.xml") unless ($self->{'current_filename'});  
   
251          $self->{'db'}->save_ds(          $self->{'db'}->save_ds(
252                    id => $mfn,
253                  ds => $ds,                  ds => $ds,
                 current_filename => $self->{'current_filename'},  
                 headline => $self->{'headline'},  
254          ) if ($self->{'db'});          ) if ($self->{'db'});
255    
256          $log->debug("ds: ", sub { Dumper($ds) });          $log->debug("ds: ", sub { Dumper($ds) });

Legend:
Removed from v.124  
changed lines
  Added in v.125

  ViewVC Help
Powered by ViewVC 1.1.26