1 package OpenILS::Application::Search::Biblio;
2 use base qw/OpenSRF::Application/;
3 use strict; use warnings;
8 use OpenILS::Utils::Fieldmapper;
9 use OpenILS::Utils::ModsParser;
10 use OpenSRF::Utils::SettingsClient;
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 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.tcn_value.atomic", $tcn );
181 my $record_entry = $request->gather(1);
184 for my $record (@$record_entry) {
185 push @ids, $record->id;
188 $session->disconnect();
191 return { count => $size, ids => \@ids };
195 # --------------------------------------------------------------------------------
197 __PACKAGE__->register_method(
198 method => "biblio_barcode_to_copy",
199 api_name => "open-ils.search.asset.copy.find_by_barcode",);
200 sub biblio_barcode_to_copy {
201 my( $self, $client, $barcode ) = @_;
202 my( $copy, $evt ) = $U->fetch_copy_by_barcode($barcode);
207 __PACKAGE__->register_method(
208 method => "biblio_id_to_copy",
209 api_name => "open-ils.search.asset.copy.batch.retrieve",);
210 sub biblio_id_to_copy {
211 my( $self, $client, $ids ) = @_;
212 $logger->info("Fetching copies @$ids");
213 return $U->storagereq(
214 "open-ils.storage.direct.asset.copy.batch.retrieve.atomic", @$ids );
218 __PACKAGE__->register_method(
219 method => "copy_retrieve",
220 api_name => "open-ils.search.asset.copy.retrieve",);
222 my( $self, $client, $cid ) = @_;
223 my( $copy, $evt ) = $U->fetch_copy($cid);
229 __PACKAGE__->register_method(
230 method => "fleshed_copy_retrieve_batch",
231 api_name => "open-ils.search.asset.copy.fleshed.batch.retrieve",);
233 sub fleshed_copy_retrieve_batch {
234 my( $self, $client, $ids ) = @_;
235 $logger->info("Fetching fleshed copies @$ids");
236 return $U->storagereq(
237 "open-ils.storage.fleshed.asset.copy.batch.retrieve.atomic", @$ids );
241 __PACKAGE__->register_method(
242 method => "fleshed_copy_retrieve",
243 api_name => "open-ils.search.asset.copy.fleshed.retrieve",);
245 sub fleshed_copy_retrieve {
246 my( $self, $client, $id ) = @_;
247 my( $c, $e) = $U->fetch_fleshed_copy($id);
254 __PACKAGE__->register_method(
255 method => "biblio_barcode_to_title",
256 api_name => "open-ils.search.biblio.find_by_barcode",
259 sub biblio_barcode_to_title {
260 my( $self, $client, $barcode ) = @_;
262 my $title = $apputils->simple_scalar_request(
264 "open-ils.storage.biblio.record_entry.retrieve_by_barcode", $barcode );
266 return { ids => [ $title->id ], count => 1 } if $title;
267 return { count => 0 };
271 __PACKAGE__->register_method(
272 method => "biblio_copy_to_mods",
273 api_name => "open-ils.search.biblio.copy.mods.retrieve",
276 # takes a copy object and returns it fleshed mods object
277 sub biblio_copy_to_mods {
278 my( $self, $client, $copy ) = @_;
280 my $volume = $U->storagereq(
281 "open-ils.storage.direct.asset.call_number.retrieve",
282 $copy->call_number() );
284 my $mods = _records_to_mods($volume->record());
285 $mods = shift @$mods;
286 $volume->copies([$copy]);
287 push @{$mods->call_numbers()}, $volume;
293 # ----------------------------------------------------------------------------
294 # These are the main OPAC search methods
295 # ----------------------------------------------------------------------------
297 __PACKAGE__->register_method(
298 method => "record_search_class",
299 api_name => "open-ils.search.biblio.record.class.search",
301 Performs a class search for biblio records (not metarecords)
302 @param class The search class to use
303 @param args A hash of named parameters including:
304 term : The search string,
305 org_unit : The org id to focus the search at
306 depth : The org depth
307 limit : The search limit
308 offset : The search offset
309 format : The MARC format
310 sort : What field to sort the results on [ author | title | pubdate ]
311 sort_dir : What direction do we sort? [ asc | desc ]
312 The only required argument is the term.
316 __PACKAGE__->register_method(
317 method => "record_search_class",
318 api_name => "open-ils.search.biblio.record.class.search.staff",
319 signature => q/@see open-ils.search.biblio.record.class.search/);
320 __PACKAGE__->register_method(
321 method => "record_search_class",
322 api_name => "open-ils.search.biblio.metabib.class.search",
323 signature => q/@see open-ils.search.biblio.record.class.search/);
324 __PACKAGE__->register_method(
325 method => "record_search_class",
326 api_name => "open-ils.search.biblio.metabib.class.search.staff",
327 signature => q/@see open-ils.search.biblio.record.class.search/);
329 sub record_search_class {
330 my( $self, $client, $class, $args ) = @_;
332 my $type = ($self->api_name =~ /metabib/) ? 1 : 0;
333 my $method = "open-ils.storage.metabib.$class.post_filter.search_fts.metarecord.atomic";
334 $method = "open-ils.storage.biblio.$class.search_fts.record.atomic" unless $type;
336 if(!$$args{'sort'}) {
337 delete $$args{'sort'};
338 delete $$args{'sort_dir'};
340 $$args{limit} = 200 if (!$$args{limit} || $$args{limit} > 1000);
341 $$args{offset} ||= 0;
343 $logger->info("Class search with args: ".Dumper($args));
345 $method =~ s/\.atomic/.staff.atomic/o if $self->api_name =~ /staff/o;
346 my $result = $U->storagereq( $method, %$args );
348 if($result and $result->[0]) {
350 for my $r (@$result) { push(@$recs, $r) if ($r and $r->[0]); }
351 return { ids => $recs,
352 count => ($type) ? $result->[0]->[3] : $result->[0]->[2] };
354 return { count => 0 };
360 __PACKAGE__->register_method(
361 method => "biblio_mrid_to_modsbatch_batch",
362 api_name => "open-ils.search.biblio.metarecord.mods_slim.batch.retrieve");
364 sub biblio_mrid_to_modsbatch_batch {
365 my( $self, $client, $mrids) = @_;
366 warn "Performing mrid_to_modsbatch_batch...";
368 my $method = $self->method_lookup("open-ils.search.biblio.metarecord.mods_slim.retrieve");
369 for my $id (@$mrids) {
370 next unless defined $id;
371 my ($m) = $method->run($id);
378 __PACKAGE__->register_method(
379 method => "biblio_mrid_to_modsbatch",
380 api_name => "open-ils.search.biblio.metarecord.mods_slim.retrieve",
381 notes => <<" NOTES");
382 Returns the mvr associated with a given metarecod. If none exists,
386 __PACKAGE__->register_method(
387 method => "biblio_mrid_to_modsbatch",
388 api_name => "open-ils.search.biblio.metarecord.mods_slim.retrieve.staff",
389 notes => <<" NOTES");
390 Returns the mvr associated with a given metarecod. If none exists,
394 sub biblio_mrid_to_modsbatch {
395 my( $self, $client, $mrid ) = @_;
397 warn "Grabbing mvr for $mrid\n";
399 my $mr = _grab_metarecord($mrid);
400 return undef unless $mr;
402 if( my $m = $self->biblio_mrid_check_mvr($client, $mr)) {
406 return $self->biblio_mrid_make_modsbatch( $client, $mr );
409 # converts a metarecord to an mvr
412 my $perl = JSON->JSON2perl($mr->mods());
413 return Fieldmapper::metabib::virtual_record->new($perl);
416 # checks to see if a metarecord has mods, if so returns true;
418 __PACKAGE__->register_method(
419 method => "biblio_mrid_check_mvr",
420 api_name => "open-ils.search.biblio.metarecord.mods_slim.check",
421 notes => <<" NOTES");
422 Takes a metarecord ID or a metarecord object and returns true
423 if the metarecord already has an mvr associated with it.
426 sub biblio_mrid_check_mvr {
427 my( $self, $client, $mrid ) = @_;
430 if(ref($mrid)) { $mr = $mrid; }
431 else { $mr = _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 {
442 warn "Grabbing MR $mrid\n";
444 my $mr = OpenILS::Application::AppUtils->simple_scalar_request(
446 "open-ils.storage.direct.metabib.metarecord.retrieve", $mrid );
449 throw OpenSRF::EX::ERROR
450 ("No metarecord exists with the given id: $mrid");
456 __PACKAGE__->register_method(
457 method => "biblio_mrid_make_modsbatch",
458 api_name => "open-ils.search.biblio.metarecord.mods_slim.create",
459 notes => <<" NOTES");
460 Takes either a metarecord ID or a metarecord object.
461 Forces the creations of an mvr for the given metarecord.
462 The created mvr is returned.
465 sub biblio_mrid_make_modsbatch {
467 my( $self, $client, $mrid ) = @_;
470 if(ref($mrid)) { $mr = $mrid; }
471 else { $mr = _grab_metarecord($mrid); }
474 warn "Forcing mvr creation for mr " . $mr->id . "\n";
475 my $master_id = $mr->master_record;
477 my $session = OpenSRF::AppSession->create("open-ils.storage");
479 # grab the records attached to this metarecod
480 warn "Creating mods batch for metarecord $mrid\n";
481 my $meth = "open-ils.search.biblio.metarecord_to_records.staff";
482 $meth = $self->method_lookup($meth);
483 my ($id_hash) = $meth->run($mrid);
484 my @ids = @{$id_hash->{ids}};
485 if(@ids < 1) { return undef; }
487 warn "Master ID is $master_id\n";
488 # grab the master record to start the mods batch
490 $meth = "open-ils.storage.direct.biblio.record_entry.retrieve";
492 my $record = $session->request(
493 "open-ils.storage.direct.biblio.record_entry.retrieve", $master_id );
494 $record = $record->gather(1);
496 #my $record = OpenILS::Application::AppUtils->simple_scalar_request( "open-ils.storage",
499 warn "No record returned with id $master_id";
500 throw OpenSRF::EX::ERROR
503 my $u = OpenILS::Utils::ModsParser->new();
504 $u->start_mods_batch( $record->marc );
505 my $main_doc_id = $record->id();
507 @ids = grep { $_ ne $master_id } @ids;
509 # now we have to collect all of the marc objects and push them into a mods batch
510 my $request = $session->request(
511 "open-ils.storage.direct.biblio.record_entry.batch.retrieve", @ids );
513 while( my $response = $request->recv() ) {
515 next unless $response;
516 if(UNIVERSAL::isa( $response,"OpenSRF::EX")) {
517 throw $response ($response->stringify);
520 my $content = $response->content;
523 $u->push_mods_batch( $content->marc );
527 my $mods = $u->finish_mods_batch();
528 $mods->doc_id($mrid);
531 $client->respond_complete($mods);
533 my $mods_string = JSON->perl2JSON($mods->decast);
535 $mr->mods($mods_string);
537 my $req = $session->request(
538 "open-ils.storage.direct.metabib.metarecord.update", $mr );
543 $session->disconnect();
550 # converts a mr id into a list of record ids
552 __PACKAGE__->register_method(
553 method => "biblio_mrid_to_record_ids",
554 api_name => "open-ils.search.biblio.metarecord_to_records",
557 __PACKAGE__->register_method(
558 method => "biblio_mrid_to_record_ids",
559 api_name => "open-ils.search.biblio.metarecord_to_records.staff",
562 sub biblio_mrid_to_record_ids {
563 my( $self, $client, $mrid, $format ) = @_;
565 throw OpenSRF::EX::InvalidArg
566 ("search.biblio.metarecord_to_record_ids requires mr id")
567 unless defined( $mrid );
569 warn "Searching for record for MR $mrid and format $format\n";
571 my $method = "open-ils.storage.ordered.metabib.metarecord.records.atomic";
572 if($self and $self->api_name =~ /staff/) { $method =~ s/atomic/staff\.atomic/; }
573 warn "Performing record retrieval with method $method\n";
576 my $mrmaps = OpenILS::Application::AppUtils->simple_scalar_request(
577 "open-ils.storage", $method, $mrid, $format );
583 return { count => $size, ids => $mrmaps };
588 __PACKAGE__->register_method(
589 method => "biblio_record_to_marc_html",
590 api_name => "open-ils.search.biblio.record.html" );
592 my $parser = XML::LibXML->new();
593 my $xslt = XML::LibXSLT->new();
596 my $settings_client = OpenSRF::Utils::SettingsClient->new();
597 sub biblio_record_to_marc_html {
598 my( $self, $client, $recordid ) = @_;
601 my $dir = $settings_client->config_value( "dirs", "xsl" );
602 my $xsl = $settings_client->config_value(
603 "apps", "open-ils.search", "app_settings", "marc_html_xsl" );
605 $xsl = $parser->parse_file("$dir/$xsl");
606 $marc_sheet = $xslt->parse_stylesheet( $xsl );
610 my $record = $apputils->simple_scalar_request(
612 "open-ils.storage.direct.biblio.record_entry.retrieve",
615 my $xmldoc = $parser->parse_string($record->marc);
616 my $html = $marc_sheet->transform($xmldoc);
617 $html = $html->toString();
624 __PACKAGE__->register_method(
625 method => "retrieve_all_copy_locations",
626 api_name => "open-ils.search.config.copy_location.retrieve.all" );
628 my $shelving_locations;
629 sub retrieve_all_copy_locations {
630 my( $self, $client ) = @_;
631 if(!$shelving_locations) {
632 $shelving_locations = $apputils->simple_scalar_request(
634 "open-ils.storage.direct.asset.copy_location.retrieve.all.atomic");
636 return $shelving_locations;
641 __PACKAGE__->register_method(
642 method => "retrieve_all_copy_statuses",
643 api_name => "open-ils.search.config.copy_status.retrieve.all" );
646 sub retrieve_all_copy_statuses {
647 my( $self, $client ) = @_;
648 if(!$copy_statuses) {
649 $copy_statuses = $apputils->simple_scalar_request(
651 "open-ils.storage.direct.config.copy_status.retrieve.all.atomic" );
653 return $copy_statuses;
657 __PACKAGE__->register_method(
658 method => "copy_counts_per_org",
659 api_name => "open-ils.search.biblio.copy_counts.retrieve");
661 __PACKAGE__->register_method(
662 method => "copy_counts_per_org",
663 api_name => "open-ils.search.biblio.copy_counts.retrieve.staff");
665 sub copy_counts_per_org {
666 my( $self, $client, $record_id ) = @_;
668 warn "Retreiveing copy copy counts for record $record_id and method " . $self->api_name . "\n";
670 my $method = "open-ils.storage.biblio.record_entry.global_copy_count.atomic";
671 if($self->api_name =~ /staff/) { $method =~ s/atomic/staff\.atomic/; }
673 my $counts = $apputils->simple_scalar_request(
674 "open-ils.storage", $method, $record_id );
676 $counts = [ sort {$a->[0] <=> $b->[0]} @$counts ];
681 __PACKAGE__->register_method(
682 method => "copy_count_summary",
683 api_name => "open-ils.search.biblio.copy_counts.summary.retrieve",
684 notes => <<" NOTES");
685 returns an array of these:
686 [ org_id, callnumber_label, <status1_count>, <status2_cout>,...]
687 where statusx is a copy status name. the statuses are sorted
691 sub copy_count_summary {
692 my( $self, $client, $rid ) = @_;
693 my $method = "open-ils.storage.biblio.record_entry.status_copy_count.atomic";
694 return $apputils->simple_scalar_request( "open-ils.storage", $method, $rid );
699 __PACKAGE__->register_method(
700 method => "multiclass_search",
701 api_name => "open-ils.search.biblio.multiclass",
702 notes => <<" NOTES");
703 Performs a multiclass search
704 PARAMS( searchBlob, org_unit, format, limit )
705 where searchBlob is defined like this:
707 "title" : { "term" : "water" },
708 "author" : { "term" : "smith" },
713 __PACKAGE__->register_method(
714 method => "multiclass_search",
715 api_name => "open-ils.search.biblio.multiclass.staff",
716 notes => "see open-ils.search.biblio.multiclass" );
718 sub multiclass_search {
719 my( $self, $client, $searchBlob, $orgid, $format, $limit ) = @_;
721 $logger->debug("Performing multiclass search with org => $orgid, " .
722 "format => $format, limit => $limit, and search blob " . Dumper($searchBlob));
724 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
725 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
728 my $records = $apputils->simplereq(
729 'open-ils.storage', $meth,
730 org_unit => $orgid, searches => $searchBlob, format => $format, limit => $limit );
735 if( ref($records) and $records->[0] and
736 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
738 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
740 # records has the form: [ mrid, rank, singleRecord / 0, hitCount ];
741 return { ids => $recs, count => $count };
747 __PACKAGE__->register_method(
748 method => "multiclass_search",
749 api_name => "open-ils.search.biblio.multiclass",
751 Performs a multiclass search
752 @param args A names hash of arguments:
753 org_unit : The org to focus the search on
754 depth : The search depth
757 offset : Search offset
758 searches : A named hash of searches which has the following format:
760 "title" : { "term" : "water" },
761 "author" : { "term" : "smith" },
764 @return { ids : <array of ids>, count : hitcount }
768 __PACKAGE__->register_method(
769 method => "multiclass_search",
770 api_name => "open-ils.search.biblio.multiclass.staff",
771 notes => q/@see open-ils.search.biblio.multiclass/ );
773 sub multiclass_search {
774 my( $self, $client, $args ) = @_;
776 $logger->debug("Performing multiclass search with args:\n" . Dumper($args));
777 my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
778 if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
780 my $records = $apputils->simplereq( 'open-ils.storage', $meth, %$args );
785 if( ref($records) and $records->[0] and
786 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
788 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
790 return { ids => $recs, count => $count };
796 __PACKAGE__->register_method(
797 method => "marc_search",
798 api_name => "open-ils.search.biblio.marc",
799 notes => <<" NOTES");
800 Performs a multiclass search
801 PARAMS( searchBlob, org_unit, format )
802 where searchBlob is defined like this:
805 "term":"shakespeare",
806 "restrict":[{"tag":"245","subfield":"a"}]
810 "restrict":[{"tag":"100","subfield":"a"}]
817 my( $self, $client, $searchBlob, $orgid, $format ) = @_;
819 $logger->debug("Performing MARC search with org => $orgid, " .
820 "format => $format and search blob " . Dumper($searchBlob) );
822 my $records = $apputils->simplereq(
824 'open-ils.storage.metabib.full_rec.multi_search.atomic',
825 searches => $searchBlob, org_unit => $orgid, format => $format );
830 if( ref($records) and $records->[0] and
831 defined($records->[0]->[3])) { $count = $records->[0]->[3];}
833 for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
835 # records has the form: [ mrid, rank, singleRecord / 0, hitCount ];
836 return { ids => $recs, count => $count };
842 __PACKAGE__->register_method(
843 method => "biblio_search_isbn",
844 api_name => "open-ils.search.biblio.isbn",
847 sub biblio_search_isbn {
848 my( $self, $client, $isbn ) = @_;
850 $logger->debug("Searching ISBN $isbn");
852 my $method = $self->method_lookup("open-ils.search.biblio.marc");
854 my ($records) = $method->run(
856 restrict => $cat_search_hash->{isbn} } ], 1);
862 __PACKAGE__->register_method(
863 method => "biblio_search_issn",
864 api_name => "open-ils.search.biblio.issn",
867 sub biblio_search_issn {
868 my( $self, $client, $issn ) = @_;
870 $logger->debug("Searching ISSN $issn");
872 my $method = $self->method_lookup("open-ils.search.biblio.marc");
874 my ($records) = $method->run(
876 restrict => $cat_search_hash->{issn} } ], 1);
884 __PACKAGE__->register_method(
885 method => "fetch_mods_by_copy",
886 api_name => "open-ils.search.biblio.mods_from_copy",
889 sub fetch_mods_by_copy {
890 my( $self, $client, $copyid ) = @_;
891 my ($record, $evt) = $apputils->fetch_record_by_copy( $copyid );
893 return OpenILS::Event->new('ITEM_NOT_CATALOGED') unless $record->marc;
894 return $apputils->record_to_mvr($record);
901 # -------------------------------------------------------------------------------------
903 __PACKAGE__->register_method(
904 method => "cn_browse",
905 api_name => "open-ils.search.callnumber.browse.target",
906 notes => "Starts a callnumber browse"
909 __PACKAGE__->register_method(
910 method => "cn_browse",
911 api_name => "open-ils.search.callnumber.browse.page_up",
912 notes => "Returns the previous page of callnumbers",
915 __PACKAGE__->register_method(
916 method => "cn_browse",
917 api_name => "open-ils.search.callnumber.browse.page_down",
918 notes => "Returns the next page of callnumbers",
922 # RETURNS array of arrays like so: label, owning_lib, record, id
924 my( $self, $client, @params ) = @_;
927 $method = 'open-ils.storage.asset.call_number.browse.target.atomic'
928 if( $self->api_name =~ /target/ );
929 $method = 'open-ils.storage.asset.call_number.browse.page_up.atomic'
930 if( $self->api_name =~ /page_up/ );
931 $method = 'open-ils.storage.asset.call_number.browse.page_down.atomic'
932 if( $self->api_name =~ /page_down/ );
934 return $apputils->simplereq( 'open-ils.storage', $method, @params );
936 # -------------------------------------------------------------------------------------
938 __PACKAGE__->register_method(
939 method => "fetch_cn",
940 api_name => "open-ils.search.callnumber.retrieve",
941 notes => "retrieves a callnumber based on ID",
945 my( $self, $client, $id ) = @_;
946 my( $cn, $evt ) = $apputils->fetch_callnumber( $id );