Bugzilla – Attachment 158945 Details for
Bug 30070
Performance issues with edifactmsgs when you have a large number of messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30070: Add fetch endpoint for EDI Files
Bug-30070-Add-fetch-endpoint-for-EDI-Files.patch (text/plain), 8.48 KB, created by
Kyle M Hall (khall)
on 2023-11-14 17:01:41 UTC
(
hide
)
Description:
Bug 30070: Add fetch endpoint for EDI Files
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-11-14 17:01:41 UTC
Size:
8.48 KB
patch
obsolete
>From f82e5bfa077168e2a174d5c5b8c147e8c5f4ceec Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 10 Nov 2023 12:44:36 +0000 >Subject: [PATCH] Bug 30070: Add fetch endpoint for EDI Files > >This patch adds a simple EDI Files listing REST endpoint > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Edifact/File.pm | 42 +++++++++++++ > Koha/Edifact/Files.pm | 3 +- > .../V1/Acquisitions/Vendor/Edifact/Files.pm | 63 +++++++++++++++++++ > api/v1/swagger/definitions/edifact_file.yaml | 63 +++++++++++++++++++ > .../swagger/paths/acquisitions_edifiles.yaml | 63 +++++++++++++++++++ > api/v1/swagger/swagger.yaml | 4 ++ > 6 files changed, 236 insertions(+), 2 deletions(-) > create mode 100644 Koha/REST/V1/Acquisitions/Vendor/Edifact/Files.pm > create mode 100644 api/v1/swagger/definitions/edifact_file.yaml > create mode 100644 api/v1/swagger/paths/acquisitions_edifiles.yaml > >diff --git a/Koha/Edifact/File.pm b/Koha/Edifact/File.pm >index 8f01f1dff3e..8e9cea555cd 100644 >--- a/Koha/Edifact/File.pm >+++ b/Koha/Edifact/File.pm >@@ -27,6 +27,48 @@ Koha::Edifact::File - Koha::Object class for single edifact file > > =head2 Class methods > >+=head3 vendor >+ >+ my $vendor = $edifile->vendor; >+ >+Returns the I<Koha::Acquisition::Bookseller> associated with this edifact file >+ >+=cut >+ >+sub vendor { >+ my ($self) = @_; >+ my $vendor_rs = $self->_result->vendor; >+ return Koha::Acquisition::Bookseller->_new_from_dbic( $vendor_rs ); >+} >+ >+=head3 basket >+ >+ my $basket = $edifile->basket; >+ >+Returns the I<Koha::Acquisition::Basket> associated with this edifact file. >+ >+=cut >+ >+sub basket { >+ my ( $self ) = @_; >+ my $basket_rs = $self->_result->basketno; >+ return Koha::Acquisition::Basket->_new_from_dbic( $basket_rs ); >+} >+ >+=head3 to_api_mapping >+ >+This method returns the mapping for representing a Koha::Edifact::File object >+on the API. >+ >+=cut >+ >+sub to_api_mapping { >+ return { >+ message_type => 'type', >+ basketno => 'basket_id', >+ }; >+} >+ > =head2 Internal methods > > =head3 _type >diff --git a/Koha/Edifact/Files.pm b/Koha/Edifact/Files.pm >index e0701d24794..05da72db316 100644 >--- a/Koha/Edifact/Files.pm >+++ b/Koha/Edifact/Files.pm >@@ -18,6 +18,7 @@ package Koha::Edifact::Files; > use Modern::Perl; > > use Koha::Database; >+use Koha::Edifact::File; > > use base qw(Koha::Objects); > >@@ -27,8 +28,6 @@ Koha::Edifact::Files - Koha Edifact File Object set class > > =head1 API > >-=head2 Class Methods >- > =head2 Internal methods > > =head3 _type >diff --git a/Koha/REST/V1/Acquisitions/Vendor/Edifact/Files.pm b/Koha/REST/V1/Acquisitions/Vendor/Edifact/Files.pm >new file mode 100644 >index 00000000000..1f4ae3fc09e >--- /dev/null >+++ b/Koha/REST/V1/Acquisitions/Vendor/Edifact/Files.pm >@@ -0,0 +1,63 @@ >+package Koha::REST::V1::Acquisitions::Vendor::Edifact::Files; >+ >+# 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, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Mojo::Base 'Mojolicious::Controller'; >+ >+use Koha::Edifact::Files; >+ >+use Try::Tiny qw( catch try ); >+ >+=head1 NAME >+ >+Koha::REST::V1::Acquisitions::Edifact::Files >+ >+=head1 API >+ >+=head2 Class methods >+ >+=head3 list >+ >+Controller function that handles edifact files >+ >+=cut >+ >+=head3 list >+ >+Return the list of edifact files >+ >+=cut >+ >+sub list { >+ my $c = shift->openapi->valid_input or return; >+ >+ return try { >+ >+ my $files_rs = Koha::Edifact::Files->new; >+ my $files = $c->objects->search($files_rs); >+ >+ return $c->render( >+ status => 200, >+ openapi => $files, >+ ); >+ } catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ >+1; >diff --git a/api/v1/swagger/definitions/edifact_file.yaml b/api/v1/swagger/definitions/edifact_file.yaml >new file mode 100644 >index 00000000000..4f32fbe4cdc >--- /dev/null >+++ b/api/v1/swagger/definitions/edifact_file.yaml >@@ -0,0 +1,63 @@ >+--- >+type: object >+properties: >+ id: >+ type: integer >+ description: internally assigned edifect file identifier >+ readOnly: true >+ type: >+ type: >+ - string >+ description: Edifact file type >+ transfer_date: >+ type: >+ - string >+ - "null" >+ format: date >+ description: Edifact file transfer date >+ vendor_id: >+ type: >+ - string >+ - "null" >+ description: Koha vendor id >+ vendor: >+ type: >+ - object >+ - "null" >+ description: Koha vendor >+ edi_acct: >+ type: >+ - string >+ - "null" >+ description: Edifact account >+ status: >+ type: >+ - string >+ - "null" >+ description: Edifact file status >+ basket_id: >+ type: >+ - string >+ - "null" >+ description: Koha basket id >+ basket: >+ type: >+ - object >+ - "null" >+ description: Koha basket >+ raw_msg: >+ type: >+ - string >+ - "null" >+ description: Edifact message >+ filename: >+ type: >+ - string >+ - "null" >+ description: Edifact file name >+ deleted: >+ type: >+ - boolean >+ - "null" >+ description: Is this file deleted >+additionalProperties: false >diff --git a/api/v1/swagger/paths/acquisitions_edifiles.yaml b/api/v1/swagger/paths/acquisitions_edifiles.yaml >new file mode 100644 >index 00000000000..c7968fcde35 >--- /dev/null >+++ b/api/v1/swagger/paths/acquisitions_edifiles.yaml >@@ -0,0 +1,63 @@ >+--- >+/acquisitions/edifiles: >+ get: >+ x-mojo-to: Acquisitions::Vendor::Edifact::Files#list >+ operationId: listEdifactFiles >+ tags: >+ - edifiles >+ summary: List edifact files >+ produces: >+ - application/json >+ parameters: >+ - $ref: "../swagger.yaml#/parameters/match" >+ - $ref: "../swagger.yaml#/parameters/order_by" >+ - $ref: "../swagger.yaml#/parameters/page" >+ - $ref: "../swagger.yaml#/parameters/per_page" >+ - $ref: "../swagger.yaml#/parameters/q_param" >+ - $ref: "../swagger.yaml#/parameters/q_body" >+ - $ref: "../swagger.yaml#/parameters/request_id_header" >+ - name: x-koha-embed >+ in: header >+ required: false >+ description: Embed list sent as a request header >+ type: array >+ items: >+ type: string >+ enum: >+ - vendor >+ - basket >+ collectionFormat: csv >+ >+ responses: >+ "200": >+ description: A list of edifact files >+ schema: >+ type: array >+ items: >+ $ref: "../swagger.yaml#/definitions/edifact_file" >+ "401": >+ description: Authentication required >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "403": >+ description: Access forbidden >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "404": >+ description: Edifile not found >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "500": >+ description: | >+ Internal server error. Possible `error_code` attribute values: >+ >+ * `internal_server_error` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "503": >+ description: Under maintenance >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ x-koha-authorization: >+ permissions: >+ acquisition: edi_manage >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index 46966e40b2b..227921d7957 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -38,6 +38,8 @@ definitions: > $ref: ./definitions/credit.yaml > debit: > $ref: ./definitions/debit.yaml >+ edifact_file: >+ $ref: ./definitions/edifact_file.yaml > erm_config: > $ref: ./definitions/erm_config.yaml > erm_agreement: >@@ -163,6 +165,8 @@ definitions: > paths: > /acquisitions/baskets/managers: > $ref: ./paths/acquisitions_baskets.yaml#/~1acquisitions~1baskets~1managers >+ /acquisitions/edifiles: >+ $ref: ./paths/acquisitions_edifiles.yaml#/~1acquisitions~1edifiles > /acquisitions/funds: > $ref: ./paths/acquisitions_funds.yaml#/~1acquisitions~1funds > /acquisitions/funds/owners: >-- >2.30.2
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 30070
:
158808
|
158809
|
158810
|
158887
|
158903
|
158904
|
158905
|
158906
|
158907
|
158908
|
158909
|
158910
|
158911
|
158912
|
158913
|
158914
|
158915
|
158918
|
158920
|
158922
|
158923
|
158924
|
158925
|
158926
|
158927
|
158928
|
158929
|
158930
|
158931
|
158932
|
158933
|
158934
|
158935
|
158936
|
158937
|
158938
|
158939
|
158940
|
158941
|
158942
|
158943
|
158944
|
158945
|
158946
|
158947
|
158948
|
158949
|
158950
|
158951
|
158952
|
158953
|
158954
|
158955
|
158963
|
158964
|
158965
|
158966
|
158967
|
158968
|
158969
|
158970
|
158971
|
158972
|
158973
|
158974
|
158975
|
159026
|
159027
|
159028
|
159029
|
159030
|
159031
|
159032
|
159033
|
159034
|
159035
|
159036
|
160336
|
160337
|
160338
|
160339
|
160340
|
160341
|
160342
|
160343
|
160344
|
160345
|
160346
|
160347
|
160348