New QueryParser filter_group_entry filter
authorBill Erickson <berick@esilibrary.com>
Thu, 19 Apr 2012 17:54:34 +0000 (13:54 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 22 May 2012 19:04:46 +0000 (15:04 -0400)
filter_group_entry() takes one or more filter_group_entry IDs as
parameters and applies the included sub-searches as filters on the
current search.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm

index 1bdbec7..a3ea1ac 100644 (file)
@@ -25,6 +25,23 @@ sub subquery_callback {
     );
 }
 
+sub filter_group_entry_callback {
+    my ($invocant, $self, $struct, $filter, $params, $negate) = @_;
+
+    return sprintf(' saved_query(%s)', 
+        join(
+            ',', 
+            map {
+                $_->query
+            } @{
+                OpenILS::Utils::CStoreEditor
+                    ->new
+                    ->search_actor_search_filter_group_entry({ id => $params })
+            }
+        )
+    );
+}
+
 sub quote_value {
     my $self = shift;
     my $value = shift;
@@ -429,6 +446,7 @@ __PACKAGE__->default_search_class( 'keyword' );
 
 # implements EG-specific stored subqueries
 __PACKAGE__->add_search_filter( 'saved_query', sub { return __PACKAGE__->subquery_callback(@_) } );
+__PACKAGE__->add_search_filter( 'filter_group_entry', sub { return __PACKAGE__->filter_group_entry_callback(@_) } );
 
 # will be retained simply for back-compat
 __PACKAGE__->add_search_filter( 'format' );