sub _prepare_biblio_search {
my ($cgi, $ctx) = @_;
- my $query = _prepare_biblio_search_basics($cgi);
+ my $query = _prepare_biblio_search_basics($cgi) || '';
$query = ('#' . $_ . ' ' . $query) foreach ($cgi->param('modifier'));
my $page = $cgi->param('page') || 0;
my $facet = $cgi->param('facet');
my $limit = $self->_get_search_limit;
- my $loc = $cgi->param('loc');
+ my $loc = $cgi->param('loc') || $ctx->{aou_tree}->()->id;
my $offset = $page * $limit;
+ my $metarecord = $cgi->param('metarecord');
+ my $results;
my ($query, $site, $depth) = _prepare_biblio_search($cgi, $ctx);
- return $self->generic_redirect unless $query;
+ if ($metarecord) {
- # Limit and offset will stay here. Everything else should be part of
- # the query string, not special args.
- my $args = {'limit' => $limit, 'offset' => $offset};
+ # TODO: other limits, like SVF/format, etc.
+ $results = $U->simplereq(
+ 'open-ils.search',
+ 'open-ils.search.biblio.metarecord_to_records',
+ $metarecord, {org => $loc, depth => $depth}
+ );
+
+ # force the metarecord result blob to match the format of regular search results
+ $results->{ids} = [map { [$_] } @{$results->{ids}}];
+
+ } else {
- # Stuff these into the TT context so that templates can use them in redrawing forms
- $ctx->{processed_search_query} = $query;
+ return $self->generic_redirect unless $query;
- $query = "$query $facet" if $facet; # TODO
+ # Limit and offset will stay here. Everything else should be part of
+ # the query string, not special args.
+ my $args = {'limit' => $limit, 'offset' => $offset};
- $logger->activity("EGWeb: [search] $query");
+ # Stuff these into the TT context so that templates can use them in redrawing forms
+ $ctx->{processed_search_query} = $query;
- my $results;
+ $query = "$query $facet" if $facet; # TODO
- try {
+ $logger->activity("EGWeb: [search] $query");
- my $method = 'open-ils.search.biblio.multiclass.query';
- $method .= '.staff' if $ctx->{is_staff};
- $results = $U->simplereq('open-ils.search', $method, $args, $query, 1);
+ try {
- } catch Error with {
- my $err = shift;
- $logger->error("multiclass search error: $err");
- $results = {count => 0, ids => []};
- };
+ my $method = 'open-ils.search.biblio.multiclass.query';
+ $method .= '.staff' if $ctx->{is_staff};
+ $results = $U->simplereq('open-ils.search', $method, $args, $query, 1);
+
+ } catch Error with {
+ my $err = shift;
+ $logger->error("multiclass search error: $err");
+ $results = {count => 0, ids => []};
+ };
+ }
my $rec_ids = [map { $_->[0] } @{$results->{ids}}];