From 96b63737c3db6e30eeb9e8ef1cb3d0db8abaaaca Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Fri, 8 Apr 2011 02:36:53 -0400 Subject: [PATCH] open-ils.search.multi_home.bib_ids.by_barcode => Retrieve bib record ids associated with the copy identified by the given barcode. This includes peer bibs for Multi-Home items. --- .../lib/OpenILS/Application/Search/Biblio.pm | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 346038d0f5..d9af59ec9d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -578,6 +578,22 @@ __PACKAGE__->register_method( } ); +__PACKAGE__->register_method( + method => 'title_id_by_item_barcode', + api_name => 'open-ils.search.multi_home.bib_ids.by_barcode', + authoritative => 1, + signature => { + desc => 'Retrieve bib record ids associated with the copy identified by the given barcode. This includes peer bibs for Multi-Home items.', + params => [ + { desc => 'Item barcode', type => 'string' } + ], + return => { + desc => 'Array of bib record ids. First element is the native bib for the item.' + } + } +); + + sub title_id_by_item_barcode { my( $self, $conn, $barcode ) = @_; my $e = new_editor(); @@ -595,7 +611,19 @@ sub title_id_by_item_barcode { ); return $e->event unless @$copies; - return $$copies[0]->call_number->record->id; + + if( $self->api_name =~ /multi_home/ ) { + my $multi_home_list = $e->search_biblio_peer_bib_copy_map( + [ + { target_copy => $$copies[0]->id } + ] + ); + my @temp = map { $_->peer_record } @{ $multi_home_list }; + unshift @temp, $$copies[0]->call_number->record->id; + return \@temp; + } else { + return $$copies[0]->call_number->record->id; + } } -- 2.11.0