use C4::AuthoritiesMarc::UNIMARC;
use C4::Charset;
use C4::Log;
-use Koha::Authority;
+use Koha::MetadataRecord::Authority;
use vars qw($VERSION @ISA @EXPORT);
sub GetAuthority {
my ($authid)=@_;
- my $authority = Koha::Authority->get_from_authid($authid);
+ my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
return unless $authority;
return ($authority->record);
}
sub _get_authority_for_export {
my ($params) = @_;
my $authid = $params->{authid} || return;
- my $authority = Koha::Authority->get_from_authid($authid);
+ my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
return unless $authority;
return $authority->record;
}
use strict;
use warnings;
use Carp;
-use Koha::Authority;
+use Koha::MetadataRecord::Authority;
use C4::Biblio qw/GetMarcFromKohaField/;
use base qw(Koha::RecordProcessor::Base);
next unless $authid;
- my $authority = Koha::Authority->get_from_authid($authid);
+ my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
next unless $authority;
my $auth_marc = $authority->record;
my @seefrom = $auth_marc->field('4..');
-package Koha::Authority;
+package Koha::MetadataRecord::Authority;
# Copyright 2012 C & P Bibliography Services
#
=head1 NAME
-Koha::Authority - class to encapsulate authority records in Koha
+Koha::MetadataRecord::Authority - class to encapsulate authority records in Koha
=head1 SYNOPSIS
=head2 new
- my $auth = Koha::Authority->new($record);
+ my $auth = Koha::MetadataRecord::Authority->new($record);
-Create a new Koha::Authority object based on the provided record.
+Create a new Koha::MetadataRecord::Authority object based on the provided record.
=cut
=head2 get_from_authid
- my $auth = Koha::Authority->get_from_authid($authid);
+ my $auth = Koha::MetadataRecord::Authority->get_from_authid($authid);
-Create the Koha::Authority object associated with the provided authid.
+Create the Koha::MetadataRecord::Authority object associated with the provided authid.
Note that this routine currently retrieves a MARC record because
authorities in Koha are MARC records by definition. This is an
unfortunate but unavoidable fact.
return if ($@);
$record->encoding('UTF-8');
- # NOTE: GuessAuthTypeCode has no business in Koha::Authority, which is an
+ # NOTE: GuessAuthTypeCode has no business in Koha::MetadataRecord::Authority, which is an
# object-oriented class. Eventually perhaps there will be utility
# classes in the Koha:: namespace, but there are not at the moment,
# so this shim seems like the best option all-around.
=head2 get_from_breeding
- my $auth = Koha::Authority->get_from_authid($authid);
+ my $auth = Koha::MetadataRecord::Authority->get_from_authid($authid);
-Create the Koha::Authority object associated with the provided authid.
+Create the Koha::MetadataRecord::Authority object associated with the provided authid.
=cut
return if ($@);
$record->encoding('UTF-8');
- # NOTE: GuessAuthTypeCode has no business in Koha::Authority, which is an
+ # NOTE: GuessAuthTypeCode has no business in Koha::MetadataRecord::Authority, which is an
# object-oriented class. Eventually perhaps there will be utility
# classes in the Koha:: namespace, but there are not at the moment,
# so this shim seems like the best option all-around.
use C4::Output;
use C4::Auth;
use C4::AuthoritiesMarc;
-use Koha::Authority;
+use Koha::MetadataRecord::Authority;
use C4::Koha;
use C4::Biblio;
push @errors, { code => "WRONG_COUNT", value => scalar(@authid) };
}
else {
- my $recordObj1 = Koha::Authority->get_from_authid($authid[0]) || Koha::Authority->new();
+ my $recordObj1 = Koha::MetadataRecord::Authority->get_from_authid($authid[0]) || Koha::MetadataRecord::Authority->new();
my $recordObj2;
if (defined $mergereference && $mergereference eq 'breeding') {
- $recordObj2 = Koha::Authority->get_from_breeding($authid[1]) || Koha::Authority->new();
+ $recordObj2 = Koha::MetadataRecord::Authority->get_from_breeding($authid[1]) || Koha::MetadataRecord::Authority->new();
} else {
- $recordObj2 = Koha::Authority->get_from_authid($authid[1]) || Koha::Authority->new();
+ $recordObj2 = Koha::MetadataRecord::Authority->get_from_authid($authid[1]) || Koha::MetadataRecord::Authority->new();
}
if ($mergereference) {
: (),
( $authtype ? ( authtypecode => $authtype ) : () ),
};
- # Koha::Authority is not a Koha::Object...
+ # Koha::MetadataRecord::Authority is not a Koha::Object...
my $authorities = Koha::Database->new->schema->resultset('AuthHeader')->search( $conditions );
@record_ids = map { $_->authid } $authorities->all;
}
use C4::Biblio qw( GetMarcBiblio );
use C4::MarcModificationTemplates qw( ModifyRecordWithTemplate );
use C4::Output qw( output_html_with_http_headers );
-use Koha::Authority;
+use Koha::MetadataRecord::Authority;
my $query = CGI->new();
my $record_id = $query->param('record_id');
if ( $record_type eq 'biblio' ) {
$record = GetMarcBiblio( $record_id );
} else {
- my $authority = Koha::Authority->get_from_authid( $record_id );
+ my $authority = Koha::MetadataRecord::Authority->get_from_authid( $record_id );
$record = $authority->record;
}
use Test::More;
BEGIN {
- use_ok('Koha::Authority');
+ use_ok('Koha::MetadataRecord::Authority');
}
my $record = MARC::Record->new;
[ '150', ' ', ' ', a => 'Cooking' ],
[ '450', ' ', ' ', a => 'Cookery' ],
);
-my $authority = Koha::Authority->new($record);
+my $authority = Koha::MetadataRecord::Authority->new($record);
-is(ref($authority), 'Koha::Authority', 'Created valid Koha::Authority object');
+is(ref($authority), 'Koha::MetadataRecord::Authority', 'Created valid Koha::MetadataRecord::Authority object');
is($authority->authorized_heading(), 'Cooking', 'Authorized heading was correct');
$authid = $row->{'authid'};
}
skip 'No authorities', 3 unless $authid;
- $authority = Koha::Authority->get_from_authid($authid);
+ $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
- is(ref($authority), 'Koha::Authority', 'Retrieved valid Koha::Authority object');
+ is(ref($authority), 'Koha::MetadataRecord::Authority', 'Retrieved valid Koha::MetadataRecord::Authority object');
is($authority->authid, $authid, 'Object authid is correct');
is($authority->record->field('001')->data(), $authid, 'Retrieved correct record');
- $authority = Koha::Authority->get_from_authid('alphabetsoup');
+ $authority = Koha::MetadataRecord::Authority->get_from_authid('alphabetsoup');
is($authority, undef, 'No invalid record is retrieved');
}
}
skip 'No authorities in reservoir', 3 unless $import_record_id;
- $authority = Koha::Authority->get_from_breeding($import_record_id);
+ $authority = Koha::MetadataRecord::Authority->get_from_breeding($import_record_id);
- is(ref($authority), 'Koha::Authority', 'Retrieved valid Koha::Authority object');
+ is(ref($authority), 'Koha::MetadataRecord::Authority', 'Retrieved valid Koha::MetadataRecord::Authority object');
is($authority->authid, undef, 'Records in reservoir do not have an authid');
is(ref($authority->record), 'MARC::Record', 'MARC record attached to authority');
- $authority = Koha::Authority->get_from_breeding('alphabetsoup');
+ $authority = Koha::MetadataRecord::Authority->get_from_breeding('alphabetsoup');
is($authority, undef, 'No invalid record is retrieved from reservoir');
}
use warnings;
use File::Spec;
use MARC::Record;
-use Koha::Authority;
+use Koha::MetadataRecord::Authority;
use Test::More;
use Test::MockModule;
);
- my $koha_authority = new Test::MockModule('Koha::Authority');
+ my $koha_authority = new Test::MockModule('Koha::MetadataRecord::Authority');
$koha_authority->mock( 'get_from_authid', sub {
my $auth_record = MARC::Record->new;
use C4::BackgroundJob;
use C4::Biblio qw( GetMarcBiblio ModBiblio );
use C4::MarcModificationTemplates qw( GetModificationTemplateActions GetModificationTemplates ModifyRecordWithTemplate );
-use Koha::Authority;
+use Koha::MetadataRecord::Authority;
my $input = new CGI;
our $dbh = C4::Context->dbh;
push @records, $biblio;
} else {
# Retrieve authority information
- my $authority = Koha::Authority->get_from_authid( $record_id );
+ my $authority = Koha::MetadataRecord::Authority->get_from_authid( $record_id );
unless ( $authority ) {
push @messages, {
type => 'warning',
# Authorities
my $authid = $record_id;
my $error = eval {
- my $authority = Koha::Authority->get_from_authid( $authid );
+ my $authority = Koha::MetadataRecord::Authority->get_from_authid( $authid );
my $record = $authority->record;
ModifyRecordWithTemplate( $mmtid, $record );
ModAuthority( $authid, $record, GetAuthTypeCode( $authid ) );
: (),
( $authtype ? ( authtypecode => $authtype ) : () ),
};
- # Koha::Authority is not a Koha::Object...
+ # Koha::MetadataRecord::Authority is not a Koha::Object...
my $authorities = Koha::Database->new->schema->resultset('AuthHeader')->search( $conditions );
@record_ids = map { $_->authid } $authorities->all;
}