Bugzilla – Attachment 187180 Details for
Bug 38195
EDI/Edifact classes should use Koha::Objects instead of plain DBIC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38195: Modernise Koha::Edifact::Transport to use Koha::Objects
Bug-38195-Modernise-KohaEdifactTransport-to-use-Ko.patch (text/plain), 3.06 KB, created by
Martin Renvoize (ashimema)
on 2025-10-01 11:39:15 UTC
(
hide
)
Description:
Bug 38195: Modernise Koha::Edifact::Transport to use Koha::Objects
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-10-01 11:39:15 UTC
Size:
3.06 KB
patch
obsolete
>From 5ce5ddaf36ae537cf1a596a5bdd60f5ba9aa2a76 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Wed, 1 Oct 2025 07:46:54 +0100 >Subject: [PATCH] Bug 38195: Modernise Koha::Edifact::Transport to use > Koha::Objects > >This patch updates Koha::Edifact::Transport to use the new >Koha::EDI::Accounts and Koha::Edifact::Files object classes >instead of raw DBIx::Class objects. > >Changes: >- Replaced $schema->resultset('VendorEdiAccount')->find() with > Koha::EDI::Accounts->find() >- Replaced resultset('EdifactMessage')->find( { filename => $f, } ); > with Koha::Edifact::Files->search( { filename => $f }); >- Simplified file_transport retrieval by using the relationship > method from Koha::EDI::Account->file_transport() >- Removed conditional logic as the relationship method handles > undef cases automatically > >Benefits: >- Cleaner code using Koha object patterns >- Automatic relationship handling via accessor methods >- More maintainable and consistent with rest of codebase >--- > Koha/Edifact/Transport.pm | 19 ++++++++----------- > 1 file changed, 8 insertions(+), 11 deletions(-) > >diff --git a/Koha/Edifact/Transport.pm b/Koha/Edifact/Transport.pm >index 7ebc00a37be..6084877bfc4 100644 >--- a/Koha/Edifact/Transport.pm >+++ b/Koha/Edifact/Transport.pm >@@ -25,22 +25,19 @@ use Carp qw( carp ); > use Encode qw( from_to ); > use File::Slurp qw( read_file ); > >-use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); >-use Koha::File::Transports; >+use Koha::EDI::Accounts; >+use Koha::Edifact::Files; > > sub new { > my ( $class, $account_id ) = @_; >- my $database = Koha::Database->new(); >- my $schema = $database->schema(); >- my $acct = $schema->resultset('VendorEdiAccount')->find($account_id); >+ my $acct = Koha::EDI::Accounts->find($account_id); > >- # Get the file transport if configured >- my $file_transport = $acct->file_transport_id ? Koha::File::Transports->find( $acct->file_transport_id ) : undef; >+ # Cache the file transport if configured >+ my $file_transport = $acct->file_transport; > > my $self = { > account => $acct, >- schema => $schema, > file_transport => $file_transport, > working_dir => C4::Context::temporary_directory, #temporary work directory > transfer_date => dt_from_string(), >@@ -187,8 +184,8 @@ sub ingest { > foreach my $f (@downloaded_files) { > > # Check file has not been downloaded already >- my $existing_file = $self->{schema}->resultset('EdifactMessage')->find( { filename => $f, } ); >- if ($existing_file) { >+ my $existing_files = Koha::Edifact::Files->search( { filename => $f } ); >+ if ( $existing_files->count ) { > carp "skipping ingest of $f : filename exists"; > next; > } >@@ -201,7 +198,7 @@ sub ingest { > } > from_to( $file_content, 'iso-8859-1', 'utf8' ); > $msg_hash->{raw_msg} = $file_content; >- $self->{schema}->resultset('EdifactMessage')->create($msg_hash); >+ Koha::Edifact::File->new($msg_hash)->store(); > } > return; > } >-- >2.51.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38195
:
187161
|
187162
|
187163
|
187164
|
187178
|
187179
| 187180 |
187181