Bugzilla – Attachment 148998 Details for
Bug 32782
Add UNIMARC support to the ERM module
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32782: Koha to KBart mapping for UNIMARC
Bug-32782-Koha-to-KBart-mapping-for-UNIMARC.patch (text/plain), 13.49 KB, created by
Biblibre Sandboxes
on 2023-03-30 14:37:14 UTC
(
hide
)
Description:
Bug 32782: Koha to KBart mapping for UNIMARC
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2023-03-30 14:37:14 UTC
Size:
13.49 KB
patch
obsolete
>From 5e42aa575fb1107f094ccdbd42788f9793b41f14 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 22 Mar 2023 12:39:59 +0100 >Subject: [PATCH] Bug 32782: Koha to KBart mapping for UNIMARC > >Used when creating eholdings from Koha items. > >Test plan: >Add some items to a list, then use this list to create eholdings >/cgi-bin/koha/erm/eholdings/local/titles/import > >Signed-off-by: Laurence Rault <laurence.rault@biblibre.com> >--- > .../CreateEHoldingsFromBiblios.pm | 201 ++++++++++++------ > 1 file changed, 136 insertions(+), 65 deletions(-) > >diff --git a/Koha/BackgroundJob/CreateEHoldingsFromBiblios.pm b/Koha/BackgroundJob/CreateEHoldingsFromBiblios.pm >index 3f071281a3..5216a7ce85 100644 >--- a/Koha/BackgroundJob/CreateEHoldingsFromBiblios.pm >+++ b/Koha/BackgroundJob/CreateEHoldingsFromBiblios.pm >@@ -47,6 +47,137 @@ sub job_type { > return 'create_eholdings_from_biblios'; > } > >+ >+my $fix_coverage = sub { >+ my $coverage = shift || q{}; >+ my @coverages = split '-', $coverage; >+ return ($coverages[0], (@coverages > 1 ? $coverages[1] : q{})); >+}; >+ >+sub _get_unimarc_mapping { >+ my ($biblio) = @_; >+ my $record = $biblio->metadata->record; >+ my $biblio_id = $biblio->biblionumber; >+ my $publication_title = $biblio->title; >+ my $print_identifier = >+ $record->subfield( '010', 'a' ) >+ || $record->subfield( '010', 'z' ) >+ || $record->subfield( '011', 'a' ) >+ || $record->subfield( '011', 'y' ); >+ my $online_identifier = $print_identifier; >+ my $date_first_issue_online = $record->subfield( '955', 'a' ); >+ my $date_last_issue_online = $record->subfield( '955', 'k' ); >+ my $num_first_vol_online = $record->subfield( '955', 'd' ); >+ my $num_last_vol_online = $record->subfield( '955', 'n' ); >+ my $num_first_issue_online = $record->subfield( '955', 'e' ); >+ my $num_last_issue_online = $record->subfield( '955', 'o' ); >+ my $title_url = $record->subfield( '856', 'u' ); >+ my $first_author = $biblio->author; >+ my $embargo_info = $record->subfield( '371', 'a' ); >+ my $coverage_depth = $title_url ? 'fulltext' : 'print'; >+ my $notes = $record->subfield( '336', 'a' ); >+ my $publisher_name = $record->subfield( '214', 'c' ); >+ my $label_pos67 = substr( $record->leader, 6, 2 ); >+ my $publication_type = $label_pos67 eq 'am' ? 'monograph' : $label_pos67 eq 'as' ? 'serial' : ''; >+ my $date_monograph_published_print = $record->subfield( '214', 'd' ) || substr( $record->subfield(100, 'a'), 9, 4 ) || ''; >+ my $date_monograph_published_online = $date_monograph_published_print; >+ my $monograph_volume = $record->subfield( '200', 'v' ); >+ my $monograph_edition = $record->subfield( '205', 'a' ); >+ my $first_editor = $publisher_name; >+ my $parent_publication_title_id = ''; # FIXME ? >+ my $preceeding_publication_title_id = ''; # FIXME ? >+ my $access_type = $record->subfield( '856', 'y' ); >+ >+ return { >+ biblio_id => $biblio_id, >+ publication_title => $publication_title, >+ print_identifier => $print_identifier, >+ online_identifier => $online_identifier, >+ date_first_issue_online => $date_first_issue_online, >+ num_first_vol_online => $num_first_vol_online, >+ num_first_issue_online => $num_first_issue_online, >+ date_last_issue_online => $date_last_issue_online, >+ num_last_vol_online => $num_last_vol_online, >+ num_last_issue_online => $num_last_issue_online, >+ title_url => $title_url, >+ first_author => $first_author, >+ embargo_info => $embargo_info, >+ coverage_depth => $coverage_depth, >+ notes => $notes, >+ publisher_name => $publisher_name, >+ publication_type => $publication_type, >+ date_monograph_published_print => $date_monograph_published_print, >+ date_monograph_published_online => $date_monograph_published_online, >+ monograph_volume => $monograph_volume, >+ monograph_edition => $monograph_edition, >+ first_editor => $first_editor, >+ parent_publication_title_id => $parent_publication_title_id, >+ preceeding_publication_title_id => $preceeding_publication_title_id, >+ access_type => $access_type, >+ }; >+} >+ >+sub _get_marc21_mapping { >+ my ($biblio) = @_; >+ my $record = $biblio->metadata->record; >+ my $biblio_id = $biblio->biblionumber; >+ my $publication_title = $biblio->title; >+ my $print_identifier = >+ $record->subfield( '020', 'a' ) >+ || $record->subfield( '020', 'z' ) >+ || $record->subfield( '022', 'a' ) >+ || $record->subfield( '022', 'y' ); >+ my $online_identifier = $print_identifier; >+ my ( $date_first_issue_online, $date_last_issue_online ) = >+ $fix_coverage->( $record->subfield( '866', 'a' ) ); >+ my ( $num_first_vol_online, $num_last_vol_online ) = >+ $fix_coverage->( $record->subfield( '863', 'a' ) ); >+ my ( $num_first_issue_online, $num_last_issue_online ) = ( '', '' ); # FIXME ? >+ my $title_url = $record->subfield( '856', 'u' ); >+ my $first_author = $biblio->author; >+ my $embargo_info = ''; # FIXME ? >+ my $coverage_depth = $title_url ? 'fulltext' : 'print'; >+ my $notes = $record->subfield( '852', 'z' ); >+ my $publisher_name = $record->subfield( '260', 'b' ); >+ my $publication_type = ''; # FIXME ? >+ my $date_monograph_published_print = ''; # FIXME ? >+ my $date_monograph_published_online = ''; # FIXME ? >+ my $monograph_volume = ''; # FIXME ? >+ my $monograph_edition = ''; # FIXME ? >+ my $first_editor = ''; # FIXME ? >+ my $parent_publication_title_id = ''; # FIXME ? >+ my $preceeding_publication_title_id = ''; # FIXME ? >+ my $access_type = ''; # FIXME ? >+ >+ return { >+ biblio_id => $biblio_id, >+ publication_title => $publication_title, >+ print_identifier => $print_identifier, >+ online_identifier => $online_identifier, >+ date_first_issue_online => $date_first_issue_online, >+ num_first_vol_online => $num_first_vol_online, >+ num_first_issue_online => $num_first_issue_online, >+ date_last_issue_online => $date_last_issue_online, >+ num_last_vol_online => $num_last_vol_online, >+ num_last_issue_online => $num_last_issue_online, >+ title_url => $title_url, >+ first_author => $first_author, >+ embargo_info => $embargo_info, >+ coverage_depth => $coverage_depth, >+ notes => $notes, >+ publisher_name => $publisher_name, >+ publication_type => $publication_type, >+ date_monograph_published_print => $date_monograph_published_print, >+ date_monograph_published_online => $date_monograph_published_online, >+ monograph_volume => $monograph_volume, >+ monograph_edition => $monograph_edition, >+ first_editor => $first_editor, >+ parent_publication_title_id => $parent_publication_title_id, >+ preceeding_publication_title_id => $preceeding_publication_title_id, >+ access_type => $access_type, >+ }; >+} >+ > =head3 process > > Process the import. >@@ -86,12 +217,6 @@ sub process { > return $self->finish( $data ); > } > >- my $fix_coverage = sub { >- my $coverage = shift || q{}; >- my @coverages = split '-', $coverage; >- return ($coverages[0], (@coverages > 1 ? $coverages[1] : q{})); >- }; >- > my %existing_biblio_ids = map { > my $resource = $_; > map { $_->biblio_id => $resource->resource_id } $resource->title >@@ -115,66 +240,12 @@ sub process { > return; > } > my $biblio = Koha::Biblios->find($biblio_id); >- my $record = $biblio->metadata->record; >- my $publication_title = $biblio->title; >- my $print_identifier = >- $record->subfield( '020', 'a' ) >- || $record->subfield( '020', 'z' ) >- || $record->subfield( '022', 'a' ) >- || $record->subfield( '022', 'y' ); >- my $online_identifier = $print_identifier; >- my ( $date_first_issue_online, $date_last_issue_online ) = >- $fix_coverage->( $record->subfield( '866', 'a' ) ); >- my ( $num_first_vol_online, $num_last_vol_online ) = >- $fix_coverage->( $record->subfield( '863', 'a' ) ); >- my ( $num_first_issue_online, $num_last_issue_online ) = >- ( '', '' ); # FIXME ? >- my $title_url = $record->subfield( '856', 'u' ); >- my $first_author = $biblio->author; >- my $embargo_info = ''; # FIXME ? >- my $coverage_depth = $title_url ? 'fulltext' : 'print'; >- my $notes = $record->subfield( '852', 'z' ); >- my $publisher_name = $record->subfield( '260', 'b' ); >- my $publication_type = ''; # FIXME ? >- my $date_monograph_published_print = ''; # FIXME ? >- my $date_monograph_published_online = ''; # FIXME ? >- my $monograph_volume = ''; # FIXME ? >- my $monograph_edition = ''; # FIXME ? >- my $first_editor = ''; # FIXME ? >- my $parent_publication_title_id = ''; # FIXME ? >- my $preceeding_publication_title_id = ''; # FIXME ? >- my $access_type = ''; # FIXME ? >- >- my $eholding_title = { >- biblio_id => $biblio_id, >- publication_title => $publication_title, >- print_identifier => $print_identifier, >- online_identifier => $online_identifier, >- date_first_issue_online => $date_first_issue_online, >- num_first_vol_online => $num_first_vol_online, >- num_first_issue_online => $num_first_issue_online, >- date_last_issue_online => $date_last_issue_online, >- num_last_vol_online => $num_last_vol_online, >- num_last_issue_online => $num_last_issue_online, >- title_url => $title_url, >- first_author => $first_author, >- embargo_info => $embargo_info, >- coverage_depth => $coverage_depth, >- notes => $notes, >- publisher_name => $publisher_name, >- publication_type => $publication_type, >- date_monograph_published_print => $date_monograph_published_print, >- date_monograph_published_online => $date_monograph_published_online, >- monograph_volume => $monograph_volume, >- monograph_edition => $monograph_edition, >- first_editor => $first_editor, >- parent_publication_title_id => $parent_publication_title_id, >- preceeding_publication_title_id => $preceeding_publication_title_id, >- access_type => $access_type, >- }; >- $eholding_title = Koha::ERM::EHoldings::Title->new($eholding_title)->store; >- Koha::ERM::EHoldings::Resource->new({ title_id => $eholding_title->title_id, package_id => $package_id })->store; >+ my $eholding_title = C4::Context->preference('marcflavour') eq 'UNIMARC' >+ ? _get_unimarc_mapping($biblio) >+ : _get_marc21_mapping($biblio); > >+ $eholding_title = Koha::ERM::EHoldings::Title->new($eholding_title)->store; >+ Koha::ERM::EHoldings::Resource->new({ title_id => $eholding_title->title_id, package_id => $package_id })->store; > $report->{total_success}++; > } catch { > push @messages, { >-- >2.30.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 32782
:
145961
|
148516
|
148517
|
148998
|
148999
|
149000