Bugzilla – Attachment 166439 Details for
Bug 34788
Add the ability to import KBART files to ERM
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34788: Make biblio creation optional
Bug-34788-Make-biblio-creation-optional.patch (text/plain), 12.72 KB, created by
Nick Clemens (kidclamp)
on 2024-05-08 19:36:46 UTC
(
hide
)
Description:
Bug 34788: Make biblio creation optional
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-05-08 19:36:46 UTC
Size:
12.72 KB
patch
obsolete
>From 8feaea3f0f5dca3ec389c7db687084ca2eb9c355 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Wed, 17 Apr 2024 14:22:29 +0000 >Subject: [PATCH] Bug 34788: Make biblio creation optional > >This patch rebases in the changes from bug 36618 to make biblio creation optional > >Signed-off-by: Clemens Tubach <clemens.tubach@kit.edu> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/BackgroundJob/ImportKBARTFile.pm | 16 ++-- > Koha/REST/V1/ERM/EHoldings/Titles/Local.pm | 19 ++-- > .../swagger/paths/erm_eholdings_titles.yaml | 2 + > .../import_from_kbart_file.inc | 2 +- > .../ERM/EHoldingsLocalTitlesKBARTImport.vue | 86 +++++++++++-------- > .../Koha/BackgroundJob/ImportKBARTFile.t | 28 ++---- > 6 files changed, 78 insertions(+), 75 deletions(-) > >diff --git a/Koha/BackgroundJob/ImportKBARTFile.pm b/Koha/BackgroundJob/ImportKBARTFile.pm >index 8114abe0d2c..64e757d25e3 100644 >--- a/Koha/BackgroundJob/ImportKBARTFile.pm >+++ b/Koha/BackgroundJob/ImportKBARTFile.pm >@@ -76,9 +76,10 @@ sub process { > }; > > try { >- my $column_headers = $args->{column_headers}; >- my $rows = $args->{rows}; >- my $package_id = $args->{package_id}; >+ my $column_headers = $args->{column_headers}; >+ my $rows = $args->{rows}; >+ my $package_id = $args->{package_id}; >+ my $create_linked_biblio = $args->{create_linked_biblio}; > > if ( scalar( @{$rows} ) == 0 ) { > push @messages, { >@@ -118,7 +119,8 @@ sub process { > }; > $failed_imports++; > } else { >- my $imported_title = Koha::ERM::EHoldings::Title->new($formatted_title)->store; >+ my $imported_title = Koha::ERM::EHoldings::Title->new($formatted_title) >+ ->store( { create_linked_biblio => $create_linked_biblio } ); > create_linked_resource( > { > title => $imported_title, >@@ -216,7 +218,7 @@ sub read_file { > > my $file_content = defined( $file->{file_content} ) ? decode_base64( $file->{file_content} ) : ""; > my $delimiter = $file->{filename} =~ /\.tsv$/ ? "\t" : ","; >- my $quote_char = $file->{filename} =~ /\.tsv$/ ? "" : '"'; >+ my $quote_char = $file->{filename} =~ /\.tsv$/ ? "\"" : "\""; > > open my $fh, "<", \$file_content or die; > my $csv = Text::CSV_XS->new( >@@ -422,10 +424,10 @@ sub is_file_too_large { > }; > } > >-=head3 >+=head3 rescue_EBSCO_files > > EBSCO have an incorrect spelling of "preceding_publication_title_id" in all of their KBART files ("preceeding" instead of "preceding"). >-This is very annoying because it means all of their KBART files fail to import using the current methodology. >+This means all of their KBART files fail to import using the current methodology. > There is no simple way of finding out who the vendor is before importing so all KBART files from any vendor are going to have to be checked for this spelling and corrected. > > =cut >diff --git a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm >index 64ae0d45d15..775fb89da6b 100644 >--- a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm >+++ b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm >@@ -272,9 +272,10 @@ sub import_from_list { > sub import_from_kbart_file { > my $c = shift or return; > >- my $import_data = $c->req->json; >- my $file = $import_data->{file}; >- my $package_id = $import_data->{package_id}; >+ my $import_data = $c->req->json; >+ my $file = $import_data->{file}; >+ my $package_id = $import_data->{package_id}; >+ my $create_linked_biblio = $import_data->{create_linked_biblio}; > > return try { > my @job_ids; >@@ -306,10 +307,11 @@ sub import_from_kbart_file { > ) if scalar(@invalid_columns) > 0; > > my $params = { >- column_headers => $column_headers, >- rows => $rows, >- package_id => $package_id, >- file_name => $file->{filename} >+ column_headers => $column_headers, >+ rows => $rows, >+ package_id => $package_id, >+ file_name => $file->{filename}, >+ create_linked_biblio => $create_linked_biblio > }; > my $outcome = Koha::BackgroundJob::ImportKBARTFile::is_file_too_large( $params, $max_allowed_packet ); > >@@ -347,5 +349,4 @@ sub import_from_kbart_file { > }; > } > >- >-1; >+1; >\ No newline at end of file >diff --git a/api/v1/swagger/paths/erm_eholdings_titles.yaml b/api/v1/swagger/paths/erm_eholdings_titles.yaml >index f2fdef93c58..7e4e60411e4 100644 >--- a/api/v1/swagger/paths/erm_eholdings_titles.yaml >+++ b/api/v1/swagger/paths/erm_eholdings_titles.yaml >@@ -516,6 +516,8 @@ > type: object > package_id: > type: string >+ create_linked_biblio: >+ type: boolean > additionalProperties: false > responses: > 201: >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/import_from_kbart_file.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/import_from_kbart_file.inc >index fe1bee7ace9..28d0dfb5f32 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/import_from_kbart_file.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/import_from_kbart_file.inc >@@ -1,4 +1,5 @@ > [% USE Koha %] >+[% USE raw %] > > [% BLOCK report %] > [% SET report = job.report %] >@@ -90,6 +91,5 @@ > } > }); > }); >- > </script> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue >index 055c4e6ae88..401732ce359 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue >@@ -17,46 +17,55 @@ > </ol> > </li> > </ul> >- <h3>{{ $__("File") }}:</h3> >- <div class="file_information"> >- <span v-if="!file.filename"> >- {{ $__("Select a file") }} >- <input >- type="file" >- @change="selectFile($event)" >- :id="`import_file`" >- :name="`import_file`" >- required >- /> >- </span> >+ <fieldset class="rows" id="package_list"> >+ <h3>{{ $__("Select file for upload") }}:</h3> > <ol> >- <li v-show="file.filename"> >- {{ $__("File name") }}: >- <span>{{ file.filename }}</span> >+ <li> >+ <label for="import_file">{{ $__("File") }}:</label> >+ <input >+ type="file" >+ @change="selectFile($event)" >+ :id="`import_file`" >+ :name="`import_file`" >+ required >+ /> >+ </li> >+ <li> >+ <label for="package_id" >+ >{{ $__("To the following local package") }}:</label >+ > >+ <v-select >+ id="package_id" >+ v-model="package_id" >+ label="name" >+ :reduce="p => p.package_id" >+ :options="packages" >+ :clearable="false" >+ :required="!package_id" >+ > >+ <template #search="{ attributes, events }"> >+ <input >+ :required="!package_id" >+ class="vs__search" >+ v-bind="attributes" >+ v-on="events" >+ /> >+ </template> >+ </v-select> >+ <span class="required">{{ $__("Required") }}</span> >+ </li> >+ <li> >+ <label for="create_linked_biblio" >+ >{{ $__("Create linked biblio record") }}:</label >+ > >+ <input >+ type="checkbox" >+ id="create_linked_biblio" >+ v-model="create_linked_biblio" >+ /> > </li> > </ol> >- <fieldset id="package_list"> >- {{ $__("To the following local package") }}: >- <v-select >- v-model="package_id" >- label="name" >- :reduce="p => p.package_id" >- :options="packages" >- :clearable="false" >- :required="!package_id" >- > >- <template #search="{ attributes, events }"> >- <input >- :required="!package_id" >- class="vs__search" >- v-bind="attributes" >- v-on="events" >- /> >- </template> >- </v-select> >- <span class="required">{{ $__("Required") }}</span> >- </fieldset> >- </div> >+ </fieldset> > <fieldset class="action"> > <ButtonSubmit /> > <a @click="clearForm()" role="button" class="cancel">{{ >@@ -81,6 +90,7 @@ export default { > }, > packages: [], > package_id: null, >+ create_linked_biblio: false, > } > }, > beforeCreate() { >@@ -113,6 +123,7 @@ export default { > const importData = { > file: this.file, > package_id: this.package_id, >+ create_linked_biblio: this.create_linked_biblio, > } > client.localTitles.import_kbart(importData).then( > success => { >@@ -162,6 +173,7 @@ export default { > file_content: null, > } > this.package_id = null >+ this.create_linked_biblio = false > }, > }, > components: { >diff --git a/t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t b/t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t >index 76b5618defd..57e68e0b985 100755 >--- a/t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t >+++ b/t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t >@@ -194,7 +194,7 @@ Nature Astronomy 2397-3366 2017-01 1 1 https://www.nature.com/natastron 4bb > }; > > subtest 'process' => sub { >- plan tests => 12; >+ plan tests => 13; > > $schema->storage->txn_begin; > >@@ -364,26 +364,12 @@ Nature Astronomy 2397-3366 2017-01 1 1 https://www.nature.com/natastron 4bb > is( $job4->report->{duplicates_found}, 1, 'One duplicate found' ); > is( $job4->report->{titles_imported}, 0, 'No titles were imported' ); > is( $job4->report->{failed_imports}, 1, 'One failure found' ); >- is_deeply( >- $job4->messages, >- [ >- { >- 'type' => 'error', >- 'title' => 'Nature Plants', >- 'error_message' => >- 'DBIx::Class::Row::store_column(): No such column \'unknown_field\' on Koha::Schema::Result::ErmEholdingsTitle at /kohadevbox/koha/Koha/Object.pm line 79 >-', >- 'code' => 'title_failed' >- }, >- { >- 'code' => 'title_already_exists', >- 'error_message' => undef, >- 'title' => 'Nature Astronomy', >- 'type' => 'warning' >- } >- ], >- 'One duplicate message and one failure message for an incorrect column' >+ >+ is( >+ index( @{ $job4->messages }[0]->{error_message}, 'No such column \'unknown_field\'' ) > 0, 1, >+ 'Error message for an unknown column' > ); >+ is( @{ $job4->messages }[1]->{code}, 'title_already_exists', 'Error message for a duplicate title' ); > > $schema->storage->txn_rollback; >- } >+} >\ No newline at end of file >-- >2.39.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 34788
:
161379
|
161380
|
161381
|
161382
|
161383
|
161384
|
161391
|
165189
|
165190
|
165191
|
165192
|
165193
|
165194
|
165195
|
165196
|
165197
|
165837
|
165887
|
165888
|
165889
|
165890
|
165891
|
165892
|
165893
|
165894
|
166420
|
166433
|
166434
|
166435
|
166436
|
166437
|
166438
| 166439 |
166440
|
166441
|
166571
|
166645