|
Lines 352-359
sub ModAuthInBatch {
Link Here
|
| 352 |
|
352 |
|
| 353 |
( $batch_id, $num_records, $num_items, @invalid_records ) = |
353 |
( $batch_id, $num_records, $num_items, @invalid_records ) = |
| 354 |
BatchStageMarcRecords( |
354 |
BatchStageMarcRecords( |
| 355 |
$encoding, $marc_records, |
355 |
$record_type, $encoding, |
| 356 |
$file_name, $to_marc_plugin, |
356 |
$marc_records, $file_name, |
| 357 |
$marc_modification_template, $comments, |
357 |
$marc_modification_template, $comments, |
| 358 |
$branch_code, $parse_items, |
358 |
$branch_code, $parse_items, |
| 359 |
$leave_as_staging, $progress_interval, |
359 |
$leave_as_staging, $progress_interval, |
|
Lines 367-373
sub BatchStageMarcRecords {
Link Here
|
| 367 |
my $encoding = shift; |
367 |
my $encoding = shift; |
| 368 |
my $marc_records = shift; |
368 |
my $marc_records = shift; |
| 369 |
my $file_name = shift; |
369 |
my $file_name = shift; |
| 370 |
my $to_marc_plugin = shift; |
|
|
| 371 |
my $marc_modification_template = shift; |
370 |
my $marc_modification_template = shift; |
| 372 |
my $comments = shift; |
371 |
my $comments = shift; |
| 373 |
my $branch_code = shift; |
372 |
my $branch_code = shift; |
|
Lines 399-411
sub BatchStageMarcRecords {
Link Here
|
| 399 |
SetImportBatchItemAction($batch_id, 'ignore'); |
398 |
SetImportBatchItemAction($batch_id, 'ignore'); |
| 400 |
} |
399 |
} |
| 401 |
|
400 |
|
| 402 |
$marc_records = Koha::Plugins::Handler->run( |
|
|
| 403 |
{ |
| 404 |
class => $to_marc_plugin, |
| 405 |
method => 'to_marc', |
| 406 |
params => { data => $marc_records } |
| 407 |
} |
| 408 |
) if $to_marc_plugin && @$marc_records; |
| 409 |
|
401 |
|
| 410 |
my $marc_type = C4::Context->preference('marcflavour'); |
402 |
my $marc_type = C4::Context->preference('marcflavour'); |
| 411 |
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth'); |
403 |
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth'); |
|
Lines 1556-1561
sub RecordsFromMARCXMLFile {
Link Here
|
| 1556 |
return (\@errors, \@marcRecords); |
1548 |
return (\@errors, \@marcRecords); |
| 1557 |
} |
1549 |
} |
| 1558 |
|
1550 |
|
|
|
1551 |
=head2 RecordsFromMarcPlugin |
| 1552 |
|
| 1553 |
Converts text of input_file into array of MARC records with to_marc plugin |
| 1554 |
|
| 1555 |
=cut |
| 1556 |
|
| 1557 |
sub RecordsFromMarcPlugin { |
| 1558 |
my ($input_file, $plugin_class, $encoding) = @_; |
| 1559 |
|
| 1560 |
# Read input file |
| 1561 |
open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n"; |
| 1562 |
my ( $text, $marc, @return ); |
| 1563 |
$/ = "\035"; |
| 1564 |
while (<IN>) { |
| 1565 |
s/^\s+//; |
| 1566 |
s/\s+$//; |
| 1567 |
next unless $_; |
| 1568 |
$text .= $_; |
| 1569 |
} |
| 1570 |
close IN; |
| 1571 |
|
| 1572 |
# Convert to large MARC blob with plugin |
| 1573 |
$text = Koha::Plugins::Handler->run({ |
| 1574 |
class => $plugin_class, |
| 1575 |
method => 'to_marc', |
| 1576 |
params => { data => $text }, |
| 1577 |
}); |
| 1578 |
|
| 1579 |
# Convert to array of MARC records |
| 1580 |
my $marc_type = C4::Context->preference('marcflavour'); |
| 1581 |
foreach my $blob ( split(/\x1D/, $text) ) { |
| 1582 |
next if $blob =~ /^\s*$/; |
| 1583 |
my ($marcrecord) = MarcToUTF8Record($blob, $marc_type, $encoding); |
| 1584 |
push @return, $marcrecord; |
| 1585 |
} |
| 1586 |
return \@return; |
| 1587 |
} |
| 1588 |
|
| 1559 |
# internal functions |
1589 |
# internal functions |
| 1560 |
|
1590 |
|
| 1561 |
sub _create_import_record { |
1591 |
sub _create_import_record { |