From 724151b575e0b32c3e3ca7fee95d2f89bf8e8884 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Wed, 20 Jun 2012 09:08:59 +0200 Subject: [PATCH] Branchrelation package, 1st draft unused in my tests I think, commiting it just in case http://bugs.koha-community.org/show_bug.cgi?id=8309 --- Koha/BusinessLogic/Branchrelation.pm | 5 +++++ Koha/DB/Branchrelation.pm | 40 ++++++++++++++++++++++++++++++++++ Koha/DataObject/Branchrelation.pm | 5 +++++ 3 files changed, 50 insertions(+) create mode 100644 Koha/BusinessLogic/Branchrelation.pm create mode 100644 Koha/DB/Branchrelation.pm create mode 100644 Koha/DataObject/Branchrelation.pm diff --git a/Koha/BusinessLogic/Branchrelation.pm b/Koha/BusinessLogic/Branchrelation.pm new file mode 100644 index 0000000..25560cb --- /dev/null +++ b/Koha/BusinessLogic/Branchrelation.pm @@ -0,0 +1,5 @@ +package Koha::BusinessLogic::Branchrelation; + +use Modern::Perl; +use Moose; +extends (qw(Koha::DataObject::Branchrelation)); diff --git a/Koha/DB/Branchrelation.pm b/Koha/DB/Branchrelation.pm new file mode 100644 index 0000000..e513f16 --- /dev/null +++ b/Koha/DB/Branchrelation.pm @@ -0,0 +1,40 @@ +package Koha::DB::Branchrelation; + +use Modern::Perl; +use C4::Context; #FIXME = create a Koha package for KOHA_CONF reading + +use Koha::Schema; + +use Moose; + +has 'branchcode' => (is => 'rw', required => 0, isa => 'Str'); +has 'categorycode' => (is => 'rw', required => 0, isa => 'Str'); + + +my $schema = Koha::Schema->connect( + 'dbi:mysql:dbname='.C4::Context->config("database"), + C4::Context->config("user"), + C4::Context->config("pass"), + { AutoCommit => 1 }, + ); + +sub create { + my ($self) = @_; + $schema->resultset('Branchrelation')->create({%{$self}}); +} + +sub read { + my ($self, $branchrelation) = @_; + return $schema->resultset('Branchrelation')->search($branchrelation); +} + +sub update { + my ($self, $branchrelation) = @_; + return $schema->resultset('Branchrelation')->search({branchcode => $branchrelation->{branchcode}})->update($branchrelation); +} + +sub delete { + my ($self,$branchrelation) = @_; + $schema->resultset('Branchrelation')->search($branchrelation)->delete; +} + diff --git a/Koha/DataObject/Branchrelation.pm b/Koha/DataObject/Branchrelation.pm new file mode 100644 index 0000000..dda0768 --- /dev/null +++ b/Koha/DataObject/Branchrelation.pm @@ -0,0 +1,5 @@ +package Koha::DataObject::Branchrelation; + +use Modern::Perl; +use Moose; +extends (qw(Koha::DB::Branchrelation)); -- 1.7.9.5