1 package Koha::Authority::MergeRequest;
3 # Copyright Rijksmuseum 2017
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 use parent qw(Koha::Object);
24 use Koha::Authorities;
25 use Koha::Authority::MergeRequests;
26 use Koha::Authority::Types;
30 Koha::Authority::MergeRequest - Koha::Object class for single need_merge_authorities record
34 use Koha::Authority::MergeRequest;
42 =head2 INSTANCE METHODS
48 [ authid_new => $new, ]
49 [ oldrecord => $marc, ]
52 authid refers to the old authority id,
53 authid_new optionally refers to a new different authority id
55 oldrecord is the MARC record belonging to the original authority record
57 This method returns an object and initializes the reportxml property.
62 my ( $class, $params ) = @_;
63 my $oldrecord = delete $params->{oldrecord};
64 delete $params->{reportxml}; # just making sure it is empty
65 my $self = $class->SUPER::new( $params );
67 if( $self->authid && $oldrecord ) {
68 my $auth = Koha::Authorities->find( $self->authid );
69 my $type = $auth ? Koha::Authority::Types->find($auth->authtypecode) : undef;
70 $self->reportxml( Koha::Authority::MergeRequests->reporting_tag_xml({ record => $oldrecord, tag => $type->auth_tag_to_report })) if $type;
77 my $record = $self->oldmarc;
79 Convert reportxml back to MARC::Record.
85 return if !$self->reportxml;
86 return MARC::Record->new_from_xml( $self->reportxml, 'UTF-8' );
93 Returns name of corresponding DBIC resultset
98 return 'NeedMergeAuthority';
103 Marcel de Rooy (Rijksmuseum)
105 Koha Development Team