cachable => 1,
);
}
+__PACKAGE__->register_method(
+ api_name => "open-ils.storage.authority.in_db.browse",
+ method => "authority_in_db_browse",
+ api_level => 1,
+ argc => 5
+);
+
+sub authority_in_db_browse {
+ my ($self, $shift, $method, @args) = @_;
+ return unless $method =~ /^\w+$/;
+
+ my $db = authority::full_rec->db_Main;
+ my $list = $db->selectcol_arrayref(
+ qq/
+ SELECT ash.record
+ FROM (SELECT * FROM authority.$method(?,?,?,?)) func
+ JOIN authority.simple_heading ash ON
+ (ash.id = func.$method);
+ /,
+ {}, @args
+ );
+
+ return $list;
+}
1;
register_record_transforms();
+ register_new_authorities_methods();
+
return 1;
}
}
}
+sub register_new_authorities_methods {
+ my %register_args = (
+ method => "generic_new_authorities_method",
+ api_level => 1,
+ argc => 1,
+ signature => {
+ desc => q/Generated method/,
+ }
+ );
+
+ foreach my $how (qw/axis atag btag/) {
+ foreach my $action (qw/browse_center browse_top
+ search_rank search_heading/) {
+
+ $register_args{api_name} =
+ "open-ils.supercat.authority.$action.by_$how";
+ __PACKAGE__->register_method(%register_args);
+
+ $register_args{api_name} =
+ "open-ils.supercat.authority.$action.by_$how.refs";
+ __PACKAGE__->register_method(%register_args);
+
+ }
+ }
+}
+
+sub generic_new_authorities_method {
+ my $self = shift;
+ my $client = shift;
+
+ # We want to be extra careful with these arguments, since the next
+ # thing we're doing with them is passing them to a DB procedure.
+ my $term = ''.shift;
+ my $value = ''.shift;
+ my $page = int(shift || 0);
+ my $page_size = shift;
+
+ # undef ok, but other non numbers not ok
+ $page_size = int($page_size) if defined $page_size;
+
+ # Figure out how we were called and what DB procedure we'll call in turn.
+ $self->api_name =~ /\.by_(\w+)($|\.)/;
+ my $metaaxis = $1;
+ my $refs = $2;
+
+ $self->api_name =~ /authority\.(\w+)\./;
+ my $action = $1;
+
+ my $method = "${metaaxis}_$action";
+ $method .= "_refs" if $refs;
+
+ # Match authority.full_rec normalization
+ # XXX don't know whether we need second arg 'subfield'?
+ $value = naco_normalize($value);
+
+ my $storage = create OpenSRF::AppSession("open-ils.storage");
+ my $list = $storage->request(
+ "open-ils.storage.authority.in_db.browse",
+ $method, $term, $value, $page, $page_size
+ )->gather(1);
+
+ $storage->kill_me;
+
+ return $list;
+}
+
+
sub tree_walker {
my $tree = shift;
my $field = shift;
my $tree;
if ($axis =~ /^authority/) {
+ # Formerly, this was always browse by axis, so for right this moment
+ # I'm still not implementing a front door API for atag and btag
+ # browsing, but I might do it in a moment.
+
+ my ($realaxis, $refs) = ($axis =~ /^authority\.(\w+)(\.refs)?$/);
+
+ my $method = "open-ils.supercat.authority.browse_center.by_axis";
+ $method .= ".refs" if $refs;
+
$tree = $supercat->request(
- "open-ils.supercat.authority.browse.by_axis",
- $axis,
+ $method,
+ $realaxis,
$string,
- $page_size,
- $page
+ $page,
+ $page_size
)->gather(1);
} else {
$tree = $supercat->request(