Lines 404-410
sub BatchStageMarcRecords {
Link Here
|
404 |
method => 'to_marc', |
404 |
method => 'to_marc', |
405 |
params => { data => $marc_records } |
405 |
params => { data => $marc_records } |
406 |
} |
406 |
} |
407 |
) if $to_marc_plugin; |
407 |
) if $to_marc_plugin && @$marc_records; |
408 |
|
408 |
|
409 |
my $marc_type = C4::Context->preference('marcflavour'); |
409 |
my $marc_type = C4::Context->preference('marcflavour'); |
410 |
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth'); |
410 |
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth'); |
Lines 1473-1483
Reads ISO2709 binary porridge from the given file and creates MARC::Record-objec
Link Here
|
1473 |
@PARAM2, String, see stage_file.pl |
1473 |
@PARAM2, String, see stage_file.pl |
1474 |
@PARAM3, String, should be utf8 |
1474 |
@PARAM3, String, should be utf8 |
1475 |
|
1475 |
|
|
|
1476 |
Returns two array refs. |
1477 |
|
1476 |
=cut |
1478 |
=cut |
1477 |
|
1479 |
|
1478 |
sub RecordsFromISO2709File { |
1480 |
sub RecordsFromISO2709File { |
1479 |
my ($input_file, $record_type, $encoding) = @_; |
1481 |
my ($input_file, $record_type, $encoding) = @_; |
1480 |
my $errors; |
1482 |
my @errors; |
1481 |
|
1483 |
|
1482 |
my $marc_type = C4::Context->preference('marcflavour'); |
1484 |
my $marc_type = C4::Context->preference('marcflavour'); |
1483 |
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth'); |
1485 |
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth'); |
Lines 1493-1532
sub RecordsFromISO2709File {
Link Here
|
1493 |
my ($marc_record, $charset_guessed, $char_errors) = MarcToUTF8Record($_, $marc_type, $encoding); |
1495 |
my ($marc_record, $charset_guessed, $char_errors) = MarcToUTF8Record($_, $marc_type, $encoding); |
1494 |
push @marc_records, $marc_record; |
1496 |
push @marc_records, $marc_record; |
1495 |
if ($charset_guessed ne $encoding) { |
1497 |
if ($charset_guessed ne $encoding) { |
1496 |
$errors = '' unless $errors; |
1498 |
push @errors, |
1497 |
$errors .= "Unexpected charset $charset_guessed, expecting $encoding\n"; |
1499 |
"Unexpected charset $charset_guessed, expecting $encoding"; |
1498 |
} |
1500 |
} |
1499 |
} |
1501 |
} |
1500 |
close IN; |
1502 |
close IN; |
1501 |
return ($errors, \@marc_records); |
1503 |
return ( \@errors, \@marc_records ); |
1502 |
} |
1504 |
} |
1503 |
|
1505 |
|
1504 |
=head2 RecordsFromMARCXMLFile |
1506 |
=head2 RecordsFromMARCXMLFile |
1505 |
|
1507 |
|
1506 |
my ($errors, $records) = C4::ImportBatch::RecordsFromMARCXMLFile($input_file, $encoding); |
1508 |
my ($errors, $records) = C4::ImportBatch::RecordsFromMARCXMLFile($input_file, $encoding); |
1507 |
|
1509 |
|
1508 |
|
|
|
1509 |
|
1510 |
Creates MARC::Record-objects out of the given MARCXML-file. |
1510 |
Creates MARC::Record-objects out of the given MARCXML-file. |
1511 |
|
1511 |
|
1512 |
@PARAM1, String, absolute path to the ISO2709 file. |
1512 |
@PARAM1, String, absolute path to the ISO2709 file. |
1513 |
@PARAM2, String, should be utf8 |
1513 |
@PARAM2, String, should be utf8 |
1514 |
|
1514 |
|
|
|
1515 |
Returns two array refs. |
1516 |
|
1515 |
=cut |
1517 |
=cut |
1516 |
|
1518 |
|
1517 |
sub RecordsFromMARCXMLFile { |
1519 |
sub RecordsFromMARCXMLFile { |
1518 |
my ( $filename, $encoding ) = @_; |
1520 |
my ( $filename, $encoding ) = @_; |
1519 |
my $batch = MARC::File::XML->in( $filename ); |
1521 |
my $batch = MARC::File::XML->in( $filename ); |
1520 |
my @marcRecords; |
1522 |
my ( @marcRecords, @errors, $record ); |
1521 |
my @errors; |
|
|
1522 |
do { |
1523 |
do { |
1523 |
eval { |
1524 |
eval { $record = $batch->next( $encoding ); }; |
1524 |
my $record = $batch->next($encoding); |
|
|
1525 |
push @marcRecords, $record if $record; |
1526 |
}; |
1527 |
if ($@) { |
1525 |
if ($@) { |
1528 |
push @errors, $@; |
1526 |
push @errors, $@; |
1529 |
} |
1527 |
} |
|
|
1528 |
push @marcRecords, $record if $record; |
1530 |
} while( $record ); |
1529 |
} while( $record ); |
1531 |
return (\@errors, \@marcRecords); |
1530 |
return (\@errors, \@marcRecords); |
1532 |
} |
1531 |
} |