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;
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;
171 warn "Searching TCN $tcn\n";
173 my $session = OpenSRF::AppSession->create( "open-ils.storage" );
174 my $request = $session->request(
175 "open-ils.storage.direct.biblio.record_entry.search_where.atomic",
176 { tcn_value => $tcn, deleted => 'f' } );
177 #"open-ils.storage.direct.biblio.record_entry.search.tcn_value.atomic", $tcn );
178 my $record_entry = $request->gather(1);
181 for my $record (@$record_entry) {
182 push @ids, $record->id;
185 $session->disconnect();
188 return { count => $size, ids => \@ids };
192 # --------------------------------------------------------------------------------
194 __PACKAGE__->register_method(
195 method => "biblio_barcode_to_copy",
196 api_name => "open-ils.search.asset.copy.find_by_barcode",);
197 sub biblio_barcode_to_copy {
198 my( $self, $client, $barcode ) = @_;
199 my( $copy, $evt ) = $U->fetch_copy_by_barcode($barcode);
204 __PACKAGE__->register_method(
205 method => "biblio_id_to_copy",
206 api_name => "open-ils.search.asset.copy.batch.retrieve",);
207 sub biblio_id_to_copy {
208 my( $self, $client, $ids ) = @_;
209 $logger->info("Fetching copies @$ids");
210 return $U->storagereq(
211 "open-ils.storage.direct.asset.copy.batch.retrieve.atomic", @$ids );
215 __PACKAGE__->register_method(
216 method => "copy_retrieve",
217 api_name => "open-ils.search.asset.copy.retrieve",);
219 my( $self, $client, $cid ) = @_;
220 my( $copy, $evt ) = $U->fetch_copy($cid);
226 __PACKAGE__->register_method(
227 method => "fleshed_copy_retrieve_batch",
228 api_name => "open-ils.search.asset.copy.fleshed.batch.retrieve");
230 sub fleshed_copy_retrieve_batch {
231 my( $self, $client, $ids ) = @_;
232 $logger->info("Fetching fleshed copies @$ids");
233 return $U->storagereq(
234 "open-ils.storage.fleshed.asset.copy.batch.retrieve.atomic", @$ids );
238 __PACKAGE__->register_method(
239 method => "fleshed_copy_retrieve",
240 api_name => "open-ils.search.asset.copy.fleshed.retrieve",);
242 sub fleshed_copy_retrieve {
243 my( $self, $client, $id ) = @_;
244 my( $c, $e) = $U->fetch_fleshed_copy($id);
251 __PACKAGE__->register_method(
252 method => "biblio_barcode_to_title",
253 api_name => "open-ils.search.biblio.find_by_barcode",
256 sub biblio_barcode_to_title {
257 my( $self, $client, $barcode ) = @_;
259 my $title = $apputils->simple_scalar_request(
261 "open-ils.storage.biblio.record_entry.retrieve_by_barcode", $barcode );
263 return { ids => [ $title->id ], count => 1 } if $title;
264 return { count => 0 };
268 __PACKAGE__->register_method(
269 method => "biblio_copy_to_mods",
270 api_name => "open-ils.search.biblio.copy.mods.retrieve",
273 # takes a copy object and returns it fleshed mods object
274 sub biblio_copy_to_mods {
275 my( $self, $client, $copy ) = @_;
277 my $volume = $U->storagereq(
278 "open-ils.storage.direct.asset.call_number.retrieve",
279 $copy->call_number() );
281 my $mods = _records_to_mods($volume->record());
282 $mods = shift @$mods;
283 $volume->copies([$copy]);
284 push @{$mods->call_numbers()}, $volume;
290 # ----------------------------------------------------------------------------
291 # These are the main OPAC search methods
292 # ----------------------------------------------------------------------------
294 __PACKAGE__->register_method(
295 method => 'the_quest_for_knowledge',
296 api_name => 'open-ils.search.biblio.multiclass',
298 Performs a multi class bilbli or metabib search
299 @param searchhash A search object layed out like so:
300 searches : { "$class" : "$value", ...}
301 org_unit : The org id to focus the search at
302 depth : The org depth
303 limit : The search limit
304 offset : The search offset
305 format : The MARC format
306 sort : What field to sort the results on [ author | title | pubdate ]
307 sort_dir : What direction do we sort? [ asc | desc ]
308 @return An object of the form
309 { "count" : $count, "ids" : [ [ $id, $relevancy, $total ], ...] }
313 __PACKAGE__->register_method(
314 method => 'the_quest_for_knowledge',
315 api_name => 'open-ils.search.biblio.multiclass.staff',
316 signature => q/@see open-ils.search.biblio.multiclass/);
317 __PACKAGE__->register_method(
318 method => 'the_quest_for_knowledge',
319 api_name => 'open-ils.search.metabib.multiclass',
320 signature => q/@see open-ils.search.biblio.multiclass/);
321 __PACKAGE__->register_method(
322 method => 'the_quest_for_knowledge',
323 api_name => 'open-ils.search.metabib.multiclass.staff',
324 signature => q/@see open-ils.search.biblio.multiclass/);
327 sub the_quest_for_knowledge {
328 my( $self, $conn, $searchhash ) = @_;
330 my $method = 'open-ils.storage.biblio.multiclass.search_fts';
334 if($self->api_name =~ /metabib/) {
336 $method =~ s/biblio/metabib/o;
339 $method .= ".staff" if($self->api_name =~ /staff/);
340 $method .= ".atomic";
342 for (keys %$searchhash) {
343 delete $$searchhash{$_} unless defined $$searchhash{$_}; }
345 my $result = $U->storagereq( $method, %$searchhash );
347 return {count => 0} unless ($result && $$result[0]);
349 for my $r (@$result) { push(@recs, $r) if ($r and $$r[0]); }
350 return { ids => \@recs,
351 count => ($ismeta) ? $result->[0]->[3] : $result->[0]->[2] };
361 __PACKAGE__->register_method(
362 method => "biblio_mrid_to_modsbatch_batch",
363 api_name => "open-ils.search.biblio.metarecord.mods_slim.batch.retrieve");
365 sub biblio_mrid_to_modsbatch_batch {
366 my( $self, $client, $mrids) = @_;
367 warn "Performing mrid_to_modsbatch_batch...";
369 my $method = $self->method_lookup("open-ils.search.biblio.metarecord.mods_slim.retrieve");
370 for my $id (@$mrids) {
371 next unless defined $id;
372 my ($m) = $method->run($id);
379 __PACKAGE__->register_method(
380 method => "biblio_mrid_to_modsbatch",
381 api_name => "open-ils.search.biblio.metarecord.mods_slim.retrieve",
382 notes => <<" NOTES");
383 Returns the mvr associated with a given metarecod. If none exists,
387 __PACKAGE__->register_method(
388 method => "biblio_mrid_to_modsbatch",
389 api_name => "open-ils.search.biblio.metarecord.mods_slim.retrieve.staff",
390 notes => <<" NOTES");
391 Returns the mvr associated with a given metarecod. If none exists,
395 sub biblio_mrid_to_modsbatch {
396 my( $self, $client, $mrid ) = @_;
398 warn "Grabbing mvr for $mrid\n";
400 my ($mr, $evt) = _grab_metarecord($mrid);
401 return $evt unless $mr;
403 if( my $m = $self->biblio_mrid_check_mvr($client, $mr)) {
407 return $self->biblio_mrid_make_modsbatch( $client, $mr );
410 # converts a metarecord to an mvr
413 my $perl = JSON->JSON2perl($mr->mods());
414 return Fieldmapper::metabib::virtual_record->new($perl);
417 # checks to see if a metarecord has mods, if so returns true;
419 __PACKAGE__->register_method(
420 method => "biblio_mrid_check_mvr",
421 api_name => "open-ils.search.biblio.metarecord.mods_slim.check",
422 notes => <<" NOTES");
423 Takes a metarecord ID or a metarecord object and returns true
424 if the metarecord already has an mvr associated with it.
427 sub biblio_mrid_check_mvr {
428 my( $self, $client, $mrid ) = @_;
432 if(ref($mrid)) { $mr = $mrid; }
433 else { ($mr, $evt) = _grab_metarecord($mrid); }
436 warn "Checking mvr for mr " . $mr->id . "\n";
438 return _mr_to_mvr($mr) if $mr->mods();
442 sub _grab_metarecord {
444 my $e = OpenILS::Utils::Editor->new;
445 my $mr = $e->retrieve_metabib_metarecord($mrid) or return ( undef, $e->event );
450 __PACKAGE__->register_method(
451 method => "biblio_mrid_make_modsbatch",
452 api_name => "open-ils.search.biblio.metarecord.mods_slim.create",
453 notes => <<" NOTES");
454 Takes either a metarecord ID or a metarecord object.
455 Forces the creations of an mvr for the given metarecord.
456 The created mvr is returned.
459 sub biblio_mrid_make_modsbatch {
460 my( $self, $client, $mrid ) = @_;
462 my $e = OpenILS::Utils::Editor->new;
469 $mr = $e->retrieve_metabib_metarecord($mrid)
473 my $masterid = $mr->master_record;
474 $logger->info("creating new mods batch for metarecord=$mrid, master record=$masterid");
476 my $ids = $e->request(
477 'open-ils.storage.ordered.metabib.metarecord.records.staff.atomic', $mrid);
478 return undef unless @$ids;
480 my $master = $e->retrieve_biblio_record_entry($masterid)
483 # start the mods batch
484 my $u = OpenILS::Utils::ModsParser->new();
485 $u->start_mods_batch( $master->marc );
487 # grab all of the sub-records and shove them into the batch
488 my @ids = grep { $_ ne $masterid } @$ids;
489 my $subrecs = $e->batch_retrieve_biblio_record_entry(\@ids);
492 $logger->debug("adding record ".$_->id." to mods batch for metarecord=$mrid");
493 $u->push_mods_batch( $_->marc ) if $_->marc;
497 # finish up and send to the client
498 my $mods = $u->finish_mods_batch();
499 $mods->doc_id($mrid);
500 $client->respond_complete($mods);
503 # now update the mods string in the db
504 my $string = JSON->perl2JSON($mods->decast);
507 $e = OpenILS::Utils::Editor->new(xact => 1);
508 $e->update_metabib_metarecord($mr)
509 or $logger->error("Error setting mods text on metarecord $mrid : " . Dumper($e->event));
518 # converts a mr id into a list of record ids
520 __PACKAGE__->register_method(
521 method => "biblio_mrid_to_record_ids",
522 api_name => "open-ils.search.biblio.metarecord_to_records",
525 __PACKAGE__->register_method(
526 method => "biblio_mrid_to_record_ids",
527 api_name => "open-ils.search.biblio.metarecord_to_records.staff",
530 sub biblio_mrid_to_record_ids {
531 my( $self, $client, $mrid, $args ) = @_;
533 my $format = $$args{format};
534 my $org = $$args{org};
535 my $depth = $$args{depth};
537 my $method = "open-ils.storage.ordered.metabib.metarecord.records.atomic";
538 $method =~ s/atomic/staff\.atomic/o if $self->api_name =~ /staff/o;
539 my $recs = $U->storagereq($method, $mrid, $format, $org, $depth);
541 return { count => scalar(@$recs), ids => $recs };
545 __PACKAGE__->register_method(
546 method => "biblio_record_to_marc_html",
547 api_name => "open-ils.search.biblio.record.html" );
549 my $parser = XML::LibXML->new();
550 my $xslt = XML::LibXSLT->new();
553 my $settings_client = OpenSRF::Utils::SettingsClient->new();
554 sub biblio_record_to_marc_html {
555 my( $self, $client, $recordid ) = @_;
558 my $dir = $settings_client->config_value( "dirs", "xsl" );
559 my $xsl = $settings_client->config_value(
560 "apps", "open-ils.search", "app_settings", "marc_html_xsl" );
562 $xsl = $parser->parse_file("$dir/$xsl");
563 $marc_sheet = $xslt->parse_stylesheet( $xsl );
567 my $record = $apputils->simple_scalar_request(
569 "open-ils.storage.direct.biblio.record_entry.retrieve",
572 my $xmldoc = $parser->parse_string($record->marc);
573 my $html = $marc_sheet->transform($xmldoc);
574 $html = $html->toString();
581 __PACKAGE__->register_method(
582 method => "retrieve_all_copy_locations",
583 api_name => "open-ils.search.config.copy_location.retrieve.all" );
585 my $shelving_locations;
586 sub retrieve_all_copy_locations {
587 my( $self, $client ) = @_;
588 if(!$shelving_locations) {
589 $shelving_locations = $apputils->simple_scalar_request(
591 "open-ils.storage.direct.asset.copy_location.retrieve.all.atomic");
593 return $shelving_locations;
599 __PACKAGE__->register_method(
600 method => "retrieve_all_copy_statuses",
601 api_name => "open-ils.search.config.copy_status.retrieve.all" );
604 sub retrieve_all_copy_statuses {
605 my( $self, $client ) = @_;
606 if(!$copy_statuses) {
607 $copy_statuses = $apputils->simple_scalar_request(
609 "open-ils.storage.direct.config.copy_status.retrieve.all.atomic" );
611 return $copy_statuses;
615 __PACKAGE__->register_method(
616 method => "copy_counts_per_org",
617 api_name => "open-ils.search.biblio.copy_counts.retrieve");
619 __PACKAGE__->register_method(
620 method => "copy_counts_per_org",
621 api_name => "open-ils.search.biblio.copy_counts.retrieve.staff");
623 sub copy_counts_per_org {
624 my( $self, $client, $record_id ) = @_;
626 warn "Retreiveing copy copy counts for record $record_id and method " . $self->api_name . "\n";
628 my $method = "open-ils.storage.biblio.record_entry.global_copy_count.atomic";
629 if($self->api_name =~ /staff/) { $method =~ s/atomic/staff\.atomic/; }
631 my $counts = $apputils->simple_scalar_request(
632 "open-ils.storage", $method, $record_id );
634 $counts = [ sort {$a->[0] <=> $b->[0]} @$counts ];
639 __PACKAGE__->register_method(
640 method => "copy_count_summary",
641 api_name => "open-ils.search.biblio.copy_counts.summary.retrieve",
642 notes => <<" NOTES");
643 returns an array of these:
644 [ org_id, callnumber_label, <status1_count>, <status2_cout>,...]
645 where statusx is a copy status name. the statuses are sorted
649 sub copy_count_summary {
650 my( $self, $client, $rid ) = @_;
651 return $U->storagereq(
652 'open-ils.storage.biblio.record_entry.status_copy_count.atomic', $rid );
658 __PACKAGE__->register_method(
659 method => "multiclass_search",
660 api_name => "open-ils.search.biblio.multiclass",
661 notes => <<" NOTES");
662 Performs a multiclass search
663 PARAMS( searchBlob, org_unit, format, limit )
664 where searchBlob is defined like this:
666 "title" : { "term" : "water" },
667 "author" : { "term" : "smith" },
672 __PACKAGE__->register_method(
673 method => "multiclass_search",
674 api_name => "open-ils.search.biblio.multiclass.staff",
675 notes => "see open-ils.search.biblio.multiclass" );
677 sub multiclass_search {
678 my( $self, $client, $searchBlob, $orgid, $format, $limit ) = @_;
680 $logger->debug("Performing multiclass search with org => $orgid, " .
681 "format => $format, limit => $limit, and search blob " . Dumper($searchBlob));
683 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
684 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
687 my $records = $apputils->simplereq(
688 'open-ils.storage', $meth,
689 org_unit => $orgid, searches => $searchBlob, format => $format, limit => $limit );
694 if( ref($records) and $records->[0] and
695 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
697 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
699 # records has the form: [ mrid, rank, singleRecord / 0, hitCount ];
700 return { ids => $recs, count => $count };
706 __PACKAGE__->register_method(
707 method => "multiclass_search",
708 api_name => "open-ils.search.biblio.multiclass",
710 Performs a multiclass search
711 @param args A names hash of arguments:
712 org_unit : The org to focus the search on
713 depth : The search depth
716 offset : Search offset
717 searches : A named hash of searches which has the following format:
719 "title" : { "term" : "water" },
720 "author" : { "term" : "smith" },
723 @return { ids : <array of ids>, count : hitcount }
727 __PACKAGE__->register_method(
728 method => "multiclass_search",
729 api_name => "open-ils.search.biblio.multiclass.staff",
730 notes => q/@see open-ils.search.biblio.multiclass/ );
732 sub multiclass_search {
733 my( $self, $client, $args ) = @_;
735 $logger->debug("Performing multiclass search with args:\n" . Dumper($args));
736 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
737 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
739 my $records = $apputils->simplereq( 'open-ils.storage', $meth, %$args );
744 if( ref($records) and $records->[0] and
745 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
747 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
749 return { ids => $recs, count => $count };
756 __PACKAGE__->register_method(
757 method => "marc_search",
758 api_name => "open-ils.search.biblio.marc.staff");
760 __PACKAGE__->register_method(
761 method => "marc_search",
762 api_name => "open-ils.search.biblio.marc",
763 notes => <<" NOTES");
765 open-ils.storage.biblio.full_rec.multi_search.atomic
766 { "searches": [{"term":"harry","restrict": [{"tag":245,"subfield":"a"}]}], "org_unit": 1,
767 "limit":5,"sort":"author","item_type":"g"}
771 my( $self, $conn, $args ) = @_;
773 my $method = 'open-ils.storage.biblio.full_rec.multi_search';
774 $method .= ".staff" if $self->api_name =~ /staff/;
775 $method .= ".atomic";
777 my $records = $U->storagereq($method, %$args);
781 $count = $records->[0]->[2] if( ref($records) and
782 $records->[0] and defined($records->[0]->[2]));
784 return { ids => $records, count => $count };
789 __PACKAGE__->register_method(
790 method => "biblio_search_isbn",
791 api_name => "open-ils.search.biblio.isbn",
794 sub biblio_search_isbn {
795 my( $self, $client, $isbn ) = @_;
796 $logger->debug("Searching ISBN $isbn");
797 my $e = OpenILS::Utils::Editor->new;
798 my $recs = $e->request(
799 'open-ils.storage.id_list.biblio.record_entry.search.isbn.atomic', $isbn );
800 #$recs = [ map { [$_] } @$recs ]; # for consistancy
801 return { ids => $recs, count => scalar(@$recs) };
805 __PACKAGE__->register_method(
806 method => "biblio_search_issn",
807 api_name => "open-ils.search.biblio.issn",
810 sub biblio_search_issn {
811 my( $self, $client, $issn ) = @_;
812 $logger->debug("Searching ISSN $issn");
813 my $e = OpenILS::Utils::Editor->new;
814 my $recs = $e->request(
815 'open-ils.storage.id_list.biblio.record_entry.search.issn.atomic', $issn );
816 #$recs = [ map { [$_] } @$recs ]; # for consistancy
817 return { ids => $recs, count => scalar(@$recs) };
823 __PACKAGE__->register_method(
824 method => "fetch_mods_by_copy",
825 api_name => "open-ils.search.biblio.mods_from_copy",
828 sub fetch_mods_by_copy {
829 my( $self, $client, $copyid ) = @_;
830 my ($record, $evt) = $apputils->fetch_record_by_copy( $copyid );
832 return OpenILS::Event->new('ITEM_NOT_CATALOGED') unless $record->marc;
833 return $apputils->record_to_mvr($record);
838 # -------------------------------------------------------------------------------------
840 __PACKAGE__->register_method(
841 method => "cn_browse",
842 api_name => "open-ils.search.callnumber.browse.target",
843 notes => "Starts a callnumber browse"
846 __PACKAGE__->register_method(
847 method => "cn_browse",
848 api_name => "open-ils.search.callnumber.browse.page_up",
849 notes => "Returns the previous page of callnumbers",
852 __PACKAGE__->register_method(
853 method => "cn_browse",
854 api_name => "open-ils.search.callnumber.browse.page_down",
855 notes => "Returns the next page of callnumbers",
859 # RETURNS array of arrays like so: label, owning_lib, record, id
861 my( $self, $client, @params ) = @_;
864 $method = 'open-ils.storage.asset.call_number.browse.target.atomic'
865 if( $self->api_name =~ /target/ );
866 $method = 'open-ils.storage.asset.call_number.browse.page_up.atomic'
867 if( $self->api_name =~ /page_up/ );
868 $method = 'open-ils.storage.asset.call_number.browse.page_down.atomic'
869 if( $self->api_name =~ /page_down/ );
871 return $apputils->simplereq( 'open-ils.storage', $method, @params );
873 # -------------------------------------------------------------------------------------
875 __PACKAGE__->register_method(
876 method => "fetch_cn",
877 api_name => "open-ils.search.callnumber.retrieve",
878 notes => "retrieves a callnumber based on ID",
882 my( $self, $client, $id ) = @_;
883 my( $cn, $evt ) = $apputils->fetch_callnumber( $id );
888 __PACKAGE__->register_method (
889 method => "fetch_copy_by_cn",
890 api_name => 'open-ils.search.copies_by_call_number.retrieve',
892 Returns an array of copy id's by callnumber id
893 @param cnid The callnumber id
894 @return An array of copy ids
898 sub fetch_copy_by_cn {
899 my( $self, $conn, $cnid ) = @_;
900 return $U->storagereq(
901 'open-ils.storage.id_list.asset.copy.search_where.atomic',
902 { call_number => $cnid, deleted => 'f' } );
905 __PACKAGE__->register_method (
906 method => 'fetch_cn_by_info',
907 api_name => 'open-ils.search.call_number.retrieve_by_info',
909 @param label The callnumber label
910 @param record The record the cn is attached to
911 @param org The owning library of the cn
912 @return The callnumber object
917 sub fetch_cn_by_info {
918 my( $self, $conn, $label, $record, $org ) = @_;
919 return $U->storagereq(
920 'open-ils.storage.direct.asset.call_number.search_where',
921 { label => $label, record => $record, owning_lib => $org, deleted => 'f' });
928 __PACKAGE__->register_method (
929 method => 'bib_extras',
930 api_name => 'open-ils.search.biblio.lit_form_map.retrieve.all');
931 __PACKAGE__->register_method (
932 method => 'bib_extras',
933 api_name => 'open-ils.search.biblio.item_form_map.retrieve.all');
934 __PACKAGE__->register_method (
935 method => 'bib_extras',
936 api_name => 'open-ils.search.biblio.item_type_map.retrieve.all');
937 __PACKAGE__->register_method (
938 method => 'bib_extras',
939 api_name => 'open-ils.search.biblio.audience_map.retrieve.all');
944 return $U->storagereq(
945 'open-ils.storage.direct.config.lit_form_map.retrieve.all.atomic')
946 if( $self->api_name =~ /lit_form/ );
948 return $U->storagereq(
949 'open-ils.storage.direct.config.item_form_map.retrieve.all.atomic')
950 if( $self->api_name =~ /item_form_map/ );
952 return $U->storagereq(
953 'open-ils.storage.direct.config.item_type_map.retrieve.all.atomic')
954 if( $self->api_name =~ /item_type_map/ );
956 return $U->storagereq(
957 'open-ils.storage.direct.config.audience_map.retrieve.all.atomic')
958 if( $self->api_name =~ /audience/ );
965 __PACKAGE__->register_method(
966 method => 'fetch_slim_record',
967 api_name => 'open-ils.search.biblio.record_entry.slim.retrieve',
969 Returns a biblio.record_entry without the attached marcxml
973 sub fetch_slim_record {
974 my( $self, $conn, $ids ) = @_;
976 my $editor = OpenILS::Utils::Editor->new;
979 return $editor->event unless
980 my $r = $editor->retrieve_biblio_record_entry($_);