From daf37b85d7d4ea4446e40f4a6f608131e9e13229 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 14 Dec 2023 14:46:11 +0000 Subject: [PATCH] Bug 35581: Koha::*Illbatch* -> Koha::*ILL::*Batch* Koha/Illbatch.pm -> Koha/ILL/Batch.pm Koha/Illbatches.pm -> Koha/ILL/Batches.pm Koha/REST/V1/Illbatches.pm -> Koha/REST/V1/ILL/Batches.pm t/db_dependent/Koha/Illbatch.t -> t/db_dependent/Koha/ILL/Batch.t t/db_dependent/Illbatches.t -> t/db_dependent/Koha/ILL/Batches.t Signed-off-by: David Nind Signed-off-by: Tomas Cohen Arazi Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer --- Koha/{Illbatch.pm => ILL/Batch.pm} | 12 +++++------ Koha/{Illbatches.pm => ILL/Batches.pm} | 12 +++++------ Koha/IllbatchStatus.pm | 4 ++-- Koha/Illrequest.pm | 6 +++--- .../REST/V1/{Illbatches.pm => ILL/Batches.pm} | 18 ++++++++--------- Koha/Schema/Result/Illbatch.pm | 4 ++-- api/v1/swagger/paths/ill_batches.yaml | 10 +++++----- ill/ill-requests.pl | 6 +++--- t/db_dependent/IllbatchStatuses.t | 12 +++++------ .../Koha/{Illbatch.t => ILL/Batch.t} | 4 ++-- .../{Illbatches.t => Koha/ILL/Batches.t} | 12 +++++------ t/db_dependent/api/v1/ill_batches.t | 20 +++++++++---------- 12 files changed, 60 insertions(+), 60 deletions(-) rename Koha/{Illbatch.pm => ILL/Batch.pm} (95%) rename Koha/{Illbatches.pm => ILL/Batches.pm} (82%) rename Koha/REST/V1/{Illbatches.pm => ILL/Batches.pm} (86%) rename t/db_dependent/Koha/{Illbatch.t => ILL/Batch.t} (91%) rename t/db_dependent/{Illbatches.t => Koha/ILL/Batches.t} (93%) diff --git a/Koha/Illbatch.pm b/Koha/ILL/Batch.pm similarity index 95% rename from Koha/Illbatch.pm rename to Koha/ILL/Batch.pm index 31048670f6..cce981bc8c 100644 --- a/Koha/Illbatch.pm +++ b/Koha/ILL/Batch.pm @@ -1,4 +1,4 @@ -package Koha::Illbatch; +package Koha::ILL::Batch; # Copyright PTFS Europe 2022 # @@ -32,13 +32,13 @@ use base qw(Koha::Object); =head1 NAME -Koha::Illbatch - Koha Illbatch Object class +Koha::ILL::Batch - Koha Illbatch Object class =head2 Class methods =head3 status - my $status = Koha::Illbatch->status; + my $status = Koha::ILL::Batch > status; Return the status object associated with this batch @@ -51,7 +51,7 @@ sub status { =head3 patron - my $patron = Koha::Illbatch->patron; + my $patron = Koha::ILL::Batch->patron; Return the I object associated with this batch @@ -66,7 +66,7 @@ sub patron { =head3 library - my $library = Koha::Illbatch->library; + my $library = Koha::ILL::Batch->library; Return the I object associated with this batch @@ -232,7 +232,7 @@ sub strings_map { =head3 _type - my $type = Koha::Illbatch->_type; + my $type = Koha::ILL::Batch->_type; Return this object's type diff --git a/Koha/Illbatches.pm b/Koha/ILL/Batches.pm similarity index 82% rename from Koha/Illbatches.pm rename to Koha/ILL/Batches.pm index ee65a262d6..507b5a45e5 100644 --- a/Koha/Illbatches.pm +++ b/Koha/ILL/Batches.pm @@ -1,4 +1,4 @@ -package Koha::Illbatches; +package Koha::ILL::Batches; # Copyright PTFS Europe 2022 # @@ -19,18 +19,18 @@ package Koha::Illbatches; use Modern::Perl; use Koha::Database; -use Koha::Illbatch; +use Koha::ILL::Batch; use base qw(Koha::Objects); =head1 NAME -Koha::Illbatches - Koha Illbatches Object class +Koha::ILL::Batches - Koha Illbatches Object class =head2 Internal methods =head3 _type - my $type = Koha::Illbatches->_type; + my $type = Koha::ILL::Batches->_type; Return this object's type @@ -42,14 +42,14 @@ sub _type { =head3 object_class - my $class = Koha::Illbatches->object_class; + my $class = Koha::ILL::Batches->object_class; Return this object's class name =cut sub object_class { - return 'Koha::Illbatch'; + return 'Koha::ILL::Batch'; } =head1 AUTHOR diff --git a/Koha/IllbatchStatus.pm b/Koha/IllbatchStatus.pm index e098762f90..b5c26c72f4 100644 --- a/Koha/IllbatchStatus.pm +++ b/Koha/IllbatchStatus.pm @@ -20,7 +20,7 @@ package Koha::IllbatchStatus; use Modern::Perl; use Koha::Database; use Koha::Illrequest::Logger; -use Koha::Illbatch; +use Koha::ILL::Batch; use JSON qw( to_json ); use base qw(Koha::Object); @@ -124,7 +124,7 @@ sub delete_and_log { } # Update all batches that use this status to have status UNKNOWN - my $affected = Koha::Illbatches->search( { status_code => $self->code } ); + my $affected = Koha::ILL::Batches->search( { status_code => $self->code } ); $affected->update( { status_code => 'UNKNOWN' } ); my $logger = Koha::Illrequest::Logger->new; diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 1080976cb3..e2853a648e 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -35,7 +35,7 @@ use Koha::Illrequestattributes; use Koha::AuthorisedValue; use Koha::Illrequest::Logger; use Koha::Patron; -use Koha::Illbatches; +use Koha::ILL::Batches; use Koha::AuthorisedValues; use Koha::Biblios; use Koha::Items; @@ -152,7 +152,7 @@ sub push_processor { my $ill_batch = $request->ill_batch; -Returns the I associated with the request +Returns the I associated with the request =cut @@ -161,7 +161,7 @@ sub ill_batch { my $ill_batch = $self->_result->ill_batch; return unless $ill_batch; - return Koha::Illbatch->_new_from_dbic($ill_batch); + return Koha::ILL::Batch->_new_from_dbic($ill_batch); } =head3 statusalias diff --git a/Koha/REST/V1/Illbatches.pm b/Koha/REST/V1/ILL/Batches.pm similarity index 86% rename from Koha/REST/V1/Illbatches.pm rename to Koha/REST/V1/ILL/Batches.pm index b4e7d6aa02..0f932e3622 100644 --- a/Koha/REST/V1/Illbatches.pm +++ b/Koha/REST/V1/ILL/Batches.pm @@ -1,4 +1,4 @@ -package Koha::REST::V1::Illbatches; +package Koha::REST::V1::ILL::Batches; # This file is part of Koha. # @@ -19,7 +19,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; -use Koha::Illbatches; +use Koha::ILL::Batches; use Koha::IllbatchStatuses; use Koha::Illrequests; @@ -27,7 +27,7 @@ use Try::Tiny qw( catch try ); =head1 NAME -Koha::REST::V1::Illbatches +Koha::REST::V1::ILL::Batches =head2 Operations @@ -43,7 +43,7 @@ sub list { return try { return $c->render( status => 200, - openapi => $c->objects->search( Koha::Illbatches->new ) + openapi => $c->objects->search( Koha::ILL::Batches->new ) ); } catch { warn "$_"; @@ -61,7 +61,7 @@ sub get { my $c = shift->openapi->valid_input or return; return try { - my $ill_batch = $c->objects->find( Koha::Illbatches->new, $c->param('ill_batch_id') ); + my $ill_batch = $c->objects->find( Koha::ILL::Batches->new, $c->param('ill_batch_id') ); unless ($ill_batch) { return $c->render( @@ -103,12 +103,12 @@ sub add { $body->{patron_id} = $patron->id; return try { - my $batch = Koha::Illbatch->new_from_api($body); + my $batch = Koha::ILL::Batch->new_from_api($body); $batch->create_and_log; $c->res->headers->location( $c->req->url->to_string . '/' . $batch->id ); - my $ill_batch = $c->objects->find( Koha::Illbatches->new, $batch->id ); + my $ill_batch = $c->objects->find( Koha::ILL::Batches->new, $batch->id ); return $c->render( status => 201, @@ -136,7 +136,7 @@ Update a batch sub update { my $c = shift->openapi->valid_input or return; - my $batch = Koha::Illbatches->find( $c->param('ill_batch_id') ); + my $batch = Koha::ILL::Batches->find( $c->param('ill_batch_id') ); unless ($batch) { return $c->render( @@ -170,7 +170,7 @@ sub delete { my $c = shift->openapi->valid_input or return; - my $batch = Koha::Illbatches->find( $c->param('ill_batch_id') ); + my $batch = Koha::ILL::Batches->find( $c->param('ill_batch_id') ); if ( not defined $batch ) { return $c->render( status => 404, openapi => { error => "ILL batch not found" } ); diff --git a/Koha/Schema/Result/Illbatch.pm b/Koha/Schema/Result/Illbatch.pm index d7e758cae7..a0c61a0a7e 100644 --- a/Koha/Schema/Result/Illbatch.pm +++ b/Koha/Schema/Result/Illbatch.pm @@ -205,11 +205,11 @@ __PACKAGE__->has_many( ); sub koha_object_class { - 'Koha::Illbatch'; + 'Koha::ILL::Batch'; } sub koha_objects_class { - 'Koha::Illbatches'; + 'Koha::ILL::Batches'; } 1; diff --git a/api/v1/swagger/paths/ill_batches.yaml b/api/v1/swagger/paths/ill_batches.yaml index 3d747be2a5..d7ea3a0b5c 100644 --- a/api/v1/swagger/paths/ill_batches.yaml +++ b/api/v1/swagger/paths/ill_batches.yaml @@ -1,7 +1,7 @@ --- /ill/batches: get: - x-mojo-to: Illbatches#list + x-mojo-to: ILL::Batches#list operationId: listIllbatches tags: - ill_batches @@ -62,7 +62,7 @@ permissions: ill: "1" post: - x-mojo-to: Illbatches#add + x-mojo-to: ILL::Batches#add operationId: addIllbatch tags: - ill_batches @@ -131,7 +131,7 @@ ill: "1" "/ill/batches/{ill_batch_id}": get: - x-mojo-to: Illbatches#get + x-mojo-to: ILL::Batches#get operationId: getIllbatches tags: - ill_batches @@ -197,7 +197,7 @@ permissions: ill: "1" put: - x-mojo-to: Illbatches#update + x-mojo-to: ILL::Batches#update operationId: updateIllBatch tags: - ill_batches @@ -250,7 +250,7 @@ permissions: ill: "1" delete: - x-mojo-to: Illbatches#delete + x-mojo-to: ILL::Batches#delete operationId: deleteBatch tags: - ill_batches diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index 9087825a0d..4586ee5ea3 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -28,7 +28,7 @@ use Koha::AuthorisedValues; use Koha::Illcomment; use Koha::Illrequests; use Koha::Illrequest; -use Koha::Illbatches; +use Koha::ILL::Batches; use Koha::Illrequest::Workflow::Availability; use Koha::Illrequest::Workflow::TypeDisclaimer; use Koha::Libraries; @@ -221,7 +221,7 @@ if ( $backends_available ) { # We simulate the API for backend requests for uniformity. # So, init: my $request = Koha::Illrequests->find($params->{illrequest_id}); - my $batches = Koha::Illbatches->search(undef, { + my $batches = Koha::ILL::Batches->search(undef, { order_by => { -asc => 'name' } }); if ( !$params->{stage} ) { @@ -402,7 +402,7 @@ if ( $backends_available ) { if ($active_filters->{batch_id}) { my $batch_id = $active_filters->{batch_id}; if ($batch_id) { - my $batch = Koha::Illbatches->find($batch_id); + my $batch = Koha::ILL::Batches->find($batch_id); $template->param( batch => $batch ); diff --git a/t/db_dependent/IllbatchStatuses.t b/t/db_dependent/IllbatchStatuses.t index 8748d73b56..e256363516 100755 --- a/t/db_dependent/IllbatchStatuses.t +++ b/t/db_dependent/IllbatchStatuses.t @@ -191,12 +191,12 @@ my $status5 = Koha::IllbatchStatus->new( } ); $status5->create_and_log; -my $batch = Koha::Illbatch->new( +my $batch = Koha::ILL::Batch->new( { - name => "My test batch", - patron_id => $patron->borrowernumber, - library_id => $library->branchcode, - backend => "TEST", + name => "My test batch", + patron_id => $patron->borrowernumber, + library_id => $library->branchcode, + backend => "TEST", status_code => $status5->code } ); @@ -205,7 +205,7 @@ $batch->create_and_log; # Delete the batch status and ensure the batch's status has been changed # to UNKNOWN $status5->delete_and_log; -my $updated_code = Koha::Illbatches->find( { status_code => "UNKNOWN" } ); +my $updated_code = Koha::ILL::Batches->find( { status_code => "UNKNOWN" } ); is( $updated_code->status_code, "UNKNOWN", "batches attached to deleted status have status changed to UNKNOWN" ); $schema->storage->txn_rollback; diff --git a/t/db_dependent/Koha/Illbatch.t b/t/db_dependent/Koha/ILL/Batch.t similarity index 91% rename from t/db_dependent/Koha/Illbatch.t rename to t/db_dependent/Koha/ILL/Batch.t index c18b686386..7d95e66df6 100755 --- a/t/db_dependent/Koha/Illbatch.t +++ b/t/db_dependent/Koha/ILL/Batch.t @@ -34,7 +34,7 @@ subtest 'ill_batch() tests' => sub { $schema->storage->txn_begin; - my $batch = $builder->build_object( { class => 'Koha::Illbatches' } ); + my $batch = $builder->build_object( { class => 'Koha::ILL::Batches' } ); my $request = $builder->build_object( { class => 'Koha::Illrequests', value => { batch_id => undef } } ); is( $request->ill_batch, undef, 'Not having a linked batch makes the method return undef' ); @@ -42,7 +42,7 @@ subtest 'ill_batch() tests' => sub { $request->batch_id( $batch->id )->store; my $linked_batch = $request->ill_batch; - is( ref($linked_batch), 'Koha::Illbatch' ); + is( ref($linked_batch), 'Koha::ILL::Batch' ); is( $linked_batch->id, $batch->id, 'Correct batch linked' ); $schema->storage->txn_rollback; diff --git a/t/db_dependent/Illbatches.t b/t/db_dependent/Koha/ILL/Batches.t similarity index 93% rename from t/db_dependent/Illbatches.t rename to t/db_dependent/Koha/ILL/Batches.t index d0c465217a..e3e192ed54 100755 --- a/t/db_dependent/Illbatches.t +++ b/t/db_dependent/Koha/ILL/Batches.t @@ -18,8 +18,8 @@ use Modern::Perl; use Koha::Database; -use Koha::Illbatch; -use Koha::Illbatches; +use Koha::ILL::Batch; +use Koha::ILL::Batches; use Koha::Illrequests; use Koha::Patrons; use t::lib::Mocks; @@ -31,8 +31,8 @@ use Test::More tests => 6; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; -use_ok('Koha::Illbatch'); -use_ok('Koha::Illbatches'); +use_ok('Koha::ILL::Batch'); +use_ok('Koha::ILL::Batches'); $schema->storage->txn_begin; @@ -53,8 +53,8 @@ my $branch = $builder->build( { source => 'Branch' } ); # Create a batch my $illbatch = $builder->build_object( { - class => 'Koha::Illbatches', - value => { + class => 'Koha::ILL::Batches', + value => { name => "My test batch", backend => "Mock", patron_id => $librarian->{borrowernumber}, diff --git a/t/db_dependent/api/v1/ill_batches.t b/t/db_dependent/api/v1/ill_batches.t index aae636d829..bc8e2a514d 100755 --- a/t/db_dependent/api/v1/ill_batches.t +++ b/t/db_dependent/api/v1/ill_batches.t @@ -25,8 +25,8 @@ use t::lib::Mocks; use JSON qw(encode_json); -use Koha::Illbatch; -use Koha::Illbatches; +use Koha::ILL::Batch; +use Koha::ILL::Batches; use Koha::Illrequests; use Koha::IllbatchStatuses; use Koha::Database; @@ -58,7 +58,7 @@ subtest 'list() tests' => sub { $librarian->set_password( { password => $password, skip_validation => 1 } ); my $userid = $librarian->userid; - my $batch_to_delete = $builder->build_object( { class => 'Koha::Illbatches' } ); + my $batch_to_delete = $builder->build_object( { class => 'Koha::ILL::Batches' } ); my $deleted_batch_id = $batch_to_delete->id; $batch_to_delete->delete; @@ -70,7 +70,7 @@ subtest 'list() tests' => sub { my $batch_1 = $builder->build_object( { - class => 'Koha::Illbatches', + class => 'Koha::ILL::Batches', value => { backend => "Mock", patron_id => $librarian->id, @@ -100,7 +100,7 @@ subtest 'list() tests' => sub { ->json_has( '/0/library', 'branch embedded' )->json_has( '/0/requests_count', 'request count' ); # Create a second batch with a different name - my $batch_2 = $builder->build_object( { class => 'Koha::Illbatches' } ); + my $batch_2 = $builder->build_object( { class => 'Koha::ILL::Batches' } ); $query = { ill_batch_id => [ $batch_1->id, $batch_2->id ] }; @@ -155,7 +155,7 @@ subtest 'get() tests' => sub { my $batch = $builder->build_object( { - class => 'Koha::Illbatches', + class => 'Koha::ILL::Batches', value => { backend => "Mock", patron_id => $librarian->id, @@ -176,7 +176,7 @@ subtest 'get() tests' => sub { $t->get_ok( "//$unauth_userid:$password@/api/v1/ill/batches/" . $batch->id )->status_is(403); - my $batch_to_delete = $builder->build_object( { class => 'Koha::Illbatches' } ); + my $batch_to_delete = $builder->build_object( { class => 'Koha::ILL::Batches' } ); my $non_existent_id = $batch_to_delete->id; $batch_to_delete->delete; @@ -288,7 +288,7 @@ subtest 'update() tests' => sub { my $unauth_userid = $patron->userid; my $library = $builder->build_object( { class => 'Koha::Libraries' } ); - my $batch_id = $builder->build_object( { class => 'Koha::Illbatches' } )->id; + my $batch_id = $builder->build_object( { class => 'Koha::ILL::Batches' } )->id; # Unauthorized attempt to update $t->put_ok( "//$unauth_userid:$password@/api/v1/ill/batches/$batch_id" => json => @@ -336,7 +336,7 @@ subtest 'update() tests' => sub { ] ); - my $batch_to_delete = $builder->build_object( { class => 'Koha::Illbatches' } ); + my $batch_to_delete = $builder->build_object( { class => 'Koha::ILL::Batches' } ); my $non_existent_id = $batch_to_delete->id; $batch_to_delete->delete; @@ -378,7 +378,7 @@ subtest 'delete() tests' => sub { $patron->set_password( { password => $password, skip_validation => 1 } ); my $unauth_userid = $patron->userid; - my $batch_id = $builder->build_object( { class => 'Koha::Illbatches' } )->id; + my $batch_id = $builder->build_object( { class => 'Koha::ILL::Batches' } )->id; # Unauthorized attempt to delete $t->delete_ok("//$unauth_userid:$password@/api/v1/ill/batches/$batch_id")->status_is(403); -- 2.39.5