From: miker Date: Thu, 3 Jun 2010 14:35:03 +0000 (+0000) Subject: add authority browsing framework to backend supercat app X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=47df43d7babf9d23681b392206f9287baa4610f3;p=evergreen%2Fbjwebb.git add authority browsing framework to backend supercat app git-svn-id: svn://svn.open-ils.org/ILS/trunk@16579 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm index 213d51050..b4f15e5ba 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm @@ -666,6 +666,161 @@ Returns a list of the requested org-scoped record ids held } ); +sub general_authority_browse { + my $self = shift; + my $client = shift; + return tag_sf_browse($self, $client, $self->{tag}, $self->{subfield}, @_); +} +__PACKAGE__->register_method( + method => 'general_authority_browse', + api_name => 'open-ils.supercat.authority.title.browse', + tag => '130', subfield => 'a', + api_level => 1, + argc => 1, + signature => + { desc => "Returns a list of the requested org-scoped record ids held", + params => + [ { name => 'value', desc => 'The target title', type => 'string' }, + { name => 'page_size', desc => 'Count of records to retrieve, default is 9', type => 'number' }, + { name => 'page', desc => 'The page of records retrieve, calculated based on page_size. Can be positive, negative or 0.', type => 'number' }, ], + 'return' => { desc => 'Authority Record IDs that are near the target string', type => 'array' } + } +); +__PACKAGE__->register_method( + method => 'general_authority_browse', + api_name => 'open-ils.supercat.authority.author.browse', + tag => [qw/100 110 111/], subfield => 'a', + api_level => 1, + argc => 1, + signature => + { desc => "Returns a list of the requested org-scoped record ids held", + params => + [ { name => 'value', desc => 'The target author', type => 'string' }, + { name => 'page_size', desc => 'Count of records to retrieve, default is 9', type => 'number' }, + { name => 'page', desc => 'The page of records retrieve, calculated based on page_size. Can be positive, negative or 0.', type => 'number' }, ], + 'return' => { desc => 'Authority Record IDs that are near the target string', type => 'array' } + } +); +__PACKAGE__->register_method( + method => 'general_authority_browse', + api_name => 'open-ils.supercat.authority.subject.browse', + tag => [qw/148 150 151 155/], subfield => 'a', + api_level => 1, + argc => 1, + signature => + { desc => "Returns a list of the requested org-scoped record ids held", + params => + [ { name => 'value', desc => 'The target subject', type => 'string' }, + { name => 'page_size', desc => 'Count of records to retrieve, default is 9', type => 'number' }, + { name => 'page', desc => 'The page of records retrieve, calculated based on page_size. Can be positive, negative or 0.', type => 'number' }, ], + 'return' => { desc => 'Authority Record IDs that are near the target string', type => 'array' } + } +); +__PACKAGE__->register_method( + method => 'general_authority_browse', + api_name => 'open-ils.supercat.authority.topic.browse', + tag => '150', subfield => 'a', + api_level => 1, + argc => 1, + signature => + { desc => "Returns a list of the requested org-scoped record ids held", + params => + [ { name => 'value', desc => 'The target topical subject', type => 'string' }, + { name => 'page_size', desc => 'Count of records to retrieve, default is 9', type => 'number' }, + { name => 'page', desc => 'The page of records retrieve, calculated based on page_size. Can be positive, negative or 0.', type => 'number' }, ], + 'return' => { desc => 'Authority Record IDs that are near the target string', type => 'array' } + } +); + +sub authority_tag_sf_browse { + my $self = shift; + my $client = shift; + + my $tag = shift; + my $subfield = shift; + my $value = shift; + my $page_size = shift || 9; + my $page = shift || 0; + + my ($before_limit,$after_limit) = (0,0); + my ($before_offset,$after_offset) = (0,0); + + if (!$page) { + $before_limit = $after_limit = int($page_size / 2); + $after_limit += 1 if ($page_size % 2); + } else { + $before_offset = $after_offset = int($page_size / 2); + $before_offset += 1 if ($page_size % 2); + $before_limit = $after_limit = $page_size; + } + + my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' ); + + my @list = (); + + if ($page <= 0) { + my $before = $_storage->request( + "open-ils.cstore.json_query.atomic", + { select => { afr => [qw/record value/] }, + from => 'afr', + where => { tag => $tag, subfield => $subfield, value => { '<' => lc($value) } }, + order_by => { afr => { value => 'desc' } }, + limit => $before_limit, + offset => abs($page) * $page_size - $before_offset, + } + )->gather(1); + push @list, map { $_->{record} } reverse(@$before); + } + + if ($page >= 0) { + my $after = $_storage->request( + "open-ils.cstore.json_query.atomic", + { select => { afr => [qw/record value/] }, + from => 'afr', + where => { tag => $tag, subfield => $subfield, value => { '>=' => lc($value) } }, + order_by => { mfr => { value => 'asc' } }, + limit => $after_limit, + offset => abs($page) * $page_size - $after_offset, + } + )->gather(1); + push @list, map { $_->{record} } @$after; + } + + return \@list; +} +__PACKAGE__->register_method( + method => 'authority_tag_sf_browse', + api_name => 'open-ils.supercat.authority.tag.browse', + api_level => 1, + argc => 1, + signature => + { desc => <<" DESC", +Returns a list of the requested org-scoped record ids held + DESC + params => + [ + { name => 'tag', + desc => 'The target Authority MARC tag', + type => 'string' }, + { name => 'subfield', + desc => 'The target Authority MARC subfield', + type => 'string' }, + { name => 'value', + desc => 'The target string', + type => 'string' }, + { name => 'page_size', + desc => 'Count of call numbers to retrieve, default is 9', + type => 'number' }, + { name => 'page', + desc => 'The page of call numbers to retrieve, calculated based on page_size. Can be positive, negative or 0.', + type => 'number' }, + ], + 'return' => + { desc => 'Authority Record IDs that are near the target string', + type => 'array' } + } +); + sub holding_data_formats { return [{ marcxml => {