From 78b6d770483c2f0cd6cb972dc81f662fe65ff298 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 20 Oct 2023 11:43:35 +0000 Subject: [PATCH] Bug 35095: [WIP] Add kbart to koha biblio mapping Original code was relying on marc_record coming from a biblio, but when first creating a eholding local title, there is no biblio. As such, we must get koha fields kbart equivalents, transform those koha fields to a marc_record, and finally AddBiblio using that same marc_record. Test plan: 1. Enable ERMModule 2. Go to E-resource management > e-Holdings > Local > Packages 3. Click New package 4. Enter a package name 5. Click Submit 6. Go to e-Holdings > Local > Titles 7. Click New title 8. Fill out all the fields 9. Click Add to another package 10. Choose the package created previously 11. Click Submit 12. Click the title in the list 13. Click Local bibliographic record (next to Publication title) --> Note the record only has a title 14. Click MARC ORIGINALLY:--> Only tabs 0 and 2 have information, leader and 245$a NOW: Notice that fields 100, 110 and 500 also have information This is a WIP, more mapping required." --- Koha/ERM/EHoldings/Resource.pm | 5 ++++- Koha/ERM/EHoldings/Title.pm | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Koha/ERM/EHoldings/Resource.pm b/Koha/ERM/EHoldings/Resource.pm index 2457b2d644..c0b2207f53 100644 --- a/Koha/ERM/EHoldings/Resource.pm +++ b/Koha/ERM/EHoldings/Resource.pm @@ -68,7 +68,10 @@ sub store { $biblio_id = $title->biblio_id; C4::Biblio::ModBiblio($marc_record, $title->biblio_id, ''); } else { - ( $biblio_id ) = C4::Biblio::AddBiblio($marc_record, ''); + my $eholding_title = Koha::ERM::EHoldings::Titles->find($self->title_id); + + my $marc_record_from_kart = TransformKohaToMarc( $eholding_title->get_kbart_to_koha_biblio_mapping ); + ($biblio_id) = C4::Biblio::AddBiblio( $marc_record_from_kart, '' ); } $title->biblio_id($biblio_id)->store; diff --git a/Koha/ERM/EHoldings/Title.pm b/Koha/ERM/EHoldings/Title.pm index 7802581f37..aa9b669a6e 100644 --- a/Koha/ERM/EHoldings/Title.pm +++ b/Koha/ERM/EHoldings/Title.pm @@ -58,6 +58,35 @@ sub resources { return Koha::ERM::EHoldings::Resources->_new_from_dbic($resources_rs); } +=head3 resources + +Returns this title's kbart fields in koha fields format + +=cut + +sub get_kbart_to_koha_biblio_mapping { + my ( $self ) = @_; + + return { + 'biblio.copyrightdate' => undef, + 'biblio.part_name' => undef, + 'biblio.medium' => undef, + 'biblio.frameworkcode' => undef, + 'biblio.subtitle' => undef, + 'biblio.abstract' => undef, + 'biblio.unititle' => undef, + 'biblio.timestamp' => undef, + 'biblio.datecreated' => undef, + 'biblio.part_number' => undef, + 'biblio.author' => $self->first_author, + 'biblio.title' => $self->publication_title, + 'biblio.serial' => undef, + 'biblio.biblionumber' => $self->biblio_id, + 'biblio.notes' => $self->notes, + 'biblio.seriestitle' => undef + }; +} + =head2 Internal methods =head3 _type -- 2.30.2