View | Details | Raw Unified | Return to bug 15380
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-2 / +2 lines)
Lines 26-32 use C4::AuthoritiesMarc::MARC21; Link Here
26
use C4::AuthoritiesMarc::UNIMARC;
26
use C4::AuthoritiesMarc::UNIMARC;
27
use C4::Charset;
27
use C4::Charset;
28
use C4::Log;
28
use C4::Log;
29
use Koha::Authority;
29
use Koha::MetadataRecord::Authority;
30
30
31
use vars qw($VERSION @ISA @EXPORT);
31
use vars qw($VERSION @ISA @EXPORT);
32
32
Lines 801-807 Returns MARC::Record of the authority passed in parameter. Link Here
801
801
802
sub GetAuthority {
802
sub GetAuthority {
803
    my ($authid)=@_;
803
    my ($authid)=@_;
804
    my $authority = Koha::Authority->get_from_authid($authid);
804
    my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
805
    return unless $authority;
805
    return unless $authority;
806
    return ($authority->record);
806
    return ($authority->record);
807
}
807
}
(-)a/Koha/Exporter/Record.pm (-1 / +1 lines)
Lines 52-58 sub _get_record_for_export { Link Here
52
sub _get_authority_for_export {
52
sub _get_authority_for_export {
53
    my ($params) = @_;
53
    my ($params) = @_;
54
    my $authid = $params->{authid} || return;
54
    my $authid = $params->{authid} || return;
55
    my $authority = Koha::Authority->get_from_authid($authid);
55
    my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
56
    return unless $authority;
56
    return unless $authority;
57
    return $authority->record;
57
    return $authority->record;
58
}
58
}
(-)a/Koha/Filter/MARC/EmbedSeeFromHeadings.pm (-2 / +2 lines)
Lines 33-39 Filter to embed see from headings into MARC records. Link Here
33
use strict;
33
use strict;
34
use warnings;
34
use warnings;
35
use Carp;
35
use Carp;
36
use Koha::Authority;
36
use Koha::MetadataRecord::Authority;
37
use C4::Biblio qw/GetMarcFromKohaField/;
37
use C4::Biblio qw/GetMarcFromKohaField/;
38
38
39
use base qw(Koha::RecordProcessor::Base);
39
use base qw(Koha::RecordProcessor::Base);
Lines 83-89 sub _processrecord { Link Here
83
83
84
        next unless $authid;
84
        next unless $authid;
85
85
86
        my $authority = Koha::Authority->get_from_authid($authid);
86
        my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
87
        next unless $authority;
87
        next unless $authority;
88
        my $auth_marc = $authority->record;
88
        my $auth_marc = $authority->record;
89
        my @seefrom = $auth_marc->field('4..');
89
        my @seefrom = $auth_marc->field('4..');
(-)a/Koha/Authority.pm (-10 / +10 lines)
Lines 1-4 Link Here
1
package Koha::Authority;
1
package Koha::MetadataRecord::Authority;
2
2
3
# Copyright 2012 C & P Bibliography Services
3
# Copyright 2012 C & P Bibliography Services
4
#
4
#
Lines 19-25 package Koha::Authority; Link Here
19
19
20
=head1 NAME
20
=head1 NAME
21
21
22
Koha::Authority - class to encapsulate authority records in Koha
22
Koha::MetadataRecord::Authority - class to encapsulate authority records in Koha
23
23
24
=head1 SYNOPSIS
24
=head1 SYNOPSIS
25
25
Lines 45-53 __PACKAGE__->mk_accessors(qw( authid authtype )); Link Here
45
45
46
=head2 new
46
=head2 new
47
47
48
    my $auth = Koha::Authority->new($record);
48
    my $auth = Koha::MetadataRecord::Authority->new($record);
49
49
50
Create a new Koha::Authority object based on the provided record.
50
Create a new Koha::MetadataRecord::Authority object based on the provided record.
51
51
52
=cut
52
=cut
53
53
Lines 69-77 sub new { Link Here
69
69
70
=head2 get_from_authid
70
=head2 get_from_authid
71
71
72
    my $auth = Koha::Authority->get_from_authid($authid);
72
    my $auth = Koha::MetadataRecord::Authority->get_from_authid($authid);
73
73
74
Create the Koha::Authority object associated with the provided authid.
74
Create the Koha::MetadataRecord::Authority object associated with the provided authid.
75
Note that this routine currently retrieves a MARC record because
75
Note that this routine currently retrieves a MARC record because
76
authorities in Koha are MARC records by definition. This is an
76
authorities in Koha are MARC records by definition. This is an
77
unfortunate but unavoidable fact.
77
unfortunate but unavoidable fact.
Lines 92-98 sub get_from_authid { Link Here
92
    return if ($@);
92
    return if ($@);
93
    $record->encoding('UTF-8');
93
    $record->encoding('UTF-8');
94
94
95
    # NOTE: GuessAuthTypeCode has no business in Koha::Authority, which is an
95
    # NOTE: GuessAuthTypeCode has no business in Koha::MetadataRecord::Authority, which is an
96
    #       object-oriented class. Eventually perhaps there will be utility
96
    #       object-oriented class. Eventually perhaps there will be utility
97
    #       classes in the Koha:: namespace, but there are not at the moment,
97
    #       classes in the Koha:: namespace, but there are not at the moment,
98
    #       so this shim seems like the best option all-around.
98
    #       so this shim seems like the best option all-around.
Lines 110-118 sub get_from_authid { Link Here
110
110
111
=head2 get_from_breeding
111
=head2 get_from_breeding
112
112
113
    my $auth = Koha::Authority->get_from_authid($authid);
113
    my $auth = Koha::MetadataRecord::Authority->get_from_authid($authid);
114
114
115
Create the Koha::Authority object associated with the provided authid.
115
Create the Koha::MetadataRecord::Authority object associated with the provided authid.
116
116
117
=cut
117
=cut
118
118
Lines 130-136 sub get_from_breeding { Link Here
130
    return if ($@);
130
    return if ($@);
131
    $record->encoding('UTF-8');
131
    $record->encoding('UTF-8');
132
132
133
    # NOTE: GuessAuthTypeCode has no business in Koha::Authority, which is an
133
    # NOTE: GuessAuthTypeCode has no business in Koha::MetadataRecord::Authority, which is an
134
    #       object-oriented class. Eventually perhaps there will be utility
134
    #       object-oriented class. Eventually perhaps there will be utility
135
    #       classes in the Koha:: namespace, but there are not at the moment,
135
    #       classes in the Koha:: namespace, but there are not at the moment,
136
    #       so this shim seems like the best option all-around.
136
    #       so this shim seems like the best option all-around.
(-)a/authorities/merge.pl (-4 / +4 lines)
Lines 23-29 use CGI qw ( -utf8 ); Link Here
23
use C4::Output;
23
use C4::Output;
24
use C4::Auth;
24
use C4::Auth;
25
use C4::AuthoritiesMarc;
25
use C4::AuthoritiesMarc;
26
use Koha::Authority;
26
use Koha::MetadataRecord::Authority;
27
use C4::Koha;
27
use C4::Koha;
28
use C4::Biblio;
28
use C4::Biblio;
29
29
Lines 92-104 else { Link Here
92
        push @errors, { code => "WRONG_COUNT", value => scalar(@authid) };
92
        push @errors, { code => "WRONG_COUNT", value => scalar(@authid) };
93
    }
93
    }
94
    else {
94
    else {
95
        my $recordObj1 = Koha::Authority->get_from_authid($authid[0]) || Koha::Authority->new();
95
        my $recordObj1 = Koha::MetadataRecord::Authority->get_from_authid($authid[0]) || Koha::MetadataRecord::Authority->new();
96
        my $recordObj2;
96
        my $recordObj2;
97
97
98
        if (defined $mergereference && $mergereference eq 'breeding') {
98
        if (defined $mergereference && $mergereference eq 'breeding') {
99
            $recordObj2 =  Koha::Authority->get_from_breeding($authid[1]) || Koha::Authority->new();
99
            $recordObj2 =  Koha::MetadataRecord::Authority->get_from_breeding($authid[1]) || Koha::MetadataRecord::Authority->new();
100
        } else {
100
        } else {
101
            $recordObj2 =  Koha::Authority->get_from_authid($authid[1]) || Koha::Authority->new();
101
            $recordObj2 =  Koha::MetadataRecord::Authority->get_from_authid($authid[1]) || Koha::MetadataRecord::Authority->new();
102
        }
102
        }
103
103
104
        if ($mergereference) {
104
        if ($mergereference) {
(-)a/misc/export_records.pl (-1 / +1 lines)
Lines 167-173 elsif ( $record_type eq 'auths' ) { Link Here
167
            : (),
167
            : (),
168
        ( $authtype ? ( authtypecode => $authtype ) : () ),
168
        ( $authtype ? ( authtypecode => $authtype ) : () ),
169
    };
169
    };
170
    # Koha::Authority is not a Koha::Object...
170
    # Koha::MetadataRecord::Authority is not a Koha::Object...
171
    my $authorities = Koha::Database->new->schema->resultset('AuthHeader')->search( $conditions );
171
    my $authorities = Koha::Database->new->schema->resultset('AuthHeader')->search( $conditions );
172
    @record_ids = map { $_->authid } $authorities->all;
172
    @record_ids = map { $_->authid } $authorities->all;
173
}
173
}
(-)a/svc/records/preview (-2 / +2 lines)
Lines 23-29 use C4::Auth qw( get_template_and_user ); Link Here
23
use C4::Biblio qw( GetMarcBiblio );
23
use C4::Biblio qw( GetMarcBiblio );
24
use C4::MarcModificationTemplates qw( ModifyRecordWithTemplate );
24
use C4::MarcModificationTemplates qw( ModifyRecordWithTemplate );
25
use C4::Output qw( output_html_with_http_headers );
25
use C4::Output qw( output_html_with_http_headers );
26
use Koha::Authority;
26
use Koha::MetadataRecord::Authority;
27
27
28
my $query = CGI->new();
28
my $query = CGI->new();
29
my $record_id = $query->param('record_id');
29
my $record_id = $query->param('record_id');
Lines 34-40 my $record; Link Here
34
if ( $record_type eq 'biblio' ) {
34
if ( $record_type eq 'biblio' ) {
35
    $record = GetMarcBiblio( $record_id );
35
    $record = GetMarcBiblio( $record_id );
36
} else {
36
} else {
37
    my $authority = Koha::Authority->get_from_authid( $record_id );
37
    my $authority = Koha::MetadataRecord::Authority->get_from_authid( $record_id );
38
    $record = $authority->record;
38
    $record = $authority->record;
39
}
39
}
40
40
(-)a/t/db_dependent/Koha_Authority.t (-9 / +9 lines)
Lines 24-30 use C4::Context; Link Here
24
use Test::More;
24
use Test::More;
25
25
26
BEGIN {
26
BEGIN {
27
        use_ok('Koha::Authority');
27
        use_ok('Koha::MetadataRecord::Authority');
28
}
28
}
29
29
30
my $record = MARC::Record->new;
30
my $record = MARC::Record->new;
Lines 34-42 $record->add_fields( Link Here
34
        [ '150', ' ', ' ', a => 'Cooking' ],
34
        [ '150', ' ', ' ', a => 'Cooking' ],
35
        [ '450', ' ', ' ', a => 'Cookery' ],
35
        [ '450', ' ', ' ', a => 'Cookery' ],
36
        );
36
        );
37
my $authority = Koha::Authority->new($record);
37
my $authority = Koha::MetadataRecord::Authority->new($record);
38
38
39
is(ref($authority), 'Koha::Authority', 'Created valid Koha::Authority object');
39
is(ref($authority), 'Koha::MetadataRecord::Authority', 'Created valid Koha::MetadataRecord::Authority object');
40
40
41
is($authority->authorized_heading(), 'Cooking', 'Authorized heading was correct');
41
is($authority->authorized_heading(), 'Cooking', 'Authorized heading was correct');
42
42
Lines 53-67 SKIP: Link Here
53
        $authid = $row->{'authid'};
53
        $authid = $row->{'authid'};
54
    }
54
    }
55
    skip 'No authorities', 3 unless $authid;
55
    skip 'No authorities', 3 unless $authid;
56
    $authority = Koha::Authority->get_from_authid($authid);
56
    $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
57
57
58
    is(ref($authority), 'Koha::Authority', 'Retrieved valid Koha::Authority object');
58
    is(ref($authority), 'Koha::MetadataRecord::Authority', 'Retrieved valid Koha::MetadataRecord::Authority object');
59
59
60
    is($authority->authid, $authid, 'Object authid is correct');
60
    is($authority->authid, $authid, 'Object authid is correct');
61
61
62
    is($authority->record->field('001')->data(), $authid, 'Retrieved correct record');
62
    is($authority->record->field('001')->data(), $authid, 'Retrieved correct record');
63
63
64
    $authority = Koha::Authority->get_from_authid('alphabetsoup');
64
    $authority = Koha::MetadataRecord::Authority->get_from_authid('alphabetsoup');
65
    is($authority, undef, 'No invalid record is retrieved');
65
    is($authority, undef, 'No invalid record is retrieved');
66
}
66
}
67
67
Lines 77-91 SKIP: Link Here
77
    }
77
    }
78
78
79
    skip 'No authorities in reservoir', 3 unless $import_record_id;
79
    skip 'No authorities in reservoir', 3 unless $import_record_id;
80
    $authority = Koha::Authority->get_from_breeding($import_record_id);
80
    $authority = Koha::MetadataRecord::Authority->get_from_breeding($import_record_id);
81
81
82
    is(ref($authority), 'Koha::Authority', 'Retrieved valid Koha::Authority object');
82
    is(ref($authority), 'Koha::MetadataRecord::Authority', 'Retrieved valid Koha::MetadataRecord::Authority object');
83
83
84
    is($authority->authid, undef, 'Records in reservoir do not have an authid');
84
    is($authority->authid, undef, 'Records in reservoir do not have an authid');
85
85
86
    is(ref($authority->record), 'MARC::Record', 'MARC record attached to authority');
86
    is(ref($authority->record), 'MARC::Record', 'MARC record attached to authority');
87
87
88
    $authority = Koha::Authority->get_from_breeding('alphabetsoup');
88
    $authority = Koha::MetadataRecord::Authority->get_from_breeding('alphabetsoup');
89
    is($authority, undef, 'No invalid record is retrieved from reservoir');
89
    is($authority, undef, 'No invalid record is retrieved from reservoir');
90
}
90
}
91
91
(-)a/t/db_dependent/RecordProcessor_EmbedSeeFromHeadings.t (-2 / +2 lines)
Lines 21-27 use strict; Link Here
21
use warnings;
21
use warnings;
22
use File::Spec;
22
use File::Spec;
23
use MARC::Record;
23
use MARC::Record;
24
use Koha::Authority;
24
use Koha::MetadataRecord::Authority;
25
25
26
use Test::More;
26
use Test::More;
27
use Test::MockModule;
27
use Test::MockModule;
Lines 82-88 subtest "EmbedSeeFromHeadings should skip holdings fields" => sub { Link Here
82
    );
82
    );
83
83
84
84
85
    my $koha_authority = new Test::MockModule('Koha::Authority');
85
    my $koha_authority = new Test::MockModule('Koha::MetadataRecord::Authority');
86
    $koha_authority->mock( 'get_from_authid', sub {
86
    $koha_authority->mock( 'get_from_authid', sub {
87
87
88
        my $auth_record = MARC::Record->new;
88
        my $auth_record = MARC::Record->new;
(-)a/tools/batch_record_modification.pl (-3 / +3 lines)
Lines 29-35 use C4::AuthoritiesMarc qw( BuildSummary GetAuthTypeCode ModAuthority ); Link Here
29
use C4::BackgroundJob;
29
use C4::BackgroundJob;
30
use C4::Biblio qw( GetMarcBiblio ModBiblio );
30
use C4::Biblio qw( GetMarcBiblio ModBiblio );
31
use C4::MarcModificationTemplates qw( GetModificationTemplateActions GetModificationTemplates ModifyRecordWithTemplate );
31
use C4::MarcModificationTemplates qw( GetModificationTemplateActions GetModificationTemplates ModifyRecordWithTemplate );
32
use Koha::Authority;
32
use Koha::MetadataRecord::Authority;
33
33
34
my $input = new CGI;
34
my $input = new CGI;
35
our $dbh = C4::Context->dbh;
35
our $dbh = C4::Context->dbh;
Lines 128-134 if ( $op eq 'form' ) { Link Here
128
            push @records, $biblio;
128
            push @records, $biblio;
129
        } else {
129
        } else {
130
            # Retrieve authority information
130
            # Retrieve authority information
131
            my $authority = Koha::Authority->get_from_authid( $record_id );
131
            my $authority = Koha::MetadataRecord::Authority->get_from_authid( $record_id );
132
            unless ( $authority ) {
132
            unless ( $authority ) {
133
                push @messages, {
133
                push @messages, {
134
                    type => 'warning',
134
                    type => 'warning',
Lines 213-219 if ( $op eq 'form' ) { Link Here
213
            # Authorities
213
            # Authorities
214
            my $authid = $record_id;
214
            my $authid = $record_id;
215
            my $error = eval {
215
            my $error = eval {
216
                my $authority = Koha::Authority->get_from_authid( $authid );
216
                my $authority = Koha::MetadataRecord::Authority->get_from_authid( $authid );
217
                my $record = $authority->record;
217
                my $record = $authority->record;
218
                ModifyRecordWithTemplate( $mmtid, $record );
218
                ModifyRecordWithTemplate( $mmtid, $record );
219
                ModAuthority( $authid, $record, GetAuthTypeCode( $authid ) );
219
                ModAuthority( $authid, $record, GetAuthTypeCode( $authid ) );
(-)a/tools/export.pl (-2 / +1 lines)
Lines 168-174 if ( $op eq "export" ) { Link Here
168
                        : (),
168
                        : (),
169
                    ( $authtype ? ( authtypecode => $authtype ) : () ),
169
                    ( $authtype ? ( authtypecode => $authtype ) : () ),
170
                };
170
                };
171
                # Koha::Authority is not a Koha::Object...
171
                # Koha::MetadataRecord::Authority is not a Koha::Object...
172
                my $authorities = Koha::Database->new->schema->resultset('AuthHeader')->search( $conditions );
172
                my $authorities = Koha::Database->new->schema->resultset('AuthHeader')->search( $conditions );
173
                @record_ids = map { $_->authid } $authorities->all;
173
                @record_ids = map { $_->authid } $authorities->all;
174
            }
174
            }
175
- 

Return to bug 15380