Koha-Contrib-ARK
view release on metacpan or search on metacpan
lib/Koha/Contrib/ARK/Reader.pm view on Meta::CPAN
package Koha::Contrib::ARK::Reader;
# ABSTRACT: Read Koha biblio records with/without ARK
$Koha::Contrib::ARK::Reader::VERSION = '1.1.2';
use Moose;
use Moose::Util::TypeConstraints;
use Modern::Perl;
use C4::Context;
use C4::Biblio;
use MARC::Moose::Record;
with 'MooseX::RW::Reader';
has ark => ( is => 'rw', isa => 'Koha::Contrib::ARK' );
subtype 'BiblioSelect'
=> as 'Str'
=> where { $_ =~ /WithArk|WithoutArk|All/ }
=> message { 'Invalid biblio selection' };
has select => (
is => 'rw',
isa => 'BiblioSelect',
default => 'All',
);
has fromwhere => (
is => 'rw',
isa => 'Str'
);
has total => ( is => 'rw', isa => 'Int', default => 0 );
has sth_bn => (is => 'rw');
sub BUILD {
my $self = shift;
my $dbh = C4::Context->dbh;
my $fromwhere = "FROM biblio_metadata";
if ($self->fromwhere) {
$fromwhere .= " WHERE " . $self->fromwhere;
}
else {
$fromwhere .= " WHERE " .
$self->ark->field_query .
($self->select eq 'WithoutArk' ? " =''" : " <> ''" )
if $self->select ne 'All';
}
#$fromwhere = "FROM biblio_metadata WHERE biblionumber=875167";
my $total = $dbh->selectall_arrayref("SELECT COUNT(*) $fromwhere");
$total = $total->[0][0];
$self->total( $total );
my $sth = $dbh->prepare("SELECT biblionumber $fromwhere");
$sth->execute;
$self->sth_bn($sth);
}
( run in 1.133 second using v1.01-cache-2.11-cpan-5735350b133 )