/[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 38 by dpavlin, Sat Nov 12 21:21:50 2005 UTC revision 70 by dpavlin, Sat Nov 19 23:48:24 2005 UTC
# Line 11  WebPAC::Normalize - data mungling for no Line 11  WebPAC::Normalize - data mungling for no
11    
12  =head1 VERSION  =head1 VERSION
13    
14  Version 0.01  Version 0.02
15    
16  =cut  =cut
17    
18  our $VERSION = '0.01';  our $VERSION = '0.02';
19    
20  =head1 SYNOPSIS  =head1 SYNOPSIS
21    
# Line 122  C<conf/normalize/*.xml>. Line 122  C<conf/normalize/*.xml>.
122    
123  This structures are used to produce output.  This structures are used to produce output.
124    
125   my @ds = $webpac->data_structure($rec);   my $ds = $webpac->data_structure($rec);
126    
127  B<Note: historical oddity follows>  B<Note: historical oddity follows>
128    
# Line 143  sub data_structure { Line 143  sub data_structure {
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($rec);
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 > 0);                  return $ds if ($ds);
149                  $log->debug("cache miss, creating");                  $log->debug("cache miss, creating");
150          }          }
151    
# Line 160  sub data_structure { Line 160  sub data_structure {
160                  $self->{tags_by_order} = \@sorted_tags;                  $self->{tags_by_order} = \@sorted_tags;
161          }          }
162    
163          my @ds;          my $ds;
164    
165          $log->debug("tags: ",sub { join(", ",@sorted_tags) });          $log->debug("tags: ",sub { join(", ",@sorted_tags) });
166    
# Line 243  sub data_structure { Line 243  sub data_structure {
243    
244                          # TODO: name_sigular, name_plural                          # TODO: name_sigular, name_plural
245                          my $name = $self->{'import_xml'}->{'indexer'}->{$field}->{'name'};                          my $name = $self->{'import_xml'}->{'indexer'}->{$field}->{'name'};
246                          $row->{'name'} = $name ? $self->_x($name) : $field;                          my $row_name = $name ? $self->_x($name) : $field;
247    
248                          # post-sort all values in field                          # post-sort all values in field
249                          if ($self->{'import_xml'}->{'indexer'}->{$field}->{'sort'}) {                          if ($self->{'import_xml'}->{'indexer'}->{$field}->{'sort'}) {
250                                  $log->warn("sort at field tag not implemented");                                  $log->warn("sort at field tag not implemented");
251                          }                          }
252    
253                          push @ds, $row;                          $ds->{$row_name} = $row;
254    
255                          $log->debug("row $field: ",sub { Dumper($row) });                          $log->debug("row $field: ",sub { Dumper($row) });
256                  }                  }
257    
258          }          }
259    
260            $log->logdie("there is no current_filename defined! Do you have filename tag in conf/normalize/?.xml") unless ($self->{'current_filename'});
261    
262          $self->{'db'}->save_ds(          $self->{'db'}->save_ds(
263                  ds => \@ds,                  ds => $ds,
264                  current_filename => $self->{'current_filename'},                  current_filename => $self->{'current_filename'},
265                  headline => $self->{'headline'},                  headline => $self->{'headline'},
266          ) if ($self->{'db'});          ) if ($self->{'db'});
267    
268          $log->debug("ds: ", sub { Dumper(@ds) });          $log->debug("ds: ", sub { Dumper($ds) });
269    
270            $log->logconfess("data structure returned is not array any more!") if wantarray;
271    
272          return @ds;          return $ds;
273    
274  }  }
275    
# Line 538  sub get_data { Line 542  sub get_data {
542                  if ($sf && $$rec->{$f}->[$i]->{$sf}) {                  if ($sf && $$rec->{$f}->[$i]->{$sf}) {
543                          $$found++ if (defined($$found));                          $$found++ if (defined($$found));
544                          return $$rec->{$f}->[$i]->{$sf};                          return $$rec->{$f}->[$i]->{$sf};
545                  } elsif ($$rec->{$f}->[$i]) {                  } elsif (! $sf && $$rec->{$f}->[$i]) {
546                          $$found++ if (defined($$found));                          $$found++ if (defined($$found));
547                          # it still might have subfield, just                          # it still might have subfield, just
548                          # not specified, so we'll dump all                          # not specified, so we'll dump all
# Line 551  sub get_data { Line 555  sub get_data {
555                          } else {                          } else {
556                                  return $$rec->{$f}->[$i];                                  return $$rec->{$f}->[$i];
557                          }                          }
558                    } else {
559                            return '';
560                  }                  }
561          } else {          } else {
562                  return '';                  return '';

Legend:
Removed from v.38  
changed lines
  Added in v.70

  ViewVC Help
Powered by ViewVC 1.1.26