This contains functions for normal operations on biblio records.
-Note: really, C4::Biblio does the main functions, but the Koha namespace is
-the new thing that should be used.
-
=cut
-use C4::Biblio;
+use Koha::Biblios;
use Koha::MetadataIterator;
use Koha::Database;
use Modern::Perl;
=cut
sub get_all_biblios_iterator {
- my ($self, %options) = @_;
+ my ($class, %options) = @_;
my $search_terms = {};
my ($slice_modulo, $slice_count);
my $database = Koha::Database->new();
my $schema = $database->schema();
- my $rs =
- $schema->resultset('Biblio')->search(
+ my $rs = Koha::Biblios->search(
$search_terms,
$search_options );
my $next_func = sub {
while (1) {
my $row = $rs->next();
return if !$row;
- my $marc = C4::Biblio::GetMarcBiblio({
- biblionumber => $row->biblionumber,
- embed_items => 1 });
my $next = eval {
- __PACKAGE__->new($marc, $row->biblionumber);
+ my $marc = $row->metadata->record({ embed_items => 1 });
+ $class->new($marc, $row->biblionumber);
};
if ($@) {
- warn "Something went wrong reading record for biblio $row->biblionumber: $@\n";
+ warn sprintf "Something went wrong reading record for biblio %s: %s\n", $row->biblionumber, $@;
next;
}
return $next;
sub get_marc_biblio {
my ($class, $bibnum, %options) = @_;
- return C4::Biblio::GetMarcBiblio({
- biblionumber => $bibnum,
- embed_items => ($options{item_data} ? 1 : 0 ) });
+ my $record = Koha::Biblios->find($bibnum)
+ ->metadata->record( { $options{item_data} ? ( embed_items => 1 ) : () } );
+ return $record;
}
1;