1 package OpenILS::Application::Search::CNBrowse;
2 use base qw/OpenSRF::Application/;
3 use strict; use warnings;
5 use OpenSRF::EX qw(:try);
6 use OpenILS::Application::AppUtils;
8 use OpenSRF::Utils::Logger qw/:logger/;
9 use OpenSRF::AppSession;
10 my $U = "OpenILS::Application::AppUtils";
13 __PACKAGE__->register_method(
14 method => "cn_browse_start",
15 api_name => "open-ils.search.callnumber.browse.target",
16 notes => "Starts a callnumber browse"
19 __PACKAGE__->register_method(
20 method => "cn_browse_up",
21 api_name => "open-ils.search.callnumber.browse.page_up",
22 notes => "Returns the previous page of callnumbers",
25 __PACKAGE__->register_method(
26 method => "cn_browse_down",
27 api_name => "open-ils.search.callnumber.browse.page_down",
28 notes => "Returns the next page of callnumbers",
34 my( $self, $client, @params ) = @_;
36 $method = 'open-ils.storage.asset.call_number.browse.target.atomic'
37 if( $self->api_name =~ /target/ );
38 $method = 'open-ils.storage.asset.call_number.browse.page_up'
39 if( $self->api_name =~ /page_up/ );
40 $method = 'open-ils.storage.asset.call_number.browse.page_down'
41 if( $self->api_name =~ /page_down/ );
43 return $U->simplereq( 'open-ils.storage', $method, @params );
49 __PACKAGE__->register_method(
50 method => "cn_browse",
51 api_name => "open-ils.search.callnumber.browse",
52 notes => "Starts a callnumber browse"
56 my( $self, $conn, $cn, $orgid, $size, $offset ) = @_;
57 my $ses = OpenSRF::AppSession->create('open-ils.supercat');
59 my $tree = $U->get_slim_org_tree;
60 my $name = _find_shortname($orgid, $tree);
62 $logger->debug("cn browse found or name $name");
64 my $data = $ses->request(
65 'open-ils.supercat.call_number.browse',
66 $cn, $name, $size, $offset )->gather(1);
68 return [] unless $data;
72 my $mods = $U->record_to_mvr($d->record);
73 $d->owning_lib( $d->owning_lib->id );
74 $d->record($mods->doc_id);
75 push( @res, { cn => $d, mods => $mods });
85 return undef unless $node;
86 return $node->shortname if $node->id == $id;
87 if( $node->children ) {
88 for my $c (@{$node->children()}) {
89 my $d = _find_shortname($id, $c);