Bugzilla – Attachment 159829 Details for
Bug 33036
Add route to merge bibliographic records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33036: Improve REST API controller
Bug-33036-Improve-REST-API-controller.patch (text/plain), 2.68 KB, created by
Jonathan Druart
on 2023-12-14 10:29:12 UTC
(
hide
)
Description:
Bug 33036: Improve REST API controller
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-12-14 10:29:12 UTC
Size:
2.68 KB
patch
obsolete
>From d173b755aaf6af4308fe354c8153c916bcfda5a6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 14 Dec 2023 11:08:37 +0100 >Subject: [PATCH] Bug 33036: Improve REST API controller > >--- > Koha/REST/V1/Biblios.pm | 32 +++++++++++--------------------- > 1 file changed, 11 insertions(+), 21 deletions(-) > >diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm >index ec174d4f804..0f66754f830 100644 >--- a/Koha/REST/V1/Biblios.pm >+++ b/Koha/REST/V1/Biblios.pm >@@ -907,13 +907,9 @@ sub merge { > my $ref_biblionumber = $c->param('biblio_id'); > my $json = decode_json( $c->req->body ); > my $bn_merge = $json->{'biblio_id_to_merge'}; >- my $framework = $json->{'framework_to_use'}; >- my $rules = $json->{'rules'}; >- my $override_rec = $json->{'datarecord'}; >- >- if ( ( !defined $rules ) || ( $rules eq '' ) ) { $rules = 'override'; } >- if ( ( !defined $override_rec ) ) { $override_rec = ''; } >- if ( ( !defined $framework ) ) { $framework = ''; } >+ my $framework = $json->{'framework_to_use'} // q{}; >+ my $rules = $json->{'rules'} || q{override}; >+ my $override_rec = $json->{'datarecord'} // q{}; > > my $biblio = Koha::Biblios->find($ref_biblionumber); > if ( not defined $biblio ) { >@@ -947,25 +943,17 @@ sub merge { > ); > } > >- my $results; >- eval { >+ return try { > if ( $rules eq 'override_ext' ) { > my $record = MARC::Record::MiJ->new_from_mij_structure($override_rec); > $record->encoding('UTF-8'); >- if ( $framework eq '' ) { $framework = $biblio->frameworkcode; } >+ $framework ||= $biblio->frameworkcode; > my $chk = ModBiblio( $record, $ref_biblionumber, $framework ); > if ( $chk != 1 ) { die "Error on ModBiblio"; } # ModBiblio returns 1 if everything as gone well >- my @biblio_ids_to_merge = ($bn_merge); >- $results = $biblio->merge_with( \@biblio_ids_to_merge ); >- } >- if ( $rules eq 'override' ) { >- my @biblio_ids_to_merge = ($bn_merge); >- $results = $biblio->merge_with( \@biblio_ids_to_merge ); > } >- }; >- if ($@) { >- return $c->render( status => 400, json => { error => $@ } ); >- } else { >+ >+ $biblio->merge_with( [$bn_merge] ); >+ > $c->respond_to( > mij => { > status => 200, >@@ -973,7 +961,9 @@ sub merge { > data => $biblio->metadata->record->to_mij > } > ); >- } >+ } catch { >+ $c->render( status => 400, json => { error => $@ } ); >+ }; > } > > 1; >-- >2.34.1
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 33036
:
152436
|
152437
|
152438
|
152439
|
152440
|
152447
|
152472
|
152659
|
152678
|
157481
|
157482
|
157731
|
159011
|
159012
|
159103
|
159120
|
159191
|
159239
|
159826
|
159827
|
159828
|
159829
|
160302
|
160468
|
160469
|
160470
|
160471
|
160472