From 3128151713128985e6dbf2e54ce75bbd0c329a0f Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 31 Dec 2015 12:27:15 +0000 Subject: [PATCH] Bug 12375 [7] - Update to use Koha::Object classes This code was written before the introduction of Koha::Object(s) Considering the triviality of updating the code, we should go ahead and switch this code to use Koha::Object(s) now. --- C4/Serials.pm | 37 ++++++++++++++------------- Koha/Serial.pm | 52 +++++++++++++++++++++++++++++++++++++ Koha/Serials.pm | 58 ++++++++++++++++++++++++++++++++++++++++++ Koha/Subscription.pm | 52 +++++++++++++++++++++++++++++++++++++ Koha/Subscription/Histories.pm | 58 ++++++++++++++++++++++++++++++++++++++++++ Koha/Subscription/History.pm | 52 +++++++++++++++++++++++++++++++++++++ Koha/Subscriptions.pm | 58 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 349 insertions(+), 18 deletions(-) create mode 100644 Koha/Serial.pm create mode 100644 Koha/Serials.pm create mode 100644 Koha/Subscription.pm create mode 100644 Koha/Subscription/Histories.pm create mode 100644 Koha/Subscription/History.pm create mode 100644 Koha/Subscriptions.pm diff --git a/C4/Serials.pm b/C4/Serials.pm index b162ae1..c09a198 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -32,7 +32,9 @@ use C4::Serials::Frequency; use C4::Serials::Numberpattern; use Koha::AdditionalField; use Koha::DateUtils; -use Koha::Database; +use Koha::Serial; +use Koha::Subscriptions; +use Koha::Subscription::Histories; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -1447,8 +1449,7 @@ sub NewSubscription { # calculate issue number my $serialseq = GetSeq($subscription, $pattern) || q{}; - my $serial_rs = Koha::Database->new()->schema()->resultset('Serial'); - $serial_rs->create( + Koha::Serial->new( { serialseq => $serialseq, serialseq_x => $subscription->{'lastvalue1'}, @@ -1460,7 +1461,7 @@ sub NewSubscription { planneddate => $firstacquidate, publisheddate => $firstacquidate, } - ); + )->store(); logaction( "SERIAL", "ADD", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog"); @@ -1560,27 +1561,27 @@ sub NewIssue { my $schema = Koha::Database->new()->schema(); - my $subscription = $schema->resultset('Subscription')->find( $subscriptionid ); + my $subscription = Koha::Subscriptions->find( $subscriptionid ); - my $serial = $schema->resultset('Serial')->create( + my $serial = Koha::Serial->new( { - serialseq => $serialseq, - serialseq_x => $subscription->lastvalue1(), - serialseq_y => $subscription->lastvalue2(), - serialseq_z => $subscription->lastvalue3(), - subscriptionid => $subscriptionid, - biblionumber => $biblionumber, - status => $status, - planneddate => $planneddate, - publisheddate => $publisheddate, + serialseq => $serialseq, + serialseq_x => $subscription->lastvalue1(), + serialseq_y => $subscription->lastvalue2(), + serialseq_z => $subscription->lastvalue3(), + subscriptionid => $subscriptionid, + biblionumber => $biblionumber, + status => $status, + planneddate => $planneddate, + publisheddate => $publisheddate, publisheddatetext => $publisheddatetext, - notes => $notes, + notes => $notes, } - ); + )->store(); my $serialid = $serial->id(); - my $subscription_history = $schema->resultset('Subscriptionhistory')->find($subscriptionid); + my $subscription_history = Koha::Subscription::Histories->find($subscriptionid); my $missinglist = $subscription_history->missinglist(); my $recievedlist = $subscription_history->recievedlist(); diff --git a/Koha/Serial.pm b/Koha/Serial.pm new file mode 100644 index 0000000..d6342cc --- /dev/null +++ b/Koha/Serial.pm @@ -0,0 +1,52 @@ +package Koha::Serial; + +# 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::Object); + +=head1 NAME + +Koha::Serial - Koha Serial Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'Serial'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Serials.pm b/Koha/Serials.pm new file mode 100644 index 0000000..5d16628 --- /dev/null +++ b/Koha/Serials.pm @@ -0,0 +1,58 @@ +package Koha::Serials; + +# 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::Serial; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Serial - Koha Serial Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'Serial'; +} + +sub object_class { + return 'Koha::Serial'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Subscription.pm b/Koha/Subscription.pm new file mode 100644 index 0000000..1ba0c16 --- /dev/null +++ b/Koha/Subscription.pm @@ -0,0 +1,52 @@ +package Koha::Subscription; + +# 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::Object); + +=head1 NAME + +Koha::Subscription - Koha Subscription Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'Subscription'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Subscription/Histories.pm b/Koha/Subscription/Histories.pm new file mode 100644 index 0000000..c7e1c8c --- /dev/null +++ b/Koha/Subscription/Histories.pm @@ -0,0 +1,58 @@ +package Koha::Subscription::Histories; + +# 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::Subscription::History; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Subscription::Histories - Koha Subscription Histories Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'Subscriptionhistory'; +} + +sub object_class { + return 'Koha::Subscription::History'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Subscription/History.pm b/Koha/Subscription/History.pm new file mode 100644 index 0000000..b282fa3 --- /dev/null +++ b/Koha/Subscription/History.pm @@ -0,0 +1,52 @@ +package Koha::Subscription::History; + +# 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::Object); + +=head1 NAME + +Koha::Subscription::History - Koha Subscription History Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'Subscriptionhistory'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Subscriptions.pm b/Koha/Subscriptions.pm new file mode 100644 index 0000000..316bec7 --- /dev/null +++ b/Koha/Subscriptions.pm @@ -0,0 +1,58 @@ +package Koha::Subscriptions; + +# 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::Subscription; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Subscription - Koha Subscription Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'Subscription'; +} + +sub object_class { + return 'Koha::Subscription'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; -- 2.1.4