Bug 30779: Remove _update_import_record_marc and update tests
[koha.git] / Koha / Import / Record.pm
1 package Koha::Import::Record;
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18 use Modern::Perl;
19
20 use Carp;
21 use MARC::Record;
22
23 use C4::Context;
24 use Koha::Database;
25
26 use base qw(Koha::Object);
27
28 =head1 NAME
29
30 Koha::Import::Record - Koha Import Record Object class
31
32 =head1 API
33
34 =head2 Class methods
35
36 =head3 get_marc_record
37
38 Returns a MARC::Record object
39
40     my $marc_record = $import_record->get_marc_record()
41
42 =cut
43
44 sub get_marc_record {
45     my ($self) = @_;
46
47     my $marcflavour = C4::Context->preference('marcflavour');
48
49     my $format = $marcflavour eq 'UNIMARC' ? 'UNIMARC' : 'USMARC';
50     if ($marcflavour eq 'UNIMARC' && $self->record_type eq 'auth') {
51         $format = 'UNIMARCAUTH';
52     }
53
54     my $record = MARC::Record->new_from_xml($self->marcxml, $self->encoding, $format);
55
56     return $record;
57 }
58
59 =head2 Internal methods
60
61 =head3 _type
62
63 Returns name of corresponding DBIC resultset
64
65 =cut
66
67 sub _type {
68     return 'ImportRecord';
69 }
70
71 1;