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);
213 __PACKAGE__->register_method(
214 method => "volume_retrieve",
215 api_name => "open-ils.search.asset.call_number.retrieve");
216 sub volume_retrieve {
217 my( $self, $client, $vid ) = @_;
218 my $e = new_editor();
219 my $vol = $e->retrieve_asset_call_number($vid) or return $e->event;
223 __PACKAGE__->register_method(
224 method => "fleshed_copy_retrieve_batch",
225 api_name => "open-ils.search.asset.copy.fleshed.batch.retrieve");
227 sub fleshed_copy_retrieve_batch {
228 my( $self, $client, $ids ) = @_;
229 $logger->info("Fetching fleshed copies @$ids");
230 return $U->storagereq(
231 "open-ils.storage.fleshed.asset.copy.batch.retrieve.atomic", @$ids );
235 __PACKAGE__->register_method(
236 method => "fleshed_copy_retrieve",
237 api_name => "open-ils.search.asset.copy.fleshed.retrieve",);
239 sub fleshed_copy_retrieve {
240 my( $self, $client, $id ) = @_;
241 my( $c, $e) = $U->fetch_fleshed_copy($id);
248 __PACKAGE__->register_method(
249 method => "biblio_barcode_to_title",
250 api_name => "open-ils.search.biblio.find_by_barcode",
253 sub biblio_barcode_to_title {
254 my( $self, $client, $barcode ) = @_;
256 my $title = $apputils->simple_scalar_request(
258 "open-ils.storage.biblio.record_entry.retrieve_by_barcode", $barcode );
260 return { ids => [ $title->id ], count => 1 } if $title;
261 return { count => 0 };
265 __PACKAGE__->register_method(
266 method => "biblio_copy_to_mods",
267 api_name => "open-ils.search.biblio.copy.mods.retrieve",
270 # takes a copy object and returns it fleshed mods object
271 sub biblio_copy_to_mods {
272 my( $self, $client, $copy ) = @_;
274 my $volume = $U->storagereq(
275 "open-ils.storage.direct.asset.call_number.retrieve",
276 $copy->call_number() );
278 my $mods = _records_to_mods($volume->record());
279 $mods = shift @$mods;
280 $volume->copies([$copy]);
281 push @{$mods->call_numbers()}, $volume;
287 # ----------------------------------------------------------------------------
288 # These are the main OPAC search methods
289 # ----------------------------------------------------------------------------
291 __PACKAGE__->register_method(
292 method => 'the_quest_for_knowledge',
293 api_name => 'open-ils.search.biblio.multiclass',
295 Performs a multi class bilbli or metabib search
296 @param searchhash A search object layed out like so:
297 searches : { "$class" : "$value", ...}
298 org_unit : The org id to focus the search at
299 depth : The org depth
300 limit : The search limit
301 offset : The search offset
302 format : The MARC format
303 sort : What field to sort the results on [ author | title | pubdate ]
304 sort_dir : What direction do we sort? [ asc | desc ]
305 @return An object of the form
306 { "count" : $count, "ids" : [ [ $id, $relevancy, $total ], ...] }
310 __PACKAGE__->register_method(
311 method => 'the_quest_for_knowledge',
312 api_name => 'open-ils.search.biblio.multiclass.staff',
313 signature => q/@see open-ils.search.biblio.multiclass/);
314 __PACKAGE__->register_method(
315 method => 'the_quest_for_knowledge',
316 api_name => 'open-ils.search.metabib.multiclass',
317 signature => q/@see open-ils.search.biblio.multiclass/);
318 __PACKAGE__->register_method(
319 method => 'the_quest_for_knowledge',
320 api_name => 'open-ils.search.metabib.multiclass.staff',
321 signature => q/@see open-ils.search.biblio.multiclass/);
324 sub the_quest_for_knowledge {
325 my( $self, $conn, $searchhash ) = @_;
327 my $method = 'open-ils.storage.biblio.multiclass.search_fts';
331 if($self->api_name =~ /metabib/) {
333 $method =~ s/biblio/metabib/o;
336 $method .= ".staff" if($self->api_name =~ /staff/);
337 $method .= ".atomic";
339 for (keys %$searchhash) {
340 delete $$searchhash{$_} unless defined $$searchhash{$_}; }
342 my $result = new_editor()->request( $method, %$searchhash );
344 return {count => 0} unless ($result && $$result[0]);
346 for my $r (@$result) { push(@recs, $r) if ($r and $$r[0]); }
347 return { ids => \@recs,
348 count => ($ismeta) ? $result->[0]->[3] : $result->[0]->[2] };
358 __PACKAGE__->register_method(
359 method => "biblio_mrid_to_modsbatch_batch",
360 api_name => "open-ils.search.biblio.metarecord.mods_slim.batch.retrieve");
362 sub biblio_mrid_to_modsbatch_batch {
363 my( $self, $client, $mrids) = @_;
364 warn "Performing mrid_to_modsbatch_batch...";
366 my $method = $self->method_lookup("open-ils.search.biblio.metarecord.mods_slim.retrieve");
367 for my $id (@$mrids) {
368 next unless defined $id;
369 my ($m) = $method->run($id);
376 __PACKAGE__->register_method(
377 method => "biblio_mrid_to_modsbatch",
378 api_name => "open-ils.search.biblio.metarecord.mods_slim.retrieve",
379 notes => <<" NOTES");
380 Returns the mvr associated with a given metarecod. If none exists,
384 __PACKAGE__->register_method(
385 method => "biblio_mrid_to_modsbatch",
386 api_name => "open-ils.search.biblio.metarecord.mods_slim.retrieve.staff",
387 notes => <<" NOTES");
388 Returns the mvr associated with a given metarecod. If none exists,
392 sub biblio_mrid_to_modsbatch {
393 my( $self, $client, $mrid ) = @_;
395 warn "Grabbing mvr for $mrid\n";
397 my ($mr, $evt) = _grab_metarecord($mrid);
398 return $evt unless $mr;
400 if( my $m = $self->biblio_mrid_check_mvr($client, $mr)) {
404 return $self->biblio_mrid_make_modsbatch( $client, $mr );
407 # converts a metarecord to an mvr
410 my $perl = JSON->JSON2perl($mr->mods());
411 return Fieldmapper::metabib::virtual_record->new($perl);
414 # checks to see if a metarecord has mods, if so returns true;
416 __PACKAGE__->register_method(
417 method => "biblio_mrid_check_mvr",
418 api_name => "open-ils.search.biblio.metarecord.mods_slim.check",
419 notes => <<" NOTES");
420 Takes a metarecord ID or a metarecord object and returns true
421 if the metarecord already has an mvr associated with it.
424 sub biblio_mrid_check_mvr {
425 my( $self, $client, $mrid ) = @_;
429 if(ref($mrid)) { $mr = $mrid; }
430 else { ($mr, $evt) = _grab_metarecord($mrid); }
433 warn "Checking mvr for mr " . $mr->id . "\n";
435 return _mr_to_mvr($mr) if $mr->mods();
439 sub _grab_metarecord {
441 my $e = OpenILS::Utils::Editor->new;
442 my $mr = $e->retrieve_metabib_metarecord($mrid) or return ( undef, $e->event );
447 __PACKAGE__->register_method(
448 method => "biblio_mrid_make_modsbatch",
449 api_name => "open-ils.search.biblio.metarecord.mods_slim.create",
450 notes => <<" NOTES");
451 Takes either a metarecord ID or a metarecord object.
452 Forces the creations of an mvr for the given metarecord.
453 The created mvr is returned.
456 sub biblio_mrid_make_modsbatch {
457 my( $self, $client, $mrid ) = @_;
459 my $e = OpenILS::Utils::Editor->new;
466 $mr = $e->retrieve_metabib_metarecord($mrid)
470 my $masterid = $mr->master_record;
471 $logger->info("creating new mods batch for metarecord=$mrid, master record=$masterid");
473 my $ids = $e->request(
474 'open-ils.storage.ordered.metabib.metarecord.records.staff.atomic', $mrid);
475 return undef unless @$ids;
477 my $master = $e->retrieve_biblio_record_entry($masterid)
480 # start the mods batch
481 my $u = OpenILS::Utils::ModsParser->new();
482 $u->start_mods_batch( $master->marc );
484 # grab all of the sub-records and shove them into the batch
485 my @ids = grep { $_ ne $masterid } @$ids;
486 my $subrecs = $e->batch_retrieve_biblio_record_entry(\@ids);
489 $logger->debug("adding record ".$_->id." to mods batch for metarecord=$mrid");
490 $u->push_mods_batch( $_->marc ) if $_->marc;
494 # finish up and send to the client
495 my $mods = $u->finish_mods_batch();
496 $mods->doc_id($mrid);
497 $client->respond_complete($mods);
500 # now update the mods string in the db
501 my $string = JSON->perl2JSON($mods->decast);
504 $e = OpenILS::Utils::Editor->new(xact => 1);
505 $e->update_metabib_metarecord($mr)
506 or $logger->error("Error setting mods text on metarecord $mrid : " . Dumper($e->event));
515 # converts a mr id into a list of record ids
517 __PACKAGE__->register_method(
518 method => "biblio_mrid_to_record_ids",
519 api_name => "open-ils.search.biblio.metarecord_to_records",
522 __PACKAGE__->register_method(
523 method => "biblio_mrid_to_record_ids",
524 api_name => "open-ils.search.biblio.metarecord_to_records.staff",
527 sub biblio_mrid_to_record_ids {
528 my( $self, $client, $mrid, $args ) = @_;
530 my $format = $$args{format};
531 my $org = $$args{org};
532 my $depth = $$args{depth};
534 my $method = "open-ils.storage.ordered.metabib.metarecord.records.atomic";
535 $method =~ s/atomic/staff\.atomic/o if $self->api_name =~ /staff/o;
536 my $recs = $U->storagereq($method, $mrid, $format, $org, $depth);
538 return { count => scalar(@$recs), ids => $recs };
542 __PACKAGE__->register_method(
543 method => "biblio_record_to_marc_html",
544 api_name => "open-ils.search.biblio.record.html" );
546 my $parser = XML::LibXML->new();
547 my $xslt = XML::LibXSLT->new();
550 my $settings_client = OpenSRF::Utils::SettingsClient->new();
551 sub biblio_record_to_marc_html {
552 my( $self, $client, $recordid ) = @_;
555 my $dir = $settings_client->config_value( "dirs", "xsl" );
556 my $xsl = $settings_client->config_value(
557 "apps", "open-ils.search", "app_settings", "marc_html_xsl" );
559 $xsl = $parser->parse_file("$dir/$xsl");
560 $marc_sheet = $xslt->parse_stylesheet( $xsl );
564 my $record = $apputils->simple_scalar_request(
566 "open-ils.storage.direct.biblio.record_entry.retrieve",
569 my $xmldoc = $parser->parse_string($record->marc);
570 my $html = $marc_sheet->transform($xmldoc);
571 $html = $html->toString();
578 __PACKAGE__->register_method(
579 method => "retrieve_all_copy_locations",
580 api_name => "open-ils.search.config.copy_location.retrieve.all" );
582 my $shelving_locations;
583 sub retrieve_all_copy_locations {
584 my( $self, $client ) = @_;
585 if(!$shelving_locations) {
586 $shelving_locations = $apputils->simple_scalar_request(
588 "open-ils.storage.direct.asset.copy_location.retrieve.all.atomic");
590 return $shelving_locations;
596 __PACKAGE__->register_method(
597 method => "retrieve_all_copy_statuses",
598 api_name => "open-ils.search.config.copy_status.retrieve.all" );
601 sub retrieve_all_copy_statuses {
602 my( $self, $client ) = @_;
603 if(!$copy_statuses) {
604 $copy_statuses = $apputils->simple_scalar_request(
606 "open-ils.storage.direct.config.copy_status.retrieve.all.atomic" );
608 return $copy_statuses;
612 __PACKAGE__->register_method(
613 method => "copy_counts_per_org",
614 api_name => "open-ils.search.biblio.copy_counts.retrieve");
616 __PACKAGE__->register_method(
617 method => "copy_counts_per_org",
618 api_name => "open-ils.search.biblio.copy_counts.retrieve.staff");
620 sub copy_counts_per_org {
621 my( $self, $client, $record_id ) = @_;
623 warn "Retreiveing copy copy counts for record $record_id and method " . $self->api_name . "\n";
625 my $method = "open-ils.storage.biblio.record_entry.global_copy_count.atomic";
626 if($self->api_name =~ /staff/) { $method =~ s/atomic/staff\.atomic/; }
628 my $counts = $apputils->simple_scalar_request(
629 "open-ils.storage", $method, $record_id );
631 $counts = [ sort {$a->[0] <=> $b->[0]} @$counts ];
636 __PACKAGE__->register_method(
637 method => "copy_count_summary",
638 api_name => "open-ils.search.biblio.copy_counts.summary.retrieve",
639 notes => <<" NOTES");
640 returns an array of these:
641 [ org_id, callnumber_label, <status1_count>, <status2_cout>,...]
642 where statusx is a copy status name. the statuses are sorted
646 sub copy_count_summary {
647 my( $self, $client, $rid, $org, $depth ) = @_;
650 return $U->storagereq(
651 'open-ils.storage.biblio.record_entry.status_copy_count.atomic', $rid, $org, $depth );
657 __PACKAGE__->register_method(
658 method => "multiclass_search",
659 api_name => "open-ils.search.biblio.multiclass",
660 notes => <<" NOTES");
661 Performs a multiclass search
662 PARAMS( searchBlob, org_unit, format, limit )
663 where searchBlob is defined like this:
665 "title" : { "term" : "water" },
666 "author" : { "term" : "smith" },
671 __PACKAGE__->register_method(
672 method => "multiclass_search",
673 api_name => "open-ils.search.biblio.multiclass.staff",
674 notes => "see open-ils.search.biblio.multiclass" );
676 sub multiclass_search {
677 my( $self, $client, $searchBlob, $orgid, $format, $limit ) = @_;
679 $logger->debug("Performing multiclass search with org => $orgid, " .
680 "format => $format, limit => $limit, and search blob " . Dumper($searchBlob));
682 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
683 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
686 my $records = $apputils->simplereq(
687 'open-ils.storage', $meth,
688 org_unit => $orgid, searches => $searchBlob, format => $format, limit => $limit );
693 if( ref($records) and $records->[0] and
694 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
696 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
698 # records has the form: [ mrid, rank, singleRecord / 0, hitCount ];
699 return { ids => $recs, count => $count };
705 __PACKAGE__->register_method(
706 method => "multiclass_search",
707 api_name => "open-ils.search.biblio.multiclass",
709 Performs a multiclass search
710 @param args A names hash of arguments:
711 org_unit : The org to focus the search on
712 depth : The search depth
715 offset : Search offset
716 searches : A named hash of searches which has the following format:
718 "title" : { "term" : "water" },
719 "author" : { "term" : "smith" },
722 @return { ids : <array of ids>, count : hitcount }
726 __PACKAGE__->register_method(
727 method => "multiclass_search",
728 api_name => "open-ils.search.biblio.multiclass.staff",
729 notes => q/@see open-ils.search.biblio.multiclass/ );
731 sub multiclass_search {
732 my( $self, $client, $args ) = @_;
734 $logger->debug("Performing multiclass search with args:\n" . Dumper($args));
735 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
736 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
738 my $records = $apputils->simplereq( 'open-ils.storage', $meth, %$args );
743 if( ref($records) and $records->[0] and
744 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
746 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
748 return { ids => $recs, count => $count };
755 __PACKAGE__->register_method(
756 method => "marc_search",
757 api_name => "open-ils.search.biblio.marc.staff");
759 __PACKAGE__->register_method(
760 method => "marc_search",
761 api_name => "open-ils.search.biblio.marc",
762 notes => <<" NOTES");
764 open-ils.storage.biblio.full_rec.multi_search.atomic
765 { "searches": [{"term":"harry","restrict": [{"tag":245,"subfield":"a"}]}], "org_unit": 1,
766 "limit":5,"sort":"author","item_type":"g"}
770 my( $self, $conn, $args ) = @_;
772 my $method = 'open-ils.storage.biblio.full_rec.multi_search';
773 $method .= ".staff" if $self->api_name =~ /staff/;
774 $method .= ".atomic";
776 my $recs = new_editor()->request($method, %$args);
779 $count = $recs->[0]->[2] if $recs->[0] and $recs->[0]->[2];
780 my @recs = map { $_->[0] } @$recs;
782 return { ids => \@recs, count => $count };
786 __PACKAGE__->register_method(
787 method => "biblio_search_isbn",
788 api_name => "open-ils.search.biblio.isbn",
791 sub biblio_search_isbn {
792 my( $self, $client, $isbn ) = @_;
793 $logger->debug("Searching ISBN $isbn");
794 my $e = new_editor();
795 my $recs = $e->request(
796 'open-ils.storage.id_list.biblio.record_entry.search.isbn.atomic', $isbn );
797 return { ids => $recs, count => scalar(@$recs) };
801 __PACKAGE__->register_method(
802 method => "biblio_search_issn",
803 api_name => "open-ils.search.biblio.issn",
806 sub biblio_search_issn {
807 my( $self, $client, $issn ) = @_;
808 $logger->debug("Searching ISSN $issn");
809 my $e = new_editor();
810 my $recs = $e->request(
811 'open-ils.storage.id_list.biblio.record_entry.search.issn.atomic', $issn );
812 return { ids => $recs, count => scalar(@$recs) };
818 __PACKAGE__->register_method(
819 method => "fetch_mods_by_copy",
820 api_name => "open-ils.search.biblio.mods_from_copy",
823 sub fetch_mods_by_copy {
824 my( $self, $client, $copyid ) = @_;
825 my ($record, $evt) = $apputils->fetch_record_by_copy( $copyid );
827 return OpenILS::Event->new('ITEM_NOT_CATALOGED') unless $record->marc;
828 return $apputils->record_to_mvr($record);
833 # -------------------------------------------------------------------------------------
835 __PACKAGE__->register_method(
836 method => "cn_browse",
837 api_name => "open-ils.search.callnumber.browse.target",
838 notes => "Starts a callnumber browse"
841 __PACKAGE__->register_method(
842 method => "cn_browse",
843 api_name => "open-ils.search.callnumber.browse.page_up",
844 notes => "Returns the previous page of callnumbers",
847 __PACKAGE__->register_method(
848 method => "cn_browse",
849 api_name => "open-ils.search.callnumber.browse.page_down",
850 notes => "Returns the next page of callnumbers",
854 # RETURNS array of arrays like so: label, owning_lib, record, id
856 my( $self, $client, @params ) = @_;
859 $method = 'open-ils.storage.asset.call_number.browse.target.atomic'
860 if( $self->api_name =~ /target/ );
861 $method = 'open-ils.storage.asset.call_number.browse.page_up.atomic'
862 if( $self->api_name =~ /page_up/ );
863 $method = 'open-ils.storage.asset.call_number.browse.page_down.atomic'
864 if( $self->api_name =~ /page_down/ );
866 return $apputils->simplereq( 'open-ils.storage', $method, @params );
868 # -------------------------------------------------------------------------------------
870 __PACKAGE__->register_method(
871 method => "fetch_cn",
872 api_name => "open-ils.search.callnumber.retrieve",
873 notes => "retrieves a callnumber based on ID",
877 my( $self, $client, $id ) = @_;
878 my( $cn, $evt ) = $apputils->fetch_callnumber( $id );
883 __PACKAGE__->register_method (
884 method => "fetch_copy_by_cn",
885 api_name => 'open-ils.search.copies_by_call_number.retrieve',
887 Returns an array of copy id's by callnumber id
888 @param cnid The callnumber id
889 @return An array of copy ids
893 sub fetch_copy_by_cn {
894 my( $self, $conn, $cnid ) = @_;
895 return $U->storagereq(
896 'open-ils.storage.id_list.asset.copy.search_where.atomic',
897 { call_number => $cnid, deleted => 'f' } );
900 __PACKAGE__->register_method (
901 method => 'fetch_cn_by_info',
902 api_name => 'open-ils.search.call_number.retrieve_by_info',
904 @param label The callnumber label
905 @param record The record the cn is attached to
906 @param org The owning library of the cn
907 @return The callnumber object
912 sub fetch_cn_by_info {
913 my( $self, $conn, $label, $record, $org ) = @_;
914 return $U->storagereq(
915 'open-ils.storage.direct.asset.call_number.search_where',
916 { label => $label, record => $record, owning_lib => $org, deleted => 'f' });
923 __PACKAGE__->register_method (
924 method => 'bib_extras',
925 api_name => 'open-ils.search.biblio.lit_form_map.retrieve.all');
926 __PACKAGE__->register_method (
927 method => 'bib_extras',
928 api_name => 'open-ils.search.biblio.item_form_map.retrieve.all');
929 __PACKAGE__->register_method (
930 method => 'bib_extras',
931 api_name => 'open-ils.search.biblio.item_type_map.retrieve.all');
932 __PACKAGE__->register_method (
933 method => 'bib_extras',
934 api_name => 'open-ils.search.biblio.audience_map.retrieve.all');
939 return $U->storagereq(
940 'open-ils.storage.direct.config.lit_form_map.retrieve.all.atomic')
941 if( $self->api_name =~ /lit_form/ );
943 return $U->storagereq(
944 'open-ils.storage.direct.config.item_form_map.retrieve.all.atomic')
945 if( $self->api_name =~ /item_form_map/ );
947 return $U->storagereq(
948 'open-ils.storage.direct.config.item_type_map.retrieve.all.atomic')
949 if( $self->api_name =~ /item_type_map/ );
951 return $U->storagereq(
952 'open-ils.storage.direct.config.audience_map.retrieve.all.atomic')
953 if( $self->api_name =~ /audience/ );
960 __PACKAGE__->register_method(
961 method => 'fetch_slim_record',
962 api_name => 'open-ils.search.biblio.record_entry.slim.retrieve',
964 Returns a biblio.record_entry without the attached marcxml
968 sub fetch_slim_record {
969 my( $self, $conn, $ids ) = @_;
971 my $editor = OpenILS::Utils::Editor->new;
974 return $editor->event unless
975 my $r = $editor->retrieve_biblio_record_entry($_);