Bugzilla – Attachment 96848 Details for
Bug 24321
Make objects.search use mappings from Koha::Object(s)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24321: Clean /biblios
Bug-24321-Clean-biblios.patch (text/plain), 5.07 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-01-06 15:33:02 UTC
(
hide
)
Description:
Bug 24321: Clean /biblios
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-01-06 15:33:02 UTC
Size:
5.07 KB
patch
obsolete
>From 8525f0df209782c03994a9640e7e7e59ef738d9f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 31 Dec 2019 12:26:46 -0300 >Subject: [PATCH] Bug 24321: Clean /biblios > >--- > Koha/Biblio.pm | 20 +++++++++++ > Koha/Biblioitem.pm | 34 +++++++++++++++++-- > Koha/REST/V1/Biblios.pm | 73 +++-------------------------------------- > 3 files changed, 56 insertions(+), 71 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 5b63653aec..8c26db04fb 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -724,6 +724,26 @@ sub custom_cover_image_url { > return $url; > } > >+=head3 to_api_mapping >+ >+This method returns the mapping for representing a Koha::Biblio object >+on the API. >+ >+=cut >+ >+sub to_api_mapping { >+ return { >+ biblionumber => 'biblio_id', >+ frameworkcode => 'framework_id', >+ unititle => 'uniform_title', >+ seriestitle => 'series_title', >+ copyrightdate => 'copyright_date', >+ datecreated => 'creation_date' >+ }; >+} >+ >+=head2 Internal methods >+ > =head3 type > > =cut >diff --git a/Koha/Biblioitem.pm b/Koha/Biblioitem.pm >index 8d353c8f0b..e524f8375d 100644 >--- a/Koha/Biblioitem.pm >+++ b/Koha/Biblioitem.pm >@@ -29,11 +29,41 @@ Koha::Biblioitem - Koha Biblioitem Object class > > =head1 API > >-=head2 Class Methods >+=head2 Class methods >+ >+=head3 to_api_mapping >+ >+This method returns the mapping for representing a Koha::Biblioitem object >+on the API. > > =cut > >-=head3 type >+sub to_api_mapping { >+ return { >+ agerestriction => 'age_restriction', >+ biblioitemnumber => undef, # meaningless >+ collectionissn => 'collection_issn', >+ collectiontitle => 'collection_title', >+ collectionvolume => 'collection_volume', >+ editionresponsibility => undef, # obsolete, not mapped >+ editionstatement => 'edition_statement', >+ illus => 'illustrations', >+ itemtype => 'item_type', >+ lccn => 'lc_control_number', >+ place => 'publication_place', >+ publicationyear => 'publication_year', >+ publishercode => 'publisher', >+ size => 'material_size', >+ totalissues => 'serial_total_issues', >+ volumedate => 'volume_date', >+ volumedesc => 'volume_description', >+ >+ }; >+} >+ >+=head2 Internal methods >+ >+=head3 _type > > =cut > >diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm >index b3cba7c8d3..498a0c8172 100644 >--- a/Koha/REST/V1/Biblios.pm >+++ b/Koha/REST/V1/Biblios.pm >@@ -28,7 +28,7 @@ use Try::Tiny; > > =head1 API > >-=head2 Class methods >+=head2 Methods > > =head3 get > >@@ -150,38 +150,6 @@ sub delete { > > =head2 Internal methods > >- >-=head3 _to_api >- >-Helper function that maps unblessed Koha::Patron objects into REST api >-attribute names. >- >-=cut >- >-sub _to_api { >- my $biblio = shift; >- >- # Rename attributes >- foreach my $column ( keys %{$Koha::REST::V1::Biblios::to_api_mapping} ) { >- my $mapped_column = $Koha::REST::V1::Biblios::to_api_mapping->{$column}; >- if ( exists $biblio->{$column} >- && defined $mapped_column ) >- { >- # key != undef >- $biblio->{$mapped_column} = delete $biblio->{$column}; >- } >- elsif ( exists $biblio->{$column} >- && !defined $mapped_column ) >- { >- # key == undef >- delete $biblio->{$column}; >- } >- } >- >- return $biblio; >-} >- >- > =head3 build_json_biblio > > Internal method that returns all the attributes from the biblio and biblioitems tables >@@ -193,47 +161,14 @@ sub build_json_biblio { > > my $biblio = $args->{biblio}; > >- my $response = $biblio->TO_JSON; >- my $biblioitem = $biblio->biblioitem->TO_JSON; >+ my $response = $biblio->to_api; >+ my $biblioitem = $biblio->biblioitem->to_api; > > foreach my $key ( keys %{ $biblioitem } ) { > $response->{$key} = $biblioitem->{$key}; > } > >- return _to_api($response); >+ return $response; > } > >- >-=head2 Global variables >- >-=head3 $to_api_mapping >- >-=cut >- >-our $to_api_mapping = { >- agerestriction => 'age_restriction', >- biblioitemnumber => undef, # meaningless >- biblionumber => 'biblio_id', >- collectionissn => 'collection_issn', >- collectiontitle => 'collection_title', >- collectionvolume => 'collection_volume', >- copyrightdate => 'copyright_date', >- datecreated => 'creation_date', >- editionresponsibility => undef, # obsolete, not mapped >- editionstatement => 'edition_statement', >- frameworkcode => 'framework_id', >- illus => 'illustrations', >- itemtype => 'item_type', >- lccn => 'lc_control_number', >- place => 'publication_place', >- publicationyear => 'publication_year', >- publishercode => 'publisher', >- seriestitle => 'series_title', >- size => 'material_size', >- totalissues => 'serial_total_issues', >- unititle => 'uniform_title', >- volumedate => 'volume_date', >- volumedesc => 'volume_description', >-}; >- > 1; >-- >2.24.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 24321
:
96703
|
96704
|
96705
|
96706
|
96707
|
96708
|
96709
|
96710
|
96711
|
96712
|
96713
|
96714
|
96715
|
96716
|
96717
|
96718
|
96719
|
96720
|
96721
|
96722
|
96744
|
96840
|
96841
|
96842
|
96843
|
96844
|
96845
|
96846
|
96847
|
96848
|
96849
|
96850
|
96851
|
96852
|
96874
|
96875
|
96876
|
96877
|
96878
|
96879
|
96880
|
96881
|
96882
|
96883
|
96884
|
96885
|
96886
|
96887
|
96939
|
96940
|
96941
|
96942
|
96943
|
96944
|
96945
|
96946
|
96947
|
96948
|
96949
|
96950
|
96951
|
96952