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.metarecord.copy_count",
125 __PACKAGE__->register_method(
126 method => "record_id_to_copy_count",
127 api_name => "open-ils.search.biblio.metarecord.copy_count.staff",
129 sub record_id_to_copy_count {
130 my( $self, $client, $org_id, $record_id, $format ) = @_;
132 $format = undef if (!$format or $format eq 'all');
134 my $method = "open-ils.storage.biblio.record_entry.copy_count.atomic";
136 if($self->api_name =~ /metarecord/) {
137 $method = "open-ils.storage.metabib.metarecord.copy_count.atomic";
141 if($self->api_name =~ /staff/ ) {
142 $method =~ s/atomic/staff\.atomic/og;
143 warn "Doing staff search $method\n";
147 my $session = OpenSRF::AppSession->create("open-ils.storage");
148 warn "copy_count retrieve $record_id\n";
149 return undef unless(defined $record_id);
151 my $request = $session->request(
152 $method, org_unit => $org_id => $key => $record_id, format => $format );
155 my $count = $request->gather(1);
156 $session->disconnect();
157 return [ sort { $a->{depth} <=> $b->{depth} } @$count ];
164 __PACKAGE__->register_method(
165 method => "biblio_search_tcn",
166 api_name => "open-ils.search.biblio.tcn",
168 note => "Retrieve a record by TCN",
171 sub biblio_search_tcn {
173 my( $self, $client, $tcn ) = @_;
175 $tcn =~ s/.*?(\w+)\s*$/$1/o;
176 warn "Searching TCN $tcn\n";
178 my $session = OpenSRF::AppSession->create( "open-ils.storage" );
179 my $request = $session->request(
180 "open-ils.storage.direct.biblio.record_entry.search_where.atomic",
181 { tcn_value => $tcn, deleted => 'f' } );
182 #"open-ils.storage.direct.biblio.record_entry.search.tcn_value.atomic", $tcn );
183 my $record_entry = $request->gather(1);
186 for my $record (@$record_entry) {
187 push @ids, $record->id;
190 $session->disconnect();
193 return { count => $size, ids => \@ids };
197 # --------------------------------------------------------------------------------
199 __PACKAGE__->register_method(
200 method => "biblio_barcode_to_copy",
201 api_name => "open-ils.search.asset.copy.find_by_barcode",);
202 sub biblio_barcode_to_copy {
203 my( $self, $client, $barcode ) = @_;
204 my( $copy, $evt ) = $U->fetch_copy_by_barcode($barcode);
209 __PACKAGE__->register_method(
210 method => "biblio_id_to_copy",
211 api_name => "open-ils.search.asset.copy.batch.retrieve",);
212 sub biblio_id_to_copy {
213 my( $self, $client, $ids ) = @_;
214 $logger->info("Fetching copies @$ids");
215 return $U->storagereq(
216 "open-ils.storage.direct.asset.copy.batch.retrieve.atomic", @$ids );
220 __PACKAGE__->register_method(
221 method => "copy_retrieve",
222 api_name => "open-ils.search.asset.copy.retrieve",);
224 my( $self, $client, $cid ) = @_;
225 my( $copy, $evt ) = $U->fetch_copy($cid);
231 __PACKAGE__->register_method(
232 method => "fleshed_copy_retrieve_batch",
233 api_name => "open-ils.search.asset.copy.fleshed.batch.retrieve");
235 sub fleshed_copy_retrieve_batch {
236 my( $self, $client, $ids ) = @_;
237 $logger->info("Fetching fleshed copies @$ids");
238 return $U->storagereq(
239 "open-ils.storage.fleshed.asset.copy.batch.retrieve.atomic", @$ids );
243 __PACKAGE__->register_method(
244 method => "fleshed_copy_retrieve",
245 api_name => "open-ils.search.asset.copy.fleshed.retrieve",);
247 sub fleshed_copy_retrieve {
248 my( $self, $client, $id ) = @_;
249 my( $c, $e) = $U->fetch_fleshed_copy($id);
256 __PACKAGE__->register_method(
257 method => "biblio_barcode_to_title",
258 api_name => "open-ils.search.biblio.find_by_barcode",
261 sub biblio_barcode_to_title {
262 my( $self, $client, $barcode ) = @_;
264 my $title = $apputils->simple_scalar_request(
266 "open-ils.storage.biblio.record_entry.retrieve_by_barcode", $barcode );
268 return { ids => [ $title->id ], count => 1 } if $title;
269 return { count => 0 };
273 __PACKAGE__->register_method(
274 method => "biblio_copy_to_mods",
275 api_name => "open-ils.search.biblio.copy.mods.retrieve",
278 # takes a copy object and returns it fleshed mods object
279 sub biblio_copy_to_mods {
280 my( $self, $client, $copy ) = @_;
282 my $volume = $U->storagereq(
283 "open-ils.storage.direct.asset.call_number.retrieve",
284 $copy->call_number() );
286 my $mods = _records_to_mods($volume->record());
287 $mods = shift @$mods;
288 $volume->copies([$copy]);
289 push @{$mods->call_numbers()}, $volume;
295 # ----------------------------------------------------------------------------
296 # These are the main OPAC search methods
297 # ----------------------------------------------------------------------------
299 __PACKAGE__->register_method(
300 method => 'the_quest_for_knowledge',
301 api_name => 'open-ils.search.biblio.multiclass',
303 Performs a multi class bilbli or metabib search
304 @param searchhash A search object layed out like so:
305 searches : { "$class" : "$value", ...}
306 org_unit : The org id to focus the search at
307 depth : The org depth
308 limit : The search limit
309 offset : The search offset
310 format : The MARC format
311 sort : What field to sort the results on [ author | title | pubdate ]
312 sort_dir : What direction do we sort? [ asc | desc ]
313 @return An object of the form
314 { "count" : $count, "ids" : [ [ $id, $relevancy, $total ], ...] }
318 __PACKAGE__->register_method(
319 method => 'the_quest_for_knowledge',
320 api_name => 'open-ils.search.biblio.multiclass.staff',
321 signature => q/@see open-ils.search.biblio.multiclass/);
322 __PACKAGE__->register_method(
323 method => 'the_quest_for_knowledge',
324 api_name => 'open-ils.search.metabib.multiclass',
325 signature => q/@see open-ils.search.biblio.multiclass/);
326 __PACKAGE__->register_method(
327 method => 'the_quest_for_knowledge',
328 api_name => 'open-ils.search.metabib.multiclass.staff',
329 signature => q/@see open-ils.search.biblio.multiclass/);
332 sub the_quest_for_knowledge {
333 my( $self, $conn, $searchhash ) = @_;
335 my $method = 'open-ils.storage.biblio.multiclass.search_fts';
339 if($self->api_name =~ /metabib/) {
341 $method =~ s/biblio/metabib/o;
344 $method .= ".staff" if($self->api_name =~ /staff/);
345 $method .= ".atomic";
347 for (keys %$searchhash) {
348 delete $$searchhash{$_} unless defined $$searchhash{$_}; }
350 my $result = $U->storagereq( $method, %$searchhash );
352 return {count => 0} unless ($result && $$result[0]);
354 for my $r (@$result) { push(@recs, $r) if ($r and $$r[0]); }
355 return { ids => \@recs,
356 count => ($ismeta) ? $result->[0]->[3] : $result->[0]->[2] };
366 __PACKAGE__->register_method(
367 method => "biblio_mrid_to_modsbatch_batch",
368 api_name => "open-ils.search.biblio.metarecord.mods_slim.batch.retrieve");
370 sub biblio_mrid_to_modsbatch_batch {
371 my( $self, $client, $mrids) = @_;
372 warn "Performing mrid_to_modsbatch_batch...";
374 my $method = $self->method_lookup("open-ils.search.biblio.metarecord.mods_slim.retrieve");
375 for my $id (@$mrids) {
376 next unless defined $id;
377 my ($m) = $method->run($id);
384 __PACKAGE__->register_method(
385 method => "biblio_mrid_to_modsbatch",
386 api_name => "open-ils.search.biblio.metarecord.mods_slim.retrieve",
387 notes => <<" NOTES");
388 Returns the mvr associated with a given metarecod. If none exists,
392 __PACKAGE__->register_method(
393 method => "biblio_mrid_to_modsbatch",
394 api_name => "open-ils.search.biblio.metarecord.mods_slim.retrieve.staff",
395 notes => <<" NOTES");
396 Returns the mvr associated with a given metarecod. If none exists,
400 sub biblio_mrid_to_modsbatch {
401 my( $self, $client, $mrid ) = @_;
403 warn "Grabbing mvr for $mrid\n";
405 my ($mr, $evt) = _grab_metarecord($mrid);
406 return $evt unless $mr;
408 if( my $m = $self->biblio_mrid_check_mvr($client, $mr)) {
412 return $self->biblio_mrid_make_modsbatch( $client, $mr );
415 # converts a metarecord to an mvr
418 my $perl = JSON->JSON2perl($mr->mods());
419 return Fieldmapper::metabib::virtual_record->new($perl);
422 # checks to see if a metarecord has mods, if so returns true;
424 __PACKAGE__->register_method(
425 method => "biblio_mrid_check_mvr",
426 api_name => "open-ils.search.biblio.metarecord.mods_slim.check",
427 notes => <<" NOTES");
428 Takes a metarecord ID or a metarecord object and returns true
429 if the metarecord already has an mvr associated with it.
432 sub biblio_mrid_check_mvr {
433 my( $self, $client, $mrid ) = @_;
437 if(ref($mrid)) { $mr = $mrid; }
438 else { ($mr, $evt) = _grab_metarecord($mrid); }
441 warn "Checking mvr for mr " . $mr->id . "\n";
443 return _mr_to_mvr($mr) if $mr->mods();
447 sub _grab_metarecord {
449 my $e = OpenILS::Utils::Editor->new;
450 my $mr = $e->retrieve_metabib_metarecord($mrid) or return ( undef, $e->event );
455 __PACKAGE__->register_method(
456 method => "biblio_mrid_make_modsbatch",
457 api_name => "open-ils.search.biblio.metarecord.mods_slim.create",
458 notes => <<" NOTES");
459 Takes either a metarecord ID or a metarecord object.
460 Forces the creations of an mvr for the given metarecord.
461 The created mvr is returned.
464 sub biblio_mrid_make_modsbatch {
465 my( $self, $client, $mrid ) = @_;
467 my $e = OpenILS::Utils::Editor->new;
474 $mr = $e->retrieve_metabib_metarecord($mrid)
478 my $masterid = $mr->master_record;
479 $logger->info("creating new mods batch for metarecord=$mrid, master record=$masterid");
481 my $ids = $e->request(
482 'open-ils.storage.ordered.metabib.metarecord.records.staff.atomic', $mrid);
483 return undef unless @$ids;
485 my $master = $e->retrieve_biblio_record_entry($masterid)
488 # start the mods batch
489 my $u = OpenILS::Utils::ModsParser->new();
490 $u->start_mods_batch( $master->marc );
492 # grab all of the sub-records and shove them into the batch
493 my @ids = grep { $_ ne $masterid } @$ids;
494 my $subrecs = $e->batch_retrieve_biblio_record_entry(\@ids);
497 $logger->debug("adding record ".$_->id." to mods batch for metarecord=$mrid");
498 $u->push_mods_batch( $_->marc ) if $_->marc;
502 # finish up and send to the client
503 my $mods = $u->finish_mods_batch();
504 $mods->doc_id($mrid);
505 $client->respond_complete($mods);
508 # now update the mods string in the db
509 my $string = JSON->perl2JSON($mods->decast);
512 $e = OpenILS::Utils::Editor->new(xact => 1);
513 $e->update_metabib_metarecord($mr)
514 or $logger->error("Error setting mods text on metarecord $mrid : " . Dumper($e->event));
523 # converts a mr id into a list of record ids
525 __PACKAGE__->register_method(
526 method => "biblio_mrid_to_record_ids",
527 api_name => "open-ils.search.biblio.metarecord_to_records",
530 __PACKAGE__->register_method(
531 method => "biblio_mrid_to_record_ids",
532 api_name => "open-ils.search.biblio.metarecord_to_records.staff",
535 sub biblio_mrid_to_record_ids {
536 my( $self, $client, $mrid, $args ) = @_;
538 my $format = $$args{format};
539 my $org = $$args{org};
540 my $depth = $$args{depth};
542 my $method = "open-ils.storage.ordered.metabib.metarecord.records.atomic";
543 $method =~ s/atomic/staff\.atomic/o if $self->api_name =~ /staff/o;
544 my $recs = $U->storagereq($method, $mrid, $format, $org, $depth);
546 return { count => scalar(@$recs), ids => $recs };
550 __PACKAGE__->register_method(
551 method => "biblio_record_to_marc_html",
552 api_name => "open-ils.search.biblio.record.html" );
554 my $parser = XML::LibXML->new();
555 my $xslt = XML::LibXSLT->new();
558 my $settings_client = OpenSRF::Utils::SettingsClient->new();
559 sub biblio_record_to_marc_html {
560 my( $self, $client, $recordid ) = @_;
563 my $dir = $settings_client->config_value( "dirs", "xsl" );
564 my $xsl = $settings_client->config_value(
565 "apps", "open-ils.search", "app_settings", "marc_html_xsl" );
567 $xsl = $parser->parse_file("$dir/$xsl");
568 $marc_sheet = $xslt->parse_stylesheet( $xsl );
572 my $record = $apputils->simple_scalar_request(
574 "open-ils.storage.direct.biblio.record_entry.retrieve",
577 my $xmldoc = $parser->parse_string($record->marc);
578 my $html = $marc_sheet->transform($xmldoc);
579 $html = $html->toString();
586 __PACKAGE__->register_method(
587 method => "retrieve_all_copy_locations",
588 api_name => "open-ils.search.config.copy_location.retrieve.all" );
590 my $shelving_locations;
591 sub retrieve_all_copy_locations {
592 my( $self, $client ) = @_;
593 if(!$shelving_locations) {
594 $shelving_locations = $apputils->simple_scalar_request(
596 "open-ils.storage.direct.asset.copy_location.retrieve.all.atomic");
598 return $shelving_locations;
604 __PACKAGE__->register_method(
605 method => "retrieve_all_copy_statuses",
606 api_name => "open-ils.search.config.copy_status.retrieve.all" );
609 sub retrieve_all_copy_statuses {
610 my( $self, $client ) = @_;
611 if(!$copy_statuses) {
612 $copy_statuses = $apputils->simple_scalar_request(
614 "open-ils.storage.direct.config.copy_status.retrieve.all.atomic" );
616 return $copy_statuses;
620 __PACKAGE__->register_method(
621 method => "copy_counts_per_org",
622 api_name => "open-ils.search.biblio.copy_counts.retrieve");
624 __PACKAGE__->register_method(
625 method => "copy_counts_per_org",
626 api_name => "open-ils.search.biblio.copy_counts.retrieve.staff");
628 sub copy_counts_per_org {
629 my( $self, $client, $record_id ) = @_;
631 warn "Retreiveing copy copy counts for record $record_id and method " . $self->api_name . "\n";
633 my $method = "open-ils.storage.biblio.record_entry.global_copy_count.atomic";
634 if($self->api_name =~ /staff/) { $method =~ s/atomic/staff\.atomic/; }
636 my $counts = $apputils->simple_scalar_request(
637 "open-ils.storage", $method, $record_id );
639 $counts = [ sort {$a->[0] <=> $b->[0]} @$counts ];
644 __PACKAGE__->register_method(
645 method => "copy_count_summary",
646 api_name => "open-ils.search.biblio.copy_counts.summary.retrieve",
647 notes => <<" NOTES");
648 returns an array of these:
649 [ org_id, callnumber_label, <status1_count>, <status2_cout>,...]
650 where statusx is a copy status name. the statuses are sorted
654 sub copy_count_summary {
655 my( $self, $client, $rid ) = @_;
656 return $U->storagereq(
657 'open-ils.storage.biblio.record_entry.status_copy_count.atomic', $rid );
663 __PACKAGE__->register_method(
664 method => "multiclass_search",
665 api_name => "open-ils.search.biblio.multiclass",
666 notes => <<" NOTES");
667 Performs a multiclass search
668 PARAMS( searchBlob, org_unit, format, limit )
669 where searchBlob is defined like this:
671 "title" : { "term" : "water" },
672 "author" : { "term" : "smith" },
677 __PACKAGE__->register_method(
678 method => "multiclass_search",
679 api_name => "open-ils.search.biblio.multiclass.staff",
680 notes => "see open-ils.search.biblio.multiclass" );
682 sub multiclass_search {
683 my( $self, $client, $searchBlob, $orgid, $format, $limit ) = @_;
685 $logger->debug("Performing multiclass search with org => $orgid, " .
686 "format => $format, limit => $limit, and search blob " . Dumper($searchBlob));
688 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
689 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
692 my $records = $apputils->simplereq(
693 'open-ils.storage', $meth,
694 org_unit => $orgid, searches => $searchBlob, format => $format, limit => $limit );
699 if( ref($records) and $records->[0] and
700 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
702 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
704 # records has the form: [ mrid, rank, singleRecord / 0, hitCount ];
705 return { ids => $recs, count => $count };
711 __PACKAGE__->register_method(
712 method => "multiclass_search",
713 api_name => "open-ils.search.biblio.multiclass",
715 Performs a multiclass search
716 @param args A names hash of arguments:
717 org_unit : The org to focus the search on
718 depth : The search depth
721 offset : Search offset
722 searches : A named hash of searches which has the following format:
724 "title" : { "term" : "water" },
725 "author" : { "term" : "smith" },
728 @return { ids : <array of ids>, count : hitcount }
732 __PACKAGE__->register_method(
733 method => "multiclass_search",
734 api_name => "open-ils.search.biblio.multiclass.staff",
735 notes => q/@see open-ils.search.biblio.multiclass/ );
737 sub multiclass_search {
738 my( $self, $client, $args ) = @_;
740 $logger->debug("Performing multiclass search with args:\n" . Dumper($args));
741 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
742 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
744 my $records = $apputils->simplereq( 'open-ils.storage', $meth, %$args );
749 if( ref($records) and $records->[0] and
750 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
752 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
754 return { ids => $recs, count => $count };
761 __PACKAGE__->register_method(
762 method => "marc_search",
763 api_name => "open-ils.search.biblio.marc",
764 notes => <<" NOTES");
766 open-ils.storage.biblio.full_rec.multi_search.atomic
767 { "searches": [{"term":"harry","restrict": [{"tag":245,"subfield":"a"}]}], "org_unit": 1,
768 "limit":5,"sort":"author","item_type":"g"}
772 my( $self, $conn, $args ) = @_;
773 my $records = $U->storagereq(
774 'open-ils.storage.biblio.full_rec.multi_search.atomic', %$args );
778 $count = $records->[0]->[2] if( ref($records) and
779 $records->[0] and defined($records->[0]->[2]));
781 return { ids => $records, 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 = OpenILS::Utils::Editor->new;
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 = OpenILS::Utils::Editor->new;
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);
835 # -------------------------------------------------------------------------------------
837 __PACKAGE__->register_method(
838 method => "cn_browse",
839 api_name => "open-ils.search.callnumber.browse.target",
840 notes => "Starts a callnumber browse"
843 __PACKAGE__->register_method(
844 method => "cn_browse",
845 api_name => "open-ils.search.callnumber.browse.page_up",
846 notes => "Returns the previous page of callnumbers",
849 __PACKAGE__->register_method(
850 method => "cn_browse",
851 api_name => "open-ils.search.callnumber.browse.page_down",
852 notes => "Returns the next page of callnumbers",
856 # RETURNS array of arrays like so: label, owning_lib, record, id
858 my( $self, $client, @params ) = @_;
861 $method = 'open-ils.storage.asset.call_number.browse.target.atomic'
862 if( $self->api_name =~ /target/ );
863 $method = 'open-ils.storage.asset.call_number.browse.page_up.atomic'
864 if( $self->api_name =~ /page_up/ );
865 $method = 'open-ils.storage.asset.call_number.browse.page_down.atomic'
866 if( $self->api_name =~ /page_down/ );
868 return $apputils->simplereq( 'open-ils.storage', $method, @params );
870 # -------------------------------------------------------------------------------------
872 __PACKAGE__->register_method(
873 method => "fetch_cn",
874 api_name => "open-ils.search.callnumber.retrieve",
875 notes => "retrieves a callnumber based on ID",
879 my( $self, $client, $id ) = @_;
880 my( $cn, $evt ) = $apputils->fetch_callnumber( $id );
885 __PACKAGE__->register_method (
886 method => "fetch_copy_by_cn",
887 api_name => 'open-ils.search.copies_by_call_number.retrieve',
889 Returns an array of copy id's by callnumber id
890 @param cnid The callnumber id
891 @return An array of copy ids
895 sub fetch_copy_by_cn {
896 my( $self, $conn, $cnid ) = @_;
897 return $U->storagereq(
898 'open-ils.storage.id_list.asset.copy.search_where.atomic',
899 { call_number => $cnid, deleted => 'f' } );
902 __PACKAGE__->register_method (
903 method => 'fetch_cn_by_info',
904 api_name => 'open-ils.search.call_number.retrieve_by_info',
906 @param label The callnumber label
907 @param record The record the cn is attached to
908 @param org The owning library of the cn
909 @return The callnumber object
914 sub fetch_cn_by_info {
915 my( $self, $conn, $label, $record, $org ) = @_;
916 return $U->storagereq(
917 'open-ils.storage.direct.asset.call_number.search_where',
918 { label => $label, record => $record, owning_lib => $org, deleted => 'f' });
925 __PACKAGE__->register_method (
926 method => 'bib_extras',
927 api_name => 'open-ils.search.biblio.lit_form_map.retrieve.all');
928 __PACKAGE__->register_method (
929 method => 'bib_extras',
930 api_name => 'open-ils.search.biblio.item_form_map.retrieve.all');
931 __PACKAGE__->register_method (
932 method => 'bib_extras',
933 api_name => 'open-ils.search.biblio.item_type_map.retrieve.all');
934 __PACKAGE__->register_method (
935 method => 'bib_extras',
936 api_name => 'open-ils.search.biblio.audience_map.retrieve.all');
941 return $U->storagereq(
942 'open-ils.storage.direct.config.lit_form_map.retrieve.all.atomic')
943 if( $self->api_name =~ /lit_form/ );
945 return $U->storagereq(
946 'open-ils.storage.direct.config.item_form_map.retrieve.all.atomic')
947 if( $self->api_name =~ /item_form_map/ );
949 return $U->storagereq(
950 'open-ils.storage.direct.config.item_type_map.retrieve.all.atomic')
951 if( $self->api_name =~ /item_type_map/ );
953 return $U->storagereq(
954 'open-ils.storage.direct.config.audience_map.retrieve.all.atomic')
955 if( $self->api_name =~ /audience/ );
962 __PACKAGE__->register_method(
963 method => 'fetch_slim_record',
964 api_name => 'open-ils.search.biblio.record_entry.slim.retrieve',
966 Returns a biblio.record_entry without the attached marcxml
970 sub fetch_slim_record {
971 my( $self, $conn, $ids ) = @_;
973 my $editor = OpenILS::Utils::Editor->new;
976 return $editor->event unless
977 my $r = $editor->retrieve_biblio_record_entry($_);