Lines 255-282
sub export {
Link Here
|
255 |
} |
255 |
} |
256 |
if ( $format eq 'iso2709' ) { |
256 |
if ( $format eq 'iso2709' ) { |
257 |
my $encoding_validator = sub { |
257 |
my $encoding_validator = sub { |
258 |
my ($record_type) = @_; |
258 |
my ($record, $record_type) = @_; |
259 |
return sub { |
259 |
my $errorcount_on_decode = eval { scalar(MARC::File::USMARC->decode($record->as_usmarc)->warnings()) }; |
260 |
my ($record) = @_; |
260 |
if ($errorcount_on_decode || $@) { |
261 |
my $errorcount_on_decode = eval { scalar(MARC::File::USMARC->decode($record->as_usmarc)->warnings()) }; |
261 |
my ($id_tag, $id_subfield) = GetMarcFromKohaField('biblio.biblionumber', ''); |
262 |
if ($errorcount_on_decode || $@) { |
262 |
my $record_id = $record->subfield($id_tag, $id_subfield); |
263 |
my ($id_tag, $id_subfield) = GetMarcFromKohaField('biblio.biblionumber', ''); |
263 |
my $msg = "$record_type $record_id could not be USMARC decoded/encoded. " . ($@ // ''); |
264 |
my $record_id = $record->subfield($id_tag, $id_subfield); |
264 |
chomp $msg; |
265 |
my $msg = "$record_type $record_id could not be USMARC decoded/encoded. " . ($@ // ''); |
265 |
Koha::Logger->get->warn($msg); |
266 |
chomp $msg; |
266 |
return 0; |
267 |
Koha::Logger->get->warn($msg); |
|
|
268 |
return 0; |
269 |
} |
270 |
return 1; |
271 |
} |
267 |
} |
|
|
268 |
return 1; |
272 |
}; |
269 |
}; |
273 |
my $validator = $encoding_validator->('Record'); |
270 |
for my $record (grep { $encoding_validator->($_, 'Record') } @records) { |
274 |
for my $record (grep { $validator->($_) } @records) { |
|
|
275 |
print $record->as_usmarc(); |
271 |
print $record->as_usmarc(); |
276 |
} |
272 |
} |
277 |
if (@deleted_records) { |
273 |
if (@deleted_records) { |
278 |
$validator = $encoding_validator->('Deleted record'); |
274 |
for my $deleted_record (grep { $encoding_validator->($_, 'Deleted record') } @deleted_records) { |
279 |
for my $deleted_record (grep { $validator->($_) } @deleted_records) { |
|
|
280 |
print $deleted_record->as_usmarc(); |
275 |
print $deleted_record->as_usmarc(); |
281 |
} |
276 |
} |
282 |
} |
277 |
} |
283 |
- |
|
|