From d5ee4e06d88160f7a4fd448a22964e4517884a51 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 16 Jul 2015 07:56:18 -0400 Subject: [PATCH] Bug 8483 - Add record and item related classes Signed-off-by: Heather Braum --- Koha/Checkout.pm | 2 +- Koha/Checkouts.pm | 2 +- Koha/Deleted/Biblio.pm | 57 ++++++++++++++++++++++++++++++++++++++++ Koha/Deleted/BiblioItem.pm | 57 ++++++++++++++++++++++++++++++++++++++++ Koha/Deleted/BiblioItems.pm | 63 ++++++++++++++++++++++++++++++++++++++++++++ Koha/Deleted/Biblios.pm | 64 +++++++++++++++++++++++++++++++++++++++++++++ Koha/Deleted/Item.pm | 58 ++++++++++++++++++++++++++++++++++++++++ Koha/Deleted/Items.pm | 63 ++++++++++++++++++++++++++++++++++++++++++++ Koha/Item.pm | 48 ++++++++++++++++++++++++++++++++++ Koha/Old/Checkout.pm | 2 +- Koha/Old/Checkouts.pm | 2 +- 11 files changed, 414 insertions(+), 4 deletions(-) create mode 100644 Koha/Deleted/Biblio.pm create mode 100644 Koha/Deleted/BiblioItem.pm create mode 100644 Koha/Deleted/BiblioItems.pm create mode 100644 Koha/Deleted/Biblios.pm create mode 100644 Koha/Deleted/Item.pm create mode 100644 Koha/Deleted/Items.pm diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm index f30f6e1..e96b6ad 100644 --- a/Koha/Checkout.pm +++ b/Koha/Checkout.pm @@ -63,7 +63,7 @@ sub item { =cut -sub type { +sub _type { return 'Issue'; } diff --git a/Koha/Checkouts.pm b/Koha/Checkouts.pm index 9b1ddc1..333fb47 100644 --- a/Koha/Checkouts.pm +++ b/Koha/Checkouts.pm @@ -41,7 +41,7 @@ Koha::Checkouts - Koha Checkouts Object class =cut -sub type { +sub _type { return 'Issue'; } diff --git a/Koha/Deleted/Biblio.pm b/Koha/Deleted/Biblio.pm new file mode 100644 index 0000000..6624ffd --- /dev/null +++ b/Koha/Deleted/Biblio.pm @@ -0,0 +1,57 @@ +package Koha::Deleted::Biblio; + +# Copyright ByWater Solutions 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Carp; + +use Koha::Database; + +use base qw(Koha::Biblio); + +=head1 NAME + +Koha::Deleted::Biblio - Koha Biblio Object class + +This class is an extension of Koha::Biblio. + +New methods should only be added to Koha::Biblio unless they are specifically +and only for dealing with deleted bibs. + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'Deletedbiblio'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Deleted/BiblioItem.pm b/Koha/Deleted/BiblioItem.pm new file mode 100644 index 0000000..d8a6398 --- /dev/null +++ b/Koha/Deleted/BiblioItem.pm @@ -0,0 +1,57 @@ +package Koha::Deleted::BiblioItem; + +# Copyright ByWater Solutions 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Carp; + +use Koha::Database; + +use base qw(Koha::BiblioItem); + +=head1 NAME + +Koha::Deleted::BiblioItem - Koha Deleted BiblioItem Object class + +This class is an extension of Koha::BiblioItem. + +New methods should only be added to Koha::BiblioItem unless they are specifically +and only for dealing with deleted biblioitems. + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'Deletedbiblioitem'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Deleted/BiblioItems.pm b/Koha/Deleted/BiblioItems.pm new file mode 100644 index 0000000..35d5d1a --- /dev/null +++ b/Koha/Deleted/BiblioItems.pm @@ -0,0 +1,63 @@ +package Koha::Deleted::BiblioItems; + +# Copyright ByWater Solutions 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Carp; + +use Koha::Database; + +use Koha::Deleted::BiblioItem; + +use base qw(Koha::BiblioItems); + +=head1 NAME + +Koha::BiblioItem - Koha BiblioItem Object class + +This class is an extension of Koha::BiblioItems. + +New methods should only be added to Koha::BiblioItems unless they are specifically +and only for dealing with deleted biblioitem sets + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'Deletedbiblioitem'; +} + +sub object_class { + return 'Koha::Deleted::BiblioItem'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Deleted/Biblios.pm b/Koha/Deleted/Biblios.pm new file mode 100644 index 0000000..c0d255c --- /dev/null +++ b/Koha/Deleted/Biblios.pm @@ -0,0 +1,64 @@ +package Koha::Deleted::Biblios; + +# Copyright ByWater Solutions 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Carp; + +use Koha::Database; + +use Koha::Deleted::Biblio; + +use base qw(Koha::Biblios); + +=head1 NAME + +Koha::Deleted::Biblios - Koha Deleted Bibliographic Record set object class + +This class is an extension of Koha::Biblios. + +New methods should only be added to Koha::Biblios unless they are specifically +and only for dealing with deleted bib sets + + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'Deletedbiblio'; +} + +sub object_class { + return 'Koha::Deleted::Biblio'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Deleted/Item.pm b/Koha/Deleted/Item.pm new file mode 100644 index 0000000..41a8c44 --- /dev/null +++ b/Koha/Deleted/Item.pm @@ -0,0 +1,58 @@ +package Koha::Deleted::Item; + +# Copyright ByWater Solutions 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Carp; + +use Koha::Database; + +use base qw(Koha::Item); + +=head1 NAME + +Koha::Deleted::Item - Koha Deleted Item Object class + +This class is an extension of Koha::Item. + +New methods should only be added to Koha::Item unless they are specifically +and only for dealing with deleted items only. + + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'Deleteditem'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Deleted/Items.pm b/Koha/Deleted/Items.pm new file mode 100644 index 0000000..3b36033 --- /dev/null +++ b/Koha/Deleted/Items.pm @@ -0,0 +1,63 @@ +package Koha::Deleted::Items; + +# Copyright ByWater Solutions 2014 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Carp; + +use Koha::Database; + +use Koha::Deleted::Item; + +use base qw(Koha::Items); + +=head1 NAME + +Koha::Deleted::Items - Koha Deleted Items Object class + +This class is an extension of Koha::Items. + +New methods should only be added to Koha::Items unless they are specifically +and only for dealing with deleted item sets + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'Deleteditem'; +} + +sub object_class { + return 'Koha::Deleted::Item'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Item.pm b/Koha/Item.pm index d721537..14f9853 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -25,6 +25,10 @@ use Koha::Database; use Koha::Patrons; use Koha::Libraries; +use Koha::Biblios; +use Koha::Deleted::Biblios; +use Koha::BiblioItems; +use Koha::Deleted::BiblioItems; use base qw(Koha::Object); @@ -107,6 +111,50 @@ sub last_returned_by { } } +=head3 biblio + +my $biblio = $checkout->biblio({ deleted => 1 }); + +Returns the related Koha::Biblio for this checkout. + +If the parameter delete is passed and true, and the biblionumber +is not found for current biblios, this method will look for a matching +deleted biblio. + +=cut + +sub biblio { + my ( $self, $params ) = @_; + + my $biblio = Koha::Biblios->search( { biblionumber => $self->biblionumber() } )->next(); + + $biblio ||= Koha::Deleted::Biblios->search( { biblionumber => $self->biblionumber() } )->next() if ( $params->{deleted} ); + + return $biblio || undef; +} + +=head3 biblioitem + +my $biblioitem = $checkout->biblio({ deleted => 1 }); + +Returns the related Koha::Biblio for this checkout. + +If the parameter delete is passed and true, and the biblioitemnumber +is not found for current biblioitems, this method will look for a matching +deleted biblioitem. + +=cut + +sub biblioitem { + my ( $self, $params ) = @_; + + my $biblioitem = Koha::BiblioItems->search( { biblionumber => $self->biblionumber() } )->next(); + + $biblioitem ||= Koha::Deleted::BiblioItems->search( { biblionumber => $self->biblionumber() } )->next() if ( $params->{deleted} ); + + return $biblioitem || undef; +} + =head3 type =cut diff --git a/Koha/Old/Checkout.pm b/Koha/Old/Checkout.pm index 27e8283..07a9908 100644 --- a/Koha/Old/Checkout.pm +++ b/Koha/Old/Checkout.pm @@ -44,7 +44,7 @@ and only for dealing with old checkouts. =cut -sub type { +sub _type { return 'OldIssue'; } diff --git a/Koha/Old/Checkouts.pm b/Koha/Old/Checkouts.pm index 85dc15e..0ecfdb4 100644 --- a/Koha/Old/Checkouts.pm +++ b/Koha/Old/Checkouts.pm @@ -46,7 +46,7 @@ and only for dealing with old checkouts. =cut -sub type { +sub _type { return 'OldIssue'; } -- 2.1.4