Lines 8-13
use C4::AuthoritiesMarc;
Link Here
|
8 |
use C4::Biblio; |
8 |
use C4::Biblio; |
9 |
use C4::Record; |
9 |
use C4::Record; |
10 |
use Koha::CsvProfiles; |
10 |
use Koha::CsvProfiles; |
|
|
11 |
use Koha::Logger; |
11 |
|
12 |
|
12 |
sub _get_record_for_export { |
13 |
sub _get_record_for_export { |
13 |
my ($params) = @_; |
14 |
my ($params) = @_; |
Lines 22-32
sub _get_record_for_export {
Link Here
|
22 |
} elsif ( $record_type eq 'bibs' ) { |
23 |
} elsif ( $record_type eq 'bibs' ) { |
23 |
$record = _get_biblio_for_export( { %$params, biblionumber => $record_id } ); |
24 |
$record = _get_biblio_for_export( { %$params, biblionumber => $record_id } ); |
24 |
} else { |
25 |
} else { |
25 |
|
26 |
Koha::Logger->get->warn( "Record_type $record_type not supported." ); |
26 |
# TODO log "record_type not supported" |
|
|
27 |
return; |
28 |
} |
27 |
} |
29 |
|
|
|
30 |
return unless $record; |
28 |
return unless $record; |
31 |
|
29 |
|
32 |
if ($dont_export_fields) { |
30 |
if ($dont_export_fields) { |
Lines 99-105
sub export {
Link Here
|
99 |
my $csv_profile_id = $params->{csv_profile_id}; |
97 |
my $csv_profile_id = $params->{csv_profile_id}; |
100 |
my $output_filepath = $params->{output_filepath}; |
98 |
my $output_filepath = $params->{output_filepath}; |
101 |
|
99 |
|
102 |
return unless $record_type; |
100 |
if( !$record_type ) { |
|
|
101 |
Koha::Logger->get->warn( "No record_type given." ); |
102 |
return; |
103 |
} |
103 |
return unless @$record_ids; |
104 |
return unless @$record_ids; |
104 |
|
105 |
|
105 |
my $fh; |
106 |
my $fh; |
Lines 116-123
sub export {
Link Here
|
116 |
my $record = _get_record_for_export( { %$params, record_id => $record_id } ); |
117 |
my $record = _get_record_for_export( { %$params, record_id => $record_id } ); |
117 |
my $errorcount_on_decode = eval { scalar( MARC::File::USMARC->decode( $record->as_usmarc )->warnings() ) }; |
118 |
my $errorcount_on_decode = eval { scalar( MARC::File::USMARC->decode( $record->as_usmarc )->warnings() ) }; |
118 |
if ( $errorcount_on_decode or $@ ) { |
119 |
if ( $errorcount_on_decode or $@ ) { |
119 |
warn $@ if $@; |
120 |
my $msg = "Record $record_id could not be exported. " . |
120 |
warn "record (number $record_id) is invalid and therefore not exported because its reopening generates warnings above"; |
121 |
( $@ // '' ); |
|
|
122 |
chomp $msg; |
123 |
Koha::Logger->get->info( $msg ); |
121 |
next; |
124 |
next; |
122 |
} |
125 |
} |
123 |
print $record->as_usmarc(); |
126 |
print $record->as_usmarc(); |
Lines 130-136
sub export {
Link Here
|
130 |
print "\n"; |
133 |
print "\n"; |
131 |
for my $record_id (@$record_ids) { |
134 |
for my $record_id (@$record_ids) { |
132 |
my $record = _get_record_for_export( { %$params, record_id => $record_id } ); |
135 |
my $record = _get_record_for_export( { %$params, record_id => $record_id } ); |
133 |
next unless $record; |
136 |
if( !$record ) { |
|
|
137 |
Koha::Logger->get->info( "Record $record_id could not be exported." ); |
138 |
next; |
139 |
} |
134 |
print MARC::File::XML::record($record); |
140 |
print MARC::File::XML::record($record); |
135 |
print "\n"; |
141 |
print "\n"; |
136 |
} |
142 |
} |