open-ils.search.multi_home.bib_ids.by_barcode => Retrieve bib record ids associated...
authorJason Etheridge <jason@esilibrary.com>
Fri, 8 Apr 2011 06:36:53 +0000 (02:36 -0400)
committerJason Etheridge <jason@esilibrary.com>
Fri, 8 Apr 2011 06:36:53 +0000 (02:36 -0400)
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm

index 346038d..d9af59e 100644 (file)
@@ -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;
+    }
 }