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 ) = @_;
648 return $U->storagereq(
649 'open-ils.storage.biblio.record_entry.status_copy_count.atomic', $rid );
655 __PACKAGE__->register_method(
656 method => "multiclass_search",
657 api_name => "open-ils.search.biblio.multiclass",
658 notes => <<" NOTES");
659 Performs a multiclass search
660 PARAMS( searchBlob, org_unit, format, limit )
661 where searchBlob is defined like this:
663 "title" : { "term" : "water" },
664 "author" : { "term" : "smith" },
669 __PACKAGE__->register_method(
670 method => "multiclass_search",
671 api_name => "open-ils.search.biblio.multiclass.staff",
672 notes => "see open-ils.search.biblio.multiclass" );
674 sub multiclass_search {
675 my( $self, $client, $searchBlob, $orgid, $format, $limit ) = @_;
677 $logger->debug("Performing multiclass search with org => $orgid, " .
678 "format => $format, limit => $limit, and search blob " . Dumper($searchBlob));
680 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
681 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
684 my $records = $apputils->simplereq(
685 'open-ils.storage', $meth,
686 org_unit => $orgid, searches => $searchBlob, format => $format, limit => $limit );
691 if( ref($records) and $records->[0] and
692 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
694 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
696 # records has the form: [ mrid, rank, singleRecord / 0, hitCount ];
697 return { ids => $recs, count => $count };
703 __PACKAGE__->register_method(
704 method => "multiclass_search",
705 api_name => "open-ils.search.biblio.multiclass",
707 Performs a multiclass search
708 @param args A names hash of arguments:
709 org_unit : The org to focus the search on
710 depth : The search depth
713 offset : Search offset
714 searches : A named hash of searches which has the following format:
716 "title" : { "term" : "water" },
717 "author" : { "term" : "smith" },
720 @return { ids : <array of ids>, count : hitcount }
724 __PACKAGE__->register_method(
725 method => "multiclass_search",
726 api_name => "open-ils.search.biblio.multiclass.staff",
727 notes => q/@see open-ils.search.biblio.multiclass/ );
729 sub multiclass_search {
730 my( $self, $client, $args ) = @_;
732 $logger->debug("Performing multiclass search with args:\n" . Dumper($args));
733 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
734 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
736 my $records = $apputils->simplereq( 'open-ils.storage', $meth, %$args );
741 if( ref($records) and $records->[0] and
742 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
744 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
746 return { ids => $recs, count => $count };
753 __PACKAGE__->register_method(
754 method => "marc_search",
755 api_name => "open-ils.search.biblio.marc.staff");
757 __PACKAGE__->register_method(
758 method => "marc_search",
759 api_name => "open-ils.search.biblio.marc",
760 notes => <<" NOTES");
762 open-ils.storage.biblio.full_rec.multi_search.atomic
763 { "searches": [{"term":"harry","restrict": [{"tag":245,"subfield":"a"}]}], "org_unit": 1,
764 "limit":5,"sort":"author","item_type":"g"}
768 my( $self, $conn, $args ) = @_;
770 my $method = 'open-ils.storage.biblio.full_rec.multi_search';
771 $method .= ".staff" if $self->api_name =~ /staff/;
772 $method .= ".atomic";
774 my $recs = new_editor()->request($method, %$args);
777 $count = $recs->[0]->[2] if $recs->[0] and $recs->[0]->[2];
778 my @recs = map { $_->[0] } @$recs;
780 return { ids => \@recs, count => $count };
784 __PACKAGE__->register_method(
785 method => "biblio_search_isbn",
786 api_name => "open-ils.search.biblio.isbn",
789 sub biblio_search_isbn {
790 my( $self, $client, $isbn ) = @_;
791 $logger->debug("Searching ISBN $isbn");
792 my $e = new_editor();
793 my $recs = $e->request(
794 'open-ils.storage.id_list.biblio.record_entry.search.isbn.atomic', $isbn );
795 return { ids => $recs, count => scalar(@$recs) };
799 __PACKAGE__->register_method(
800 method => "biblio_search_issn",
801 api_name => "open-ils.search.biblio.issn",
804 sub biblio_search_issn {
805 my( $self, $client, $issn ) = @_;
806 $logger->debug("Searching ISSN $issn");
807 my $e = new_editor();
808 my $recs = $e->request(
809 'open-ils.storage.id_list.biblio.record_entry.search.issn.atomic', $issn );
810 return { ids => $recs, count => scalar(@$recs) };
816 __PACKAGE__->register_method(
817 method => "fetch_mods_by_copy",
818 api_name => "open-ils.search.biblio.mods_from_copy",
821 sub fetch_mods_by_copy {
822 my( $self, $client, $copyid ) = @_;
823 my ($record, $evt) = $apputils->fetch_record_by_copy( $copyid );
825 return OpenILS::Event->new('ITEM_NOT_CATALOGED') unless $record->marc;
826 return $apputils->record_to_mvr($record);
831 # -------------------------------------------------------------------------------------
833 __PACKAGE__->register_method(
834 method => "cn_browse",
835 api_name => "open-ils.search.callnumber.browse.target",
836 notes => "Starts a callnumber browse"
839 __PACKAGE__->register_method(
840 method => "cn_browse",
841 api_name => "open-ils.search.callnumber.browse.page_up",
842 notes => "Returns the previous page of callnumbers",
845 __PACKAGE__->register_method(
846 method => "cn_browse",
847 api_name => "open-ils.search.callnumber.browse.page_down",
848 notes => "Returns the next page of callnumbers",
852 # RETURNS array of arrays like so: label, owning_lib, record, id
854 my( $self, $client, @params ) = @_;
857 $method = 'open-ils.storage.asset.call_number.browse.target.atomic'
858 if( $self->api_name =~ /target/ );
859 $method = 'open-ils.storage.asset.call_number.browse.page_up.atomic'
860 if( $self->api_name =~ /page_up/ );
861 $method = 'open-ils.storage.asset.call_number.browse.page_down.atomic'
862 if( $self->api_name =~ /page_down/ );
864 return $apputils->simplereq( 'open-ils.storage', $method, @params );
866 # -------------------------------------------------------------------------------------
868 __PACKAGE__->register_method(
869 method => "fetch_cn",
870 api_name => "open-ils.search.callnumber.retrieve",
871 notes => "retrieves a callnumber based on ID",
875 my( $self, $client, $id ) = @_;
876 my( $cn, $evt ) = $apputils->fetch_callnumber( $id );
881 __PACKAGE__->register_method (
882 method => "fetch_copy_by_cn",
883 api_name => 'open-ils.search.copies_by_call_number.retrieve',
885 Returns an array of copy id's by callnumber id
886 @param cnid The callnumber id
887 @return An array of copy ids
891 sub fetch_copy_by_cn {
892 my( $self, $conn, $cnid ) = @_;
893 return $U->storagereq(
894 'open-ils.storage.id_list.asset.copy.search_where.atomic',
895 { call_number => $cnid, deleted => 'f' } );
898 __PACKAGE__->register_method (
899 method => 'fetch_cn_by_info',
900 api_name => 'open-ils.search.call_number.retrieve_by_info',
902 @param label The callnumber label
903 @param record The record the cn is attached to
904 @param org The owning library of the cn
905 @return The callnumber object
910 sub fetch_cn_by_info {
911 my( $self, $conn, $label, $record, $org ) = @_;
912 return $U->storagereq(
913 'open-ils.storage.direct.asset.call_number.search_where',
914 { label => $label, record => $record, owning_lib => $org, deleted => 'f' });
921 __PACKAGE__->register_method (
922 method => 'bib_extras',
923 api_name => 'open-ils.search.biblio.lit_form_map.retrieve.all');
924 __PACKAGE__->register_method (
925 method => 'bib_extras',
926 api_name => 'open-ils.search.biblio.item_form_map.retrieve.all');
927 __PACKAGE__->register_method (
928 method => 'bib_extras',
929 api_name => 'open-ils.search.biblio.item_type_map.retrieve.all');
930 __PACKAGE__->register_method (
931 method => 'bib_extras',
932 api_name => 'open-ils.search.biblio.audience_map.retrieve.all');
937 return $U->storagereq(
938 'open-ils.storage.direct.config.lit_form_map.retrieve.all.atomic')
939 if( $self->api_name =~ /lit_form/ );
941 return $U->storagereq(
942 'open-ils.storage.direct.config.item_form_map.retrieve.all.atomic')
943 if( $self->api_name =~ /item_form_map/ );
945 return $U->storagereq(
946 'open-ils.storage.direct.config.item_type_map.retrieve.all.atomic')
947 if( $self->api_name =~ /item_type_map/ );
949 return $U->storagereq(
950 'open-ils.storage.direct.config.audience_map.retrieve.all.atomic')
951 if( $self->api_name =~ /audience/ );
958 __PACKAGE__->register_method(
959 method => 'fetch_slim_record',
960 api_name => 'open-ils.search.biblio.record_entry.slim.retrieve',
962 Returns a biblio.record_entry without the attached marcxml
966 sub fetch_slim_record {
967 my( $self, $conn, $ids ) = @_;
969 my $editor = OpenILS::Utils::Editor->new;
972 return $editor->event unless
973 my $r = $editor->retrieve_biblio_record_entry($_);