From 8313998789c55793b64986d9ee928e8ba2dababd Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Wed, 29 Jul 2015 15:16:34 +0300 Subject: [PATCH] Bug 14616 - Introducing Koha::Object subclasses Just adding the working subclasses as a convenience. --- Koha/Acquisition/Bookseller/Contact.pm | 32 ++++++ Koha/Acquisition/Bookseller/Contacts.pm | 40 ++++++++ Koha/Acquisition/Bookseller2.pm | 32 ++++++ Koha/Acquisition/Booksellers.pm | 40 ++++++++ Koha/Biblio.pm | 22 +--- Koha/BiblioItem.pm | 32 ++++++ Koha/BiblioItems.pm | 38 +++++++ Koha/Biblios.pm | 28 +---- Koha/Checkout.pm | 52 ++++++++++ Koha/Checkouts.pm | 38 +++++++ Koha/Item.pm | 1 + Koha/Items.pm | 5 + Koha/LetterTemplate.pm | 32 ++++++ Koha/LetterTemplates.pm | 38 +++++++ Koha/Schema/Result/Serial.pm | 7 ++ Koha/Schema/Result/Subscription.pm | 20 ++++ Koha/Serial/Subscription.pm | 160 +++++++++++++++++++++++++++++ Koha/Serial/Subscription/Frequencies.pm | 40 ++++++++ Koha/Serial/Subscription/Frequency.pm | 43 ++++++++ Koha/Serial/Subscription/Numberpattern.pm | 43 ++++++++ Koha/Serial/Subscription/Numberpatterns.pm | 40 ++++++++ Koha/Serial/Subscriptions.pm | 40 ++++++++ 22 files changed, 778 insertions(+), 45 deletions(-) create mode 100644 Koha/Acquisition/Bookseller/Contact.pm create mode 100644 Koha/Acquisition/Bookseller/Contacts.pm create mode 100644 Koha/Acquisition/Bookseller2.pm create mode 100644 Koha/Acquisition/Booksellers.pm create mode 100644 Koha/BiblioItem.pm create mode 100644 Koha/BiblioItems.pm create mode 100644 Koha/Checkout.pm create mode 100644 Koha/Checkouts.pm create mode 100644 Koha/LetterTemplate.pm create mode 100644 Koha/LetterTemplates.pm create mode 100644 Koha/Serial/Subscription.pm create mode 100644 Koha/Serial/Subscription/Frequencies.pm create mode 100644 Koha/Serial/Subscription/Frequency.pm create mode 100644 Koha/Serial/Subscription/Numberpattern.pm create mode 100644 Koha/Serial/Subscription/Numberpatterns.pm create mode 100644 Koha/Serial/Subscriptions.pm diff --git a/Koha/Acquisition/Bookseller/Contact.pm b/Koha/Acquisition/Bookseller/Contact.pm new file mode 100644 index 0000000..1b63d26 --- /dev/null +++ b/Koha/Acquisition/Bookseller/Contact.pm @@ -0,0 +1,32 @@ +package Koha::Acquisition::Bookseller::Contact; + +# Copyright KohaSuomi 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::Object); + +sub type { + return 'Aqcontact'; +} + +1; diff --git a/Koha/Acquisition/Bookseller/Contacts.pm b/Koha/Acquisition/Bookseller/Contacts.pm new file mode 100644 index 0000000..e857ee0 --- /dev/null +++ b/Koha/Acquisition/Bookseller/Contacts.pm @@ -0,0 +1,40 @@ +package Koha::Acquisition::Bookseller::Contacts; + +# Copyright KohaSuomi 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::Acquisition::Bookseller::Contact; + +use base qw(Koha::Objects); + +sub type { + return 'Aqcontact'; +} + +sub object_class { + return 'Koha::Acquisition::Bookseller::Contact'; +} + +sub _get_castable_unique_columns { + return ['id']; +} + +1; diff --git a/Koha/Acquisition/Bookseller2.pm b/Koha/Acquisition/Bookseller2.pm new file mode 100644 index 0000000..3320ffc --- /dev/null +++ b/Koha/Acquisition/Bookseller2.pm @@ -0,0 +1,32 @@ +package Koha::Acquisition::Bookseller2; #Big patch upstream which fixes bad Bookseller to follow Koha::Object + +# Copyright KohaSuomi 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::Object); + +sub type { + return 'Aqbookseller'; +} + +1; diff --git a/Koha/Acquisition/Booksellers.pm b/Koha/Acquisition/Booksellers.pm new file mode 100644 index 0000000..4fc043d --- /dev/null +++ b/Koha/Acquisition/Booksellers.pm @@ -0,0 +1,40 @@ +package Koha::Acquisition::Booksellers; + +# Copyright KohaSuomi 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::Acquisition::Bookseller2; + +use base qw(Koha::Objects); + +sub type { + return 'Aqbookseller'; +} + +sub object_class { + return 'Koha::Acquisition::Bookseller2'; +} + +sub _get_castable_unique_columns { + return ['id']; +} + +1; diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 9c467d7..4ad9613 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -1,6 +1,6 @@ package Koha::Biblio; -# Copyright ByWater Solutions 2014 +# Copyright Open Source Freedom Fighters # # This file is part of Koha. # @@ -25,28 +25,8 @@ use Koha::Database; use base qw(Koha::Object); -=head1 NAME - -Koha::Biblio - Koha Biblio Object class - -=head1 API - -=head2 Class Methods - -=cut - -=head3 type - -=cut - sub type { return 'Biblio'; } -=head1 AUTHOR - -Kyle M Hall - -=cut - 1; diff --git a/Koha/BiblioItem.pm b/Koha/BiblioItem.pm new file mode 100644 index 0000000..b4e172a --- /dev/null +++ b/Koha/BiblioItem.pm @@ -0,0 +1,32 @@ +package Koha::BiblioItem; + +# Copyright Open Source Freedom Fighters +# +# 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::Object); + +sub type { + return 'BiblioItem'; +} + +1; diff --git a/Koha/BiblioItems.pm b/Koha/BiblioItems.pm new file mode 100644 index 0000000..0769f73 --- /dev/null +++ b/Koha/BiblioItems.pm @@ -0,0 +1,38 @@ +package Koha::BiblioItems; + +# Copyright Open Source Freedom Fighters +# +# 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::BiblioItem; + +use base qw(Koha::Objects); + +sub type { + return 'BiblioItem'; +} + +sub object_class { + return 'Koha::BiblioItem'; +} + +1; diff --git a/Koha/Biblios.pm b/Koha/Biblios.pm index cba48ea..e18642b 100644 --- a/Koha/Biblios.pm +++ b/Koha/Biblios.pm @@ -1,6 +1,6 @@ package Koha::Biblios; -# Copyright ByWater Solutions 2014 +# Copyright Open Source Freedom Fighters # # This file is part of Koha. # @@ -27,36 +27,16 @@ use Koha::Biblio; use base qw(Koha::Objects); -=head1 NAME - -Koha::Biblios - Koha Biblio object set class - -=head1 API - -=head2 Class Methods - -=cut - -=head3 type - -=cut - sub type { return 'Biblio'; } -=head3 object_class - -=cut - sub object_class { return 'Koha::Biblio'; } -=head1 AUTHOR - -Kyle M Hall - -=cut +sub _get_castable_unique_columns { + return ['biblionumber']; +} 1; diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm new file mode 100644 index 0000000..9bc365f --- /dev/null +++ b/Koha/Checkout.pm @@ -0,0 +1,52 @@ +package Koha::Checkout; + +# Copyright Open Source Freedom Fighters +# +# 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::Borrowers; +use Koha::Items; + +use base qw(Koha::Object); + +sub type { + return 'Issue'; +} + +sub cardnumber { + my ($self) = @_; + + unless ($self->{borrower}) { + $self->{borrower} = Koha::Borrowers->cast($self->_result->borrower); + } + return $self->{borrower}->cardnumber; +} + +sub barcode { + my ($self) = @_; + + unless ($self->{item}) { + $self->{item} = $self->_result->item; + } + return $self->{item}->barcode; +} + +1; diff --git a/Koha/Checkouts.pm b/Koha/Checkouts.pm new file mode 100644 index 0000000..fe758f2 --- /dev/null +++ b/Koha/Checkouts.pm @@ -0,0 +1,38 @@ +package Koha::Checkouts; + +# Copyright Open Source Freedom Fighters +# +# 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::Checkout; + +use base qw(Koha::Objects); + +sub type { + return 'Issue'; +} + +sub object_class { + return 'Koha::Checkout'; +} + +1; diff --git a/Koha/Item.pm b/Koha/Item.pm index 2dcccfb..1f4b8e8 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1,6 +1,7 @@ package Koha::Item; # Copyright ByWater Solutions 2014 +# Copyright Open Source Freedom Fighters # # This file is part of Koha. # diff --git a/Koha/Items.pm b/Koha/Items.pm index 072113f..793adf4 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -1,6 +1,7 @@ package Koha::Items; # Copyright ByWater Solutions 2014 +# Copyright Open Source Freedom Fighters # # This file is part of Koha. # @@ -59,4 +60,8 @@ Kyle M Hall =cut +sub _get_castable_unique_columns { + return ['itemnumber', 'barcode']; +} + 1; diff --git a/Koha/LetterTemplate.pm b/Koha/LetterTemplate.pm new file mode 100644 index 0000000..7771c1e --- /dev/null +++ b/Koha/LetterTemplate.pm @@ -0,0 +1,32 @@ +package Koha::LetterTemplate; + +# Copyright Open Source Freedom Fighters +# +# 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::Object); + +sub type { + return 'Letter'; +} + +1; diff --git a/Koha/LetterTemplates.pm b/Koha/LetterTemplates.pm new file mode 100644 index 0000000..e1c511d --- /dev/null +++ b/Koha/LetterTemplates.pm @@ -0,0 +1,38 @@ +package Koha::LetterTemplates; + +# Copyright Open Source Freedom Fighters +# +# 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::LetterTemplate; + +use base qw(Koha::Objects); + +sub type { + return 'Letter'; +} + +sub object_class { + return 'Koha::LetterTemplate'; +} + +1; diff --git a/Koha/Schema/Result/Serial.pm b/Koha/Schema/Result/Serial.pm index db07ca1..21522eb 100644 --- a/Koha/Schema/Result/Serial.pm +++ b/Koha/Schema/Result/Serial.pm @@ -150,6 +150,13 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-10-28 10:10:55 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xscBtY2sJRoXXw7hVPTqCQ +__PACKAGE__->belongs_to( + "subscription", + "Koha::Schema::Result::Subscription", + { "foreign.subscriptionid" => "self.subscriptionid" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + # You can replace this text with custom content, and it will be preserved on regeneration 1; diff --git a/Koha/Schema/Result/Subscription.pm b/Koha/Schema/Result/Subscription.pm index 62468a0..731c84d 100644 --- a/Koha/Schema/Result/Subscription.pm +++ b/Koha/Schema/Result/Subscription.pm @@ -432,6 +432,26 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-07-11 09:26:55 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:57kc1/B3eNKQXAk9tlOy0A +=head2 biblio + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "biblio", + "Koha::Schema::Result::Biblio", + { biblionumber => "biblionumber" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "SET NULL", + on_update => "CASCADE", + }, +); + # You can replace this text with custom content, and it will be preserved on regeneration 1; diff --git a/Koha/Serial/Subscription.pm b/Koha/Serial/Subscription.pm new file mode 100644 index 0000000..2aef660 --- /dev/null +++ b/Koha/Serial/Subscription.pm @@ -0,0 +1,160 @@ +package Koha::Serial::Subscription; + +# Copyright KohaSuomi 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::Serial::Subscription::Frequencies; +use Koha::Serial::Subscription::Numberpatterns; +use Koha::Serial::Serials; +use Koha::Borrowers; +use Koha::Biblios; +use Koha::Acquisition::Booksellers; +use Koha::Items; + +use base qw(Koha::Object); + +sub type { + return 'Subscription'; +} + +sub periodicity { + my ($self, $periodicity) = @_; + + if ($periodicity) { + $periodicity = Koha::Serial::Subscription::Frequencies->cast($periodicity); + $self->{periodicity} = $periodicity; + $self->set({periodicity => $periodicity->_result()->id}); + $self->store(); + } + + unless ($self->{periodicity}) { + my $frequency = $self->_result()->periodicity(); + $self->{periodicity} = Koha::Serial::Subscription::Frequencies->cast($frequency); + } + + return $self->{periodicity}; +} + +sub numberpattern { + my ($self, $numberpattern) = @_; + + if ($numberpattern) { + $numberpattern = Koha::Serial::Subscription::Numberpatterns->cast($numberpattern); + $self->{numberpattern} = $numberpattern; + $self->set({numberpattern => $numberpattern->_result()->id}); + $self->store(); + } + + unless ($self->{numberpattern}) { + my $numberpattern = $self->_result()->numberpattern(); + $self->{numberpattern} = Koha::Serial::Subscription::Numberpatterns->cast($numberpattern); + } + + return $self->{numberpattern}; +} + +sub biblio { + my ($self, $biblio) = @_; + + if ($biblio) { + $biblio = Koha::Biblios->cast($biblio); + $self->{biblio} = $biblio; + $self->set({biblio => $biblio->_result()->id}); + $self->store(); + } + + unless ($self->{biblio}) { + my $biblio = $self->_result()->biblio(); + $self->{biblio} = Koha::Biblios->cast($biblio); + } + + return $self->{biblio}; +} + +sub borrower { + my ($self, $borrower) = @_; + + if ($borrower) { + $borrower = Koha::Borrowers->cast($borrower); + $self->{borrower} = $borrower; + $self->set({librarian => $borrower->_result()->id}); + $self->store(); + } + + unless ($self->{borrower}) { + my $borrower = $self->_result()->librarian(); + $self->{borrower} = Koha::Borrowers->cast($borrower); + } + + return $self->{borrower}; +} + +sub bookseller { + my ($self, $bookseller) = @_; + + if ($bookseller) { + $bookseller = Koha::Acquisition::Booksellers->cast($bookseller); + $self->{bookseller} = $bookseller; + $self->set({bookseller => $bookseller->_result()->id}); + $self->store(); + } + + unless ($self->{bookseller}) { + my $booksellerid = $self->_result()->aqbooksellerid(); + $self->{bookseller} = Koha::Acquisition::Booksellers->cast($booksellerid); + } + + return $self->{bookseller}; +} + +sub serials { + my ($self) = @_; + + unless ($self->{serials}) { + my @serials = Koha::Serial::Serials->search({subscriptionid => $self->subscriptionid}); + $self->{serials} = \@serials; + } + + return $self->{serials}; +} + +sub items { + my ($self) = @_; + + unless ($self->{items}) { + my @items; + my $serials = $self->serials(); + for (my $i=0 ; $i[$i]->_result()->serialitems(); + foreach my $si (@serialitems) { + my $item = $si->itemnumber; + $item = Koha::Items->cast($item); + push @items, $item; + } + } + $self->{items} = \@items; + } + + return $self->{items}; +} + +1; diff --git a/Koha/Serial/Subscription/Frequencies.pm b/Koha/Serial/Subscription/Frequencies.pm new file mode 100644 index 0000000..572858d --- /dev/null +++ b/Koha/Serial/Subscription/Frequencies.pm @@ -0,0 +1,40 @@ +package Koha::Serial::Subscription::Frequencies; + +# Copyright KohaSuomi 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::Serial::Subscription::Frequency; + +use base qw(Koha::Objects); + +sub type { + return 'SubscriptionFrequency'; +} + +sub object_class { + return 'Koha::Serial::Subscription::Frequency'; +} + +sub _get_castable_unique_columns { + return ['id']; +} + +1; diff --git a/Koha/Serial/Subscription/Frequency.pm b/Koha/Serial/Subscription/Frequency.pm new file mode 100644 index 0000000..4766c1a --- /dev/null +++ b/Koha/Serial/Subscription/Frequency.pm @@ -0,0 +1,43 @@ +package Koha::Serial::Subscription::Frequency; + +# Copyright KohaSuomi 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::Object); + +sub type { + return 'SubscriptionFrequency'; +} + +sub subscriptions { + my ($self) = @_; + + unless ($self->{subscriptions}) { + my @subscriptions = Koha::Serial::Subscriptions->search({periodicity => $self->id}); + $self->{subscriptions} = \@subscriptions; + } + + return $self->{subscriptions}; +} + +1; diff --git a/Koha/Serial/Subscription/Numberpattern.pm b/Koha/Serial/Subscription/Numberpattern.pm new file mode 100644 index 0000000..8f99544 --- /dev/null +++ b/Koha/Serial/Subscription/Numberpattern.pm @@ -0,0 +1,43 @@ +package Koha::Serial::Subscription::Numberpattern; + +# Copyright KohaSuomi 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::Object); + +sub type { + return 'SubscriptionNumberpattern'; +} + +sub subscriptions { + my ($self) = @_; + + unless ($self->{subscriptions}) { + my @subscriptions = Koha::Serial::Subscriptions->search({numberpattern => $self->id}); + $self->{subscriptions} = \@subscriptions; + } + + return $self->{subscriptions}; +} + +1; diff --git a/Koha/Serial/Subscription/Numberpatterns.pm b/Koha/Serial/Subscription/Numberpatterns.pm new file mode 100644 index 0000000..0464ba8 --- /dev/null +++ b/Koha/Serial/Subscription/Numberpatterns.pm @@ -0,0 +1,40 @@ +package Koha::Serial::Subscription::Numberpatterns; + +# Copyright KohaSuomi 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::Serial::Subscription::Numberpattern; + +use base qw(Koha::Objects); + +sub type { + return 'SubscriptionNumberpattern'; +} + +sub object_class { + return 'Koha::Serial::Subscription::Numberpattern'; +} + +sub _get_castable_unique_columns { + return ['id']; +} + +1; diff --git a/Koha/Serial/Subscriptions.pm b/Koha/Serial/Subscriptions.pm new file mode 100644 index 0000000..6a71b8a --- /dev/null +++ b/Koha/Serial/Subscriptions.pm @@ -0,0 +1,40 @@ +package Koha::Serial::Subscriptions; + +# Copyright KohaSuomi 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::Serial::Subscription; + +use base qw(Koha::Objects); + +sub type { + return 'Subscription'; +} + +sub object_class { + return 'Koha::Serial::Subscription'; +} + +sub _get_castable_unique_columns { + return ['subscriptionid']; +} + +1; -- 1.9.1