From b212c83b6143115ae6d2ec78a0acb323377d3aaa Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 11 Dec 2024 15:45:00 -0300 Subject: [PATCH] Bug 38679: Add attribute mappings Koha::Old::Biblioitem This trivial patch replicates the mappings in Koha::Biblioitem. To test: 1. Pick a sample record ID 2. Fetch is using the API with your favourite tool: GET /api/v1/biblios/ Accept: application/json 3. Save the output for later 4. Delete the record 5. Fetch the deleted biblio using the API: GET /api/v1/deleted/biblios/ Accept: application/json 6. Compare the results => FAIL: Attributes like `volumedate` are not mapped! 7. Apply this patch 8. Repeat 5 => SUCCESS: Attributes are mapped! 9. Sign off :-D Signed-off-by: Tomas Cohen Arazi --- Koha/Old/Biblioitem.pm | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Koha/Old/Biblioitem.pm b/Koha/Old/Biblioitem.pm index 24f3a99d6df..fa9b107ce14 100644 --- a/Koha/Old/Biblioitem.pm +++ b/Koha/Old/Biblioitem.pm @@ -27,8 +27,56 @@ Koha::Old::Biblioitem - Koha Old::Biblioitem Object class =head2 Class methods +=head3 public_read_list + +This method returns the list of publicly readable database fields for both API and UI output purposes + +=cut + +sub public_read_list { + return [ + 'volume', 'number', 'isbn', + 'issn', 'ean', 'publicationyear', + 'publishercode', 'volumedate', 'columedesc', + 'collectiontitle', 'collectionissn', 'collectionvolume', + 'editionstatement', 'editionresponsibility', 'pages', + 'place', 'lccn', 'url', + 'cn_source', 'cn_class', 'cn)item', + 'cn_suffix', 'cn_sort', 'agerestriction', + 'totalissues' + ]; +} + +=head3 to_api_mapping + +This method returns the mapping for representing a Koha::Biblioitem object +on the API. + =cut +sub to_api_mapping { + return { + agerestriction => 'age_restriction', + biblionumber => 'biblio_id', + 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 -- 2.47.1