Metarecord list on results page
authorBill Erickson <berick@esilibrary.com>
Wed, 27 Jul 2011 18:40:46 +0000 (14:40 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 27 Jul 2011 18:43:54 +0000 (14:43 -0400)
Added a new ?metarecord=<mrid> param to opac/results page to list
records associated with a given metarecord ID.  This is used as page 2
of the (pending) metarecord search process as well 'show in catalog'
for embedded staff client metarecord holds.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm

index 787228c..d445250 100644 (file)
@@ -48,7 +48,7 @@ sub _prepare_biblio_search_basics {
 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'));
 
@@ -135,37 +135,52 @@ sub load_rresults {
     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}}];