72 |
id => $mfn, |
id => $mfn, |
73 |
fields => WebPAC::Normalize::_get_marc_fields(), |
fields => WebPAC::Normalize::_get_marc_fields(), |
74 |
leader => WebPAC::Normalize::marc_leader(), |
leader => WebPAC::Normalize::marc_leader(), |
75 |
|
row => $row, |
76 |
); |
); |
77 |
|
|
78 |
|
C<row> is optional parametar which is used when dumping original row to |
79 |
|
error log. |
80 |
|
|
81 |
=cut |
=cut |
82 |
|
|
83 |
sub add { |
sub add { |
114 |
|
|
115 |
if ($self->{lint}) { |
if ($self->{lint}) { |
116 |
$self->{lint}->check_record( $marc ); |
$self->{lint}->check_record( $marc ); |
117 |
my $err = join( "\n", $self->{lint}->warnings ); |
my @w = $self->{lint}->warnings; |
118 |
$log->error("MARC lint detected warning on record $id\n", |
if (@w) { |
119 |
"<<<<< Original imput row:\n",dump($arg->{row}), "\n", |
$log->error("MARC lint detected warning on record $id\n", |
120 |
">>>>> Normalized MARC row: leader: [", $marc->leader(), "]\n", dump( $arg->{fields} ), "\n", |
"<<<<< Original imput row:\n",dump($arg->{row}), "\n", |
121 |
"!!!!! MARC lint warnings:\n",$err,"\n" |
">>>>> Normalized MARC row: leader: [", $marc->leader(), "]\n", dump( $arg->{fields} ), "\n", |
122 |
) if ($err); |
"!!!!! MARC lint warnings:\n",join("\n",@w),"\n" |
123 |
|
); |
124 |
|
map { $self->{_marc_lint_warnings}->{$_}++ } @w; |
125 |
|
} |
126 |
} |
} |
127 |
|
|
128 |
if ($self->{dump}) { |
if ($self->{dump}) { |
142 |
|
|
143 |
$marc->finish; |
$marc->finish; |
144 |
|
|
145 |
|
It will also dump MARC lint warnings summary if called with C<lint>. |
146 |
|
|
147 |
=cut |
=cut |
148 |
|
|
149 |
sub finish { |
sub finish { |
150 |
my $self = shift; |
my $self = shift; |
151 |
|
|
152 |
close( $self->{fh} ) or $self->_get_logger->logdie("can't close ", $self->{path}, ": $!"); |
my $log = $self->get_logger; |
153 |
|
|
154 |
|
close( $self->{fh} ) or $log->logdie("can't close ", $self->{path}, ": $!"); |
155 |
|
|
156 |
|
if (my $w = $self->{_marc_lint_warnings}) { |
157 |
|
$log->error("MARC lint warnings summary:\n", |
158 |
|
join ("\n", |
159 |
|
map { $w->{$_} . "\t" . $_ } |
160 |
|
sort { $w->{$b} <=> $w->{$a} } keys %$w |
161 |
|
) |
162 |
|
); |
163 |
|
} |
164 |
} |
} |
165 |
|
|
166 |
=head1 AUTHOR |
=head1 AUTHOR |