1 package OpenILS::Application::Search::Biblio;
2 use base qw/OpenSRF::Application/;
3 use strict; use warnings;
7 use OpenILS::Utils::Fieldmapper;
8 use OpenILS::Utils::ModsParser;
9 use OpenSRF::Utils::SettingsClient;
10 use OpenILS::Utils::Editor q/:funcs/;
12 use OpenSRF::Utils::Logger qw/:logger/;
17 use Time::HiRes qw(time);
18 use OpenSRF::EX qw(:try);
19 use Digest::MD5 qw(md5_hex);
25 $Data::Dumper::Indent = 0;
27 use OpenILS::Application::AppUtils;
28 my $apputils = "OpenILS::Application::AppUtils";
32 # useful for MARC based searches
33 #my $cat_search_hash = {
34 #isbn => [ { tag => '020', subfield => 'a' }, ],
35 ##issn => [ { tag => '022', subfield => 'a' }, ],
41 # ---------------------------------------------------------------------------
42 # takes a list of record id's and turns the docs into friendly
43 # mods structures. Creates one MODS structure for each doc id.
44 # ---------------------------------------------------------------------------
45 sub _records_to_mods {
51 my $session = OpenSRF::AppSession->create("open-ils.storage");
52 my $request = $session->request(
53 "open-ils.storage.direct.biblio.record_entry.batch.retrieve", @ids );
55 while( my $resp = $request->recv ) {
56 my $content = $resp->content;
57 my $u = OpenILS::Utils::ModsParser->new();
58 $u->start_mods_batch( $content->marc );
59 my $mods = $u->finish_mods_batch();
60 $mods->doc_id($content->id());
61 $mods->tcn($content->tcn_value);
65 $session->disconnect();
69 __PACKAGE__->register_method(
70 method => "record_id_to_mods",
71 api_name => "open-ils.search.biblio.record.mods.retrieve",
73 note => "Provide ID, we provide the mods"
76 # converts a record into a mods object with copy counts attached
77 sub record_id_to_mods {
79 my( $self, $client, $org_id, $id ) = @_;
81 my $mods_list = _records_to_mods( $id );
82 my $mods_obj = $mods_list->[0];
83 my $cmethod = $self->method_lookup(
84 "open-ils.search.biblio.record.copy_count");
85 my ($count) = $cmethod->run($org_id, $id);
86 $mods_obj->copy_count($count);
93 __PACKAGE__->register_method(
94 method => "record_id_to_mods_slim",
95 api_name => "open-ils.search.biblio.record.mods_slim.retrieve",
97 note => "Provide ID, we provide the mods"
100 # converts a record into a mods object with NO copy counts attached
101 sub record_id_to_mods_slim {
102 my( $self, $client, $id ) = @_;
103 return undef unless defined $id;
105 if(ref($id) and ref($id) == 'ARRAY') {
106 return _records_to_mods( @$id );
108 my $mods_list = _records_to_mods( $id );
109 my $mods_obj = $mods_list->[0];
114 # Returns the number of copies attached to a record based on org location
115 __PACKAGE__->register_method(
116 method => "record_id_to_copy_count",
117 api_name => "open-ils.search.biblio.record.copy_count",
120 __PACKAGE__->register_method(
121 method => "record_id_to_copy_count",
122 api_name => "open-ils.search.biblio.record.copy_count.staff",
125 __PACKAGE__->register_method(
126 method => "record_id_to_copy_count",
127 api_name => "open-ils.search.biblio.metarecord.copy_count",
130 __PACKAGE__->register_method(
131 method => "record_id_to_copy_count",
132 api_name => "open-ils.search.biblio.metarecord.copy_count.staff",
134 sub record_id_to_copy_count {
135 my( $self, $client, $org_id, $record_id, $format ) = @_;
137 return [] unless $record_id;
138 $format = undef if (!$format or $format eq 'all');
140 my $method = "open-ils.storage.biblio.record_entry.copy_count.atomic";
143 if($self->api_name =~ /metarecord/) {
144 $method = "open-ils.storage.metabib.metarecord.copy_count.atomic";
148 $method =~ s/atomic/staff\.atomic/og if($self->api_name =~ /staff/ );
150 my $count = $U->storagereq( $method,
151 org_unit => $org_id, $key => $record_id, format => $format );
153 return [ sort { $a->{depth} <=> $b->{depth} } @$count ];
159 __PACKAGE__->register_method(
160 method => "biblio_search_tcn",
161 api_name => "open-ils.search.biblio.tcn",
163 note => "Retrieve a record by TCN",
166 sub biblio_search_tcn {
168 my( $self, $client, $tcn ) = @_;
170 $tcn =~ s/.*?(\w+)\s*$/$1/o;
172 my $e = new_editor();
173 my $recs = $e->search_biblio_record_entry(
174 {deleted => 'f', tcn_value => $tcn}, {idlist =>1});
176 return { count => scalar(@$recs), ids => $recs };
180 # --------------------------------------------------------------------------------
182 __PACKAGE__->register_method(
183 method => "biblio_barcode_to_copy",
184 api_name => "open-ils.search.asset.copy.find_by_barcode",);
185 sub biblio_barcode_to_copy {
186 my( $self, $client, $barcode ) = @_;
187 my( $copy, $evt ) = $U->fetch_copy_by_barcode($barcode);
192 __PACKAGE__->register_method(
193 method => "biblio_id_to_copy",
194 api_name => "open-ils.search.asset.copy.batch.retrieve",);
195 sub biblio_id_to_copy {
196 my( $self, $client, $ids ) = @_;
197 $logger->info("Fetching copies @$ids");
198 return $U->storagereq(
199 "open-ils.storage.direct.asset.copy.batch.retrieve.atomic", @$ids );
203 __PACKAGE__->register_method(
204 method => "copy_retrieve",
205 api_name => "open-ils.search.asset.copy.retrieve",);
207 my( $self, $client, $cid ) = @_;
208 my( $copy, $evt ) = $U->fetch_copy($cid);
214 __PACKAGE__->register_method(
215 method => "fleshed_copy_retrieve_batch",
216 api_name => "open-ils.search.asset.copy.fleshed.batch.retrieve");
218 sub fleshed_copy_retrieve_batch {
219 my( $self, $client, $ids ) = @_;
220 $logger->info("Fetching fleshed copies @$ids");
221 return $U->storagereq(
222 "open-ils.storage.fleshed.asset.copy.batch.retrieve.atomic", @$ids );
226 __PACKAGE__->register_method(
227 method => "fleshed_copy_retrieve",
228 api_name => "open-ils.search.asset.copy.fleshed.retrieve",);
230 sub fleshed_copy_retrieve {
231 my( $self, $client, $id ) = @_;
232 my( $c, $e) = $U->fetch_fleshed_copy($id);
239 __PACKAGE__->register_method(
240 method => "biblio_barcode_to_title",
241 api_name => "open-ils.search.biblio.find_by_barcode",
244 sub biblio_barcode_to_title {
245 my( $self, $client, $barcode ) = @_;
247 my $title = $apputils->simple_scalar_request(
249 "open-ils.storage.biblio.record_entry.retrieve_by_barcode", $barcode );
251 return { ids => [ $title->id ], count => 1 } if $title;
252 return { count => 0 };
256 __PACKAGE__->register_method(
257 method => "biblio_copy_to_mods",
258 api_name => "open-ils.search.biblio.copy.mods.retrieve",
261 # takes a copy object and returns it fleshed mods object
262 sub biblio_copy_to_mods {
263 my( $self, $client, $copy ) = @_;
265 my $volume = $U->storagereq(
266 "open-ils.storage.direct.asset.call_number.retrieve",
267 $copy->call_number() );
269 my $mods = _records_to_mods($volume->record());
270 $mods = shift @$mods;
271 $volume->copies([$copy]);
272 push @{$mods->call_numbers()}, $volume;
278 # ----------------------------------------------------------------------------
279 # These are the main OPAC search methods
280 # ----------------------------------------------------------------------------
282 __PACKAGE__->register_method(
283 method => 'the_quest_for_knowledge',
284 api_name => 'open-ils.search.biblio.multiclass',
286 Performs a multi class bilbli or metabib search
287 @param searchhash A search object layed out like so:
288 searches : { "$class" : "$value", ...}
289 org_unit : The org id to focus the search at
290 depth : The org depth
291 limit : The search limit
292 offset : The search offset
293 format : The MARC format
294 sort : What field to sort the results on [ author | title | pubdate ]
295 sort_dir : What direction do we sort? [ asc | desc ]
296 @return An object of the form
297 { "count" : $count, "ids" : [ [ $id, $relevancy, $total ], ...] }
301 __PACKAGE__->register_method(
302 method => 'the_quest_for_knowledge',
303 api_name => 'open-ils.search.biblio.multiclass.staff',
304 signature => q/@see open-ils.search.biblio.multiclass/);
305 __PACKAGE__->register_method(
306 method => 'the_quest_for_knowledge',
307 api_name => 'open-ils.search.metabib.multiclass',
308 signature => q/@see open-ils.search.biblio.multiclass/);
309 __PACKAGE__->register_method(
310 method => 'the_quest_for_knowledge',
311 api_name => 'open-ils.search.metabib.multiclass.staff',
312 signature => q/@see open-ils.search.biblio.multiclass/);
315 sub the_quest_for_knowledge {
316 my( $self, $conn, $searchhash ) = @_;
318 my $method = 'open-ils.storage.biblio.multiclass.search_fts';
322 if($self->api_name =~ /metabib/) {
324 $method =~ s/biblio/metabib/o;
327 $method .= ".staff" if($self->api_name =~ /staff/);
328 $method .= ".atomic";
330 for (keys %$searchhash) {
331 delete $$searchhash{$_} unless defined $$searchhash{$_}; }
333 my $result = new_editor()->request( $method, %$searchhash );
335 return {count => 0} unless ($result && $$result[0]);
337 for my $r (@$result) { push(@recs, $r) if ($r and $$r[0]); }
338 return { ids => \@recs,
339 count => ($ismeta) ? $result->[0]->[3] : $result->[0]->[2] };
349 __PACKAGE__->register_method(
350 method => "biblio_mrid_to_modsbatch_batch",
351 api_name => "open-ils.search.biblio.metarecord.mods_slim.batch.retrieve");
353 sub biblio_mrid_to_modsbatch_batch {
354 my( $self, $client, $mrids) = @_;
355 warn "Performing mrid_to_modsbatch_batch...";
357 my $method = $self->method_lookup("open-ils.search.biblio.metarecord.mods_slim.retrieve");
358 for my $id (@$mrids) {
359 next unless defined $id;
360 my ($m) = $method->run($id);
367 __PACKAGE__->register_method(
368 method => "biblio_mrid_to_modsbatch",
369 api_name => "open-ils.search.biblio.metarecord.mods_slim.retrieve",
370 notes => <<" NOTES");
371 Returns the mvr associated with a given metarecod. If none exists,
375 __PACKAGE__->register_method(
376 method => "biblio_mrid_to_modsbatch",
377 api_name => "open-ils.search.biblio.metarecord.mods_slim.retrieve.staff",
378 notes => <<" NOTES");
379 Returns the mvr associated with a given metarecod. If none exists,
383 sub biblio_mrid_to_modsbatch {
384 my( $self, $client, $mrid ) = @_;
386 warn "Grabbing mvr for $mrid\n";
388 my ($mr, $evt) = _grab_metarecord($mrid);
389 return $evt unless $mr;
391 if( my $m = $self->biblio_mrid_check_mvr($client, $mr)) {
395 return $self->biblio_mrid_make_modsbatch( $client, $mr );
398 # converts a metarecord to an mvr
401 my $perl = JSON->JSON2perl($mr->mods());
402 return Fieldmapper::metabib::virtual_record->new($perl);
405 # checks to see if a metarecord has mods, if so returns true;
407 __PACKAGE__->register_method(
408 method => "biblio_mrid_check_mvr",
409 api_name => "open-ils.search.biblio.metarecord.mods_slim.check",
410 notes => <<" NOTES");
411 Takes a metarecord ID or a metarecord object and returns true
412 if the metarecord already has an mvr associated with it.
415 sub biblio_mrid_check_mvr {
416 my( $self, $client, $mrid ) = @_;
420 if(ref($mrid)) { $mr = $mrid; }
421 else { ($mr, $evt) = _grab_metarecord($mrid); }
424 warn "Checking mvr for mr " . $mr->id . "\n";
426 return _mr_to_mvr($mr) if $mr->mods();
430 sub _grab_metarecord {
432 my $e = OpenILS::Utils::Editor->new;
433 my $mr = $e->retrieve_metabib_metarecord($mrid) or return ( undef, $e->event );
438 __PACKAGE__->register_method(
439 method => "biblio_mrid_make_modsbatch",
440 api_name => "open-ils.search.biblio.metarecord.mods_slim.create",
441 notes => <<" NOTES");
442 Takes either a metarecord ID or a metarecord object.
443 Forces the creations of an mvr for the given metarecord.
444 The created mvr is returned.
447 sub biblio_mrid_make_modsbatch {
448 my( $self, $client, $mrid ) = @_;
450 my $e = OpenILS::Utils::Editor->new;
457 $mr = $e->retrieve_metabib_metarecord($mrid)
461 my $masterid = $mr->master_record;
462 $logger->info("creating new mods batch for metarecord=$mrid, master record=$masterid");
464 my $ids = $e->request(
465 'open-ils.storage.ordered.metabib.metarecord.records.staff.atomic', $mrid);
466 return undef unless @$ids;
468 my $master = $e->retrieve_biblio_record_entry($masterid)
471 # start the mods batch
472 my $u = OpenILS::Utils::ModsParser->new();
473 $u->start_mods_batch( $master->marc );
475 # grab all of the sub-records and shove them into the batch
476 my @ids = grep { $_ ne $masterid } @$ids;
477 my $subrecs = $e->batch_retrieve_biblio_record_entry(\@ids);
480 $logger->debug("adding record ".$_->id." to mods batch for metarecord=$mrid");
481 $u->push_mods_batch( $_->marc ) if $_->marc;
485 # finish up and send to the client
486 my $mods = $u->finish_mods_batch();
487 $mods->doc_id($mrid);
488 $client->respond_complete($mods);
491 # now update the mods string in the db
492 my $string = JSON->perl2JSON($mods->decast);
495 $e = OpenILS::Utils::Editor->new(xact => 1);
496 $e->update_metabib_metarecord($mr)
497 or $logger->error("Error setting mods text on metarecord $mrid : " . Dumper($e->event));
506 # converts a mr id into a list of record ids
508 __PACKAGE__->register_method(
509 method => "biblio_mrid_to_record_ids",
510 api_name => "open-ils.search.biblio.metarecord_to_records",
513 __PACKAGE__->register_method(
514 method => "biblio_mrid_to_record_ids",
515 api_name => "open-ils.search.biblio.metarecord_to_records.staff",
518 sub biblio_mrid_to_record_ids {
519 my( $self, $client, $mrid, $args ) = @_;
521 my $format = $$args{format};
522 my $org = $$args{org};
523 my $depth = $$args{depth};
525 my $method = "open-ils.storage.ordered.metabib.metarecord.records.atomic";
526 $method =~ s/atomic/staff\.atomic/o if $self->api_name =~ /staff/o;
527 my $recs = $U->storagereq($method, $mrid, $format, $org, $depth);
529 return { count => scalar(@$recs), ids => $recs };
533 __PACKAGE__->register_method(
534 method => "biblio_record_to_marc_html",
535 api_name => "open-ils.search.biblio.record.html" );
537 my $parser = XML::LibXML->new();
538 my $xslt = XML::LibXSLT->new();
541 my $settings_client = OpenSRF::Utils::SettingsClient->new();
542 sub biblio_record_to_marc_html {
543 my( $self, $client, $recordid ) = @_;
546 my $dir = $settings_client->config_value( "dirs", "xsl" );
547 my $xsl = $settings_client->config_value(
548 "apps", "open-ils.search", "app_settings", "marc_html_xsl" );
550 $xsl = $parser->parse_file("$dir/$xsl");
551 $marc_sheet = $xslt->parse_stylesheet( $xsl );
555 my $record = $apputils->simple_scalar_request(
557 "open-ils.storage.direct.biblio.record_entry.retrieve",
560 my $xmldoc = $parser->parse_string($record->marc);
561 my $html = $marc_sheet->transform($xmldoc);
562 $html = $html->toString();
569 __PACKAGE__->register_method(
570 method => "retrieve_all_copy_locations",
571 api_name => "open-ils.search.config.copy_location.retrieve.all" );
573 my $shelving_locations;
574 sub retrieve_all_copy_locations {
575 my( $self, $client ) = @_;
576 if(!$shelving_locations) {
577 $shelving_locations = $apputils->simple_scalar_request(
579 "open-ils.storage.direct.asset.copy_location.retrieve.all.atomic");
581 return $shelving_locations;
587 __PACKAGE__->register_method(
588 method => "retrieve_all_copy_statuses",
589 api_name => "open-ils.search.config.copy_status.retrieve.all" );
592 sub retrieve_all_copy_statuses {
593 my( $self, $client ) = @_;
594 if(!$copy_statuses) {
595 $copy_statuses = $apputils->simple_scalar_request(
597 "open-ils.storage.direct.config.copy_status.retrieve.all.atomic" );
599 return $copy_statuses;
603 __PACKAGE__->register_method(
604 method => "copy_counts_per_org",
605 api_name => "open-ils.search.biblio.copy_counts.retrieve");
607 __PACKAGE__->register_method(
608 method => "copy_counts_per_org",
609 api_name => "open-ils.search.biblio.copy_counts.retrieve.staff");
611 sub copy_counts_per_org {
612 my( $self, $client, $record_id ) = @_;
614 warn "Retreiveing copy copy counts for record $record_id and method " . $self->api_name . "\n";
616 my $method = "open-ils.storage.biblio.record_entry.global_copy_count.atomic";
617 if($self->api_name =~ /staff/) { $method =~ s/atomic/staff\.atomic/; }
619 my $counts = $apputils->simple_scalar_request(
620 "open-ils.storage", $method, $record_id );
622 $counts = [ sort {$a->[0] <=> $b->[0]} @$counts ];
627 __PACKAGE__->register_method(
628 method => "copy_count_summary",
629 api_name => "open-ils.search.biblio.copy_counts.summary.retrieve",
630 notes => <<" NOTES");
631 returns an array of these:
632 [ org_id, callnumber_label, <status1_count>, <status2_cout>,...]
633 where statusx is a copy status name. the statuses are sorted
637 sub copy_count_summary {
638 my( $self, $client, $rid ) = @_;
639 return $U->storagereq(
640 'open-ils.storage.biblio.record_entry.status_copy_count.atomic', $rid );
646 __PACKAGE__->register_method(
647 method => "multiclass_search",
648 api_name => "open-ils.search.biblio.multiclass",
649 notes => <<" NOTES");
650 Performs a multiclass search
651 PARAMS( searchBlob, org_unit, format, limit )
652 where searchBlob is defined like this:
654 "title" : { "term" : "water" },
655 "author" : { "term" : "smith" },
660 __PACKAGE__->register_method(
661 method => "multiclass_search",
662 api_name => "open-ils.search.biblio.multiclass.staff",
663 notes => "see open-ils.search.biblio.multiclass" );
665 sub multiclass_search {
666 my( $self, $client, $searchBlob, $orgid, $format, $limit ) = @_;
668 $logger->debug("Performing multiclass search with org => $orgid, " .
669 "format => $format, limit => $limit, and search blob " . Dumper($searchBlob));
671 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
672 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
675 my $records = $apputils->simplereq(
676 'open-ils.storage', $meth,
677 org_unit => $orgid, searches => $searchBlob, format => $format, limit => $limit );
682 if( ref($records) and $records->[0] and
683 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
685 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
687 # records has the form: [ mrid, rank, singleRecord / 0, hitCount ];
688 return { ids => $recs, count => $count };
694 __PACKAGE__->register_method(
695 method => "multiclass_search",
696 api_name => "open-ils.search.biblio.multiclass",
698 Performs a multiclass search
699 @param args A names hash of arguments:
700 org_unit : The org to focus the search on
701 depth : The search depth
704 offset : Search offset
705 searches : A named hash of searches which has the following format:
707 "title" : { "term" : "water" },
708 "author" : { "term" : "smith" },
711 @return { ids : <array of ids>, count : hitcount }
715 __PACKAGE__->register_method(
716 method => "multiclass_search",
717 api_name => "open-ils.search.biblio.multiclass.staff",
718 notes => q/@see open-ils.search.biblio.multiclass/ );
720 sub multiclass_search {
721 my( $self, $client, $args ) = @_;
723 $logger->debug("Performing multiclass search with args:\n" . Dumper($args));
724 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
725 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
727 my $records = $apputils->simplereq( 'open-ils.storage', $meth, %$args );
732 if( ref($records) and $records->[0] and
733 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
735 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
737 return { ids => $recs, count => $count };
744 __PACKAGE__->register_method(
745 method => "marc_search",
746 api_name => "open-ils.search.biblio.marc.staff");
748 __PACKAGE__->register_method(
749 method => "marc_search",
750 api_name => "open-ils.search.biblio.marc",
751 notes => <<" NOTES");
753 open-ils.storage.biblio.full_rec.multi_search.atomic
754 { "searches": [{"term":"harry","restrict": [{"tag":245,"subfield":"a"}]}], "org_unit": 1,
755 "limit":5,"sort":"author","item_type":"g"}
759 my( $self, $conn, $args ) = @_;
761 my $method = 'open-ils.storage.biblio.full_rec.multi_search';
762 $method .= ".staff" if $self->api_name =~ /staff/;
763 $method .= ".atomic";
765 my $records = $U->storagereq($method, %$args);
769 $count = $records->[0]->[2] if( ref($records) and
770 $records->[0] and defined($records->[0]->[2]));
772 return { ids => $records, count => $count };
776 __PACKAGE__->register_method(
777 method => "biblio_search_isbn",
778 api_name => "open-ils.search.biblio.isbn",
781 sub biblio_search_isbn {
782 my( $self, $client, $isbn ) = @_;
783 $logger->debug("Searching ISBN $isbn");
784 my $e = new_editor();
785 my $recs = $e->request(
786 'open-ils.storage.id_list.biblio.record_entry.search.isbn.atomic', $isbn );
787 return { ids => $recs, count => scalar(@$recs) };
791 __PACKAGE__->register_method(
792 method => "biblio_search_issn",
793 api_name => "open-ils.search.biblio.issn",
796 sub biblio_search_issn {
797 my( $self, $client, $issn ) = @_;
798 $logger->debug("Searching ISSN $issn");
799 my $e = new_editor();
800 my $recs = $e->request(
801 'open-ils.storage.id_list.biblio.record_entry.search.issn.atomic', $issn );
802 return { ids => $recs, count => scalar(@$recs) };
808 __PACKAGE__->register_method(
809 method => "fetch_mods_by_copy",
810 api_name => "open-ils.search.biblio.mods_from_copy",
813 sub fetch_mods_by_copy {
814 my( $self, $client, $copyid ) = @_;
815 my ($record, $evt) = $apputils->fetch_record_by_copy( $copyid );
817 return OpenILS::Event->new('ITEM_NOT_CATALOGED') unless $record->marc;
818 return $apputils->record_to_mvr($record);
823 # -------------------------------------------------------------------------------------
825 __PACKAGE__->register_method(
826 method => "cn_browse",
827 api_name => "open-ils.search.callnumber.browse.target",
828 notes => "Starts a callnumber browse"
831 __PACKAGE__->register_method(
832 method => "cn_browse",
833 api_name => "open-ils.search.callnumber.browse.page_up",
834 notes => "Returns the previous page of callnumbers",
837 __PACKAGE__->register_method(
838 method => "cn_browse",
839 api_name => "open-ils.search.callnumber.browse.page_down",
840 notes => "Returns the next page of callnumbers",
844 # RETURNS array of arrays like so: label, owning_lib, record, id
846 my( $self, $client, @params ) = @_;
849 $method = 'open-ils.storage.asset.call_number.browse.target.atomic'
850 if( $self->api_name =~ /target/ );
851 $method = 'open-ils.storage.asset.call_number.browse.page_up.atomic'
852 if( $self->api_name =~ /page_up/ );
853 $method = 'open-ils.storage.asset.call_number.browse.page_down.atomic'
854 if( $self->api_name =~ /page_down/ );
856 return $apputils->simplereq( 'open-ils.storage', $method, @params );
858 # -------------------------------------------------------------------------------------
860 __PACKAGE__->register_method(
861 method => "fetch_cn",
862 api_name => "open-ils.search.callnumber.retrieve",
863 notes => "retrieves a callnumber based on ID",
867 my( $self, $client, $id ) = @_;
868 my( $cn, $evt ) = $apputils->fetch_callnumber( $id );
873 __PACKAGE__->register_method (
874 method => "fetch_copy_by_cn",
875 api_name => 'open-ils.search.copies_by_call_number.retrieve',
877 Returns an array of copy id's by callnumber id
878 @param cnid The callnumber id
879 @return An array of copy ids
883 sub fetch_copy_by_cn {
884 my( $self, $conn, $cnid ) = @_;
885 return $U->storagereq(
886 'open-ils.storage.id_list.asset.copy.search_where.atomic',
887 { call_number => $cnid, deleted => 'f' } );
890 __PACKAGE__->register_method (
891 method => 'fetch_cn_by_info',
892 api_name => 'open-ils.search.call_number.retrieve_by_info',
894 @param label The callnumber label
895 @param record The record the cn is attached to
896 @param org The owning library of the cn
897 @return The callnumber object
902 sub fetch_cn_by_info {
903 my( $self, $conn, $label, $record, $org ) = @_;
904 return $U->storagereq(
905 'open-ils.storage.direct.asset.call_number.search_where',
906 { label => $label, record => $record, owning_lib => $org, deleted => 'f' });
913 __PACKAGE__->register_method (
914 method => 'bib_extras',
915 api_name => 'open-ils.search.biblio.lit_form_map.retrieve.all');
916 __PACKAGE__->register_method (
917 method => 'bib_extras',
918 api_name => 'open-ils.search.biblio.item_form_map.retrieve.all');
919 __PACKAGE__->register_method (
920 method => 'bib_extras',
921 api_name => 'open-ils.search.biblio.item_type_map.retrieve.all');
922 __PACKAGE__->register_method (
923 method => 'bib_extras',
924 api_name => 'open-ils.search.biblio.audience_map.retrieve.all');
929 return $U->storagereq(
930 'open-ils.storage.direct.config.lit_form_map.retrieve.all.atomic')
931 if( $self->api_name =~ /lit_form/ );
933 return $U->storagereq(
934 'open-ils.storage.direct.config.item_form_map.retrieve.all.atomic')
935 if( $self->api_name =~ /item_form_map/ );
937 return $U->storagereq(
938 'open-ils.storage.direct.config.item_type_map.retrieve.all.atomic')
939 if( $self->api_name =~ /item_type_map/ );
941 return $U->storagereq(
942 'open-ils.storage.direct.config.audience_map.retrieve.all.atomic')
943 if( $self->api_name =~ /audience/ );
950 __PACKAGE__->register_method(
951 method => 'fetch_slim_record',
952 api_name => 'open-ils.search.biblio.record_entry.slim.retrieve',
954 Returns a biblio.record_entry without the attached marcxml
958 sub fetch_slim_record {
959 my( $self, $conn, $ids ) = @_;
961 my $editor = OpenILS::Utils::Editor->new;
964 return $editor->event unless
965 my $r = $editor->retrieve_biblio_record_entry($_);