Lines 405-411
sub BatchStageMarcRecords {
Link Here
|
405 |
method => 'to_marc', |
405 |
method => 'to_marc', |
406 |
params => { data => $marc_records } |
406 |
params => { data => $marc_records } |
407 |
} |
407 |
} |
408 |
) if $to_marc_plugin; |
408 |
) if $to_marc_plugin && @$marc_records; |
409 |
|
409 |
|
410 |
my $marc_type = C4::Context->preference('marcflavour'); |
410 |
my $marc_type = C4::Context->preference('marcflavour'); |
411 |
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth'); |
411 |
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth'); |
Lines 1492-1502
Reads ISO2709 binary porridge from the given file and creates MARC::Record-objec
Link Here
|
1492 |
@PARAM2, String, see stage_file.pl |
1492 |
@PARAM2, String, see stage_file.pl |
1493 |
@PARAM3, String, should be utf8 |
1493 |
@PARAM3, String, should be utf8 |
1494 |
|
1494 |
|
|
|
1495 |
Returns two array refs. |
1496 |
|
1495 |
=cut |
1497 |
=cut |
1496 |
|
1498 |
|
1497 |
sub RecordsFromISO2709File { |
1499 |
sub RecordsFromISO2709File { |
1498 |
my ($input_file, $record_type, $encoding) = @_; |
1500 |
my ($input_file, $record_type, $encoding) = @_; |
1499 |
my $errors; |
1501 |
my @errors; |
1500 |
|
1502 |
|
1501 |
my $marc_type = C4::Context->preference('marcflavour'); |
1503 |
my $marc_type = C4::Context->preference('marcflavour'); |
1502 |
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth'); |
1504 |
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth'); |
Lines 1512-1551
sub RecordsFromISO2709File {
Link Here
|
1512 |
my ($marc_record, $charset_guessed, $char_errors) = MarcToUTF8Record($_, $marc_type, $encoding); |
1514 |
my ($marc_record, $charset_guessed, $char_errors) = MarcToUTF8Record($_, $marc_type, $encoding); |
1513 |
push @marc_records, $marc_record; |
1515 |
push @marc_records, $marc_record; |
1514 |
if ($charset_guessed ne $encoding) { |
1516 |
if ($charset_guessed ne $encoding) { |
1515 |
$errors = '' unless $errors; |
1517 |
push @errors, |
1516 |
$errors .= "Unexpected charset $charset_guessed, expecting $encoding\n"; |
1518 |
"Unexpected charset $charset_guessed, expecting $encoding"; |
1517 |
} |
1519 |
} |
1518 |
} |
1520 |
} |
1519 |
close IN; |
1521 |
close IN; |
1520 |
return ($errors, \@marc_records); |
1522 |
return ( \@errors, \@marc_records ); |
1521 |
} |
1523 |
} |
1522 |
|
1524 |
|
1523 |
=head2 RecordsFromMARCXMLFile |
1525 |
=head2 RecordsFromMARCXMLFile |
1524 |
|
1526 |
|
1525 |
my ($errors, $records) = C4::ImportBatch::RecordsFromMARCXMLFile($input_file, $encoding); |
1527 |
my ($errors, $records) = C4::ImportBatch::RecordsFromMARCXMLFile($input_file, $encoding); |
1526 |
|
1528 |
|
1527 |
|
|
|
1528 |
|
1529 |
Creates MARC::Record-objects out of the given MARCXML-file. |
1529 |
Creates MARC::Record-objects out of the given MARCXML-file. |
1530 |
|
1530 |
|
1531 |
@PARAM1, String, absolute path to the ISO2709 file. |
1531 |
@PARAM1, String, absolute path to the ISO2709 file. |
1532 |
@PARAM2, String, should be utf8 |
1532 |
@PARAM2, String, should be utf8 |
1533 |
|
1533 |
|
|
|
1534 |
Returns two array refs. |
1535 |
|
1534 |
=cut |
1536 |
=cut |
1535 |
|
1537 |
|
1536 |
sub RecordsFromMARCXMLFile { |
1538 |
sub RecordsFromMARCXMLFile { |
1537 |
my ( $filename, $encoding ) = @_; |
1539 |
my ( $filename, $encoding ) = @_; |
1538 |
my $batch = MARC::File::XML->in( $filename ); |
1540 |
my $batch = MARC::File::XML->in( $filename ); |
1539 |
my @marcRecords; |
1541 |
my ( @marcRecords, @errors, $record ); |
1540 |
my @errors; |
|
|
1541 |
do { |
1542 |
do { |
1542 |
eval { |
1543 |
eval { $record = $batch->next( $encoding ); }; |
1543 |
my $record = $batch->next($encoding); |
|
|
1544 |
push @marcRecords, $record if $record; |
1545 |
}; |
1546 |
if ($@) { |
1544 |
if ($@) { |
1547 |
push @errors, $@; |
1545 |
push @errors, $@; |
1548 |
} |
1546 |
} |
|
|
1547 |
push @marcRecords, $record if $record; |
1549 |
} while( $record ); |
1548 |
} while( $record ); |
1550 |
return (\@errors, \@marcRecords); |
1549 |
return (\@errors, \@marcRecords); |
1551 |
} |
1550 |
} |