adding id_list varient to the storage search API
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 6 Mar 2006 21:41:49 +0000 (21:41 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 6 Mar 2006 21:41:49 +0000 (21:41 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3273 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher.pm

index fd8770c..bcd3368 100644 (file)
@@ -31,6 +31,21 @@ sub register_method {
                        __PACKAGE__->SUPER::register_method( %dup_args );
                }
        }
+
+       if ($dup_args{real_api_name} =~ /^open-ils\.storage\.direct\..+\.search.+/o ||
+           $dup_args{api_name} =~ /^open-ils\.storage\.direct\..+\.search.+/o) {
+               $dup_args{api_name} = $dup_args{real_api_name} if ($dup_args{real_api_name});
+
+               (my $name = $dup_args{api_name}) =~ s/\.direct\./.id_list./o;
+
+               $dup_args{notes} = $dup_args{real_api_name};
+               $dup_args{real_api_name} = $dup_args{api_name};
+               $dup_args{method} = 'search_ids';
+               $dup_args{api_name} = $name;
+               $dup_args{package} = __PACKAGE__;
+
+               __PACKAGE__->SUPER::register_method( %dup_args );
+       }
 }
 
 sub cachable_wrapper {
@@ -126,6 +141,21 @@ sub retrieve_node {
        return undef;
 }
 
+sub search_ids {
+       my $self = shift;
+       my $client = shift;
+       my @args = @_;
+
+       my @res = $self->method_lookup($self->{real_api_name})->run(@args);
+
+       if (ref($res[0]) eq 'ARRAY') {
+               return [ map { $_->id } @{ $res[0] } ];
+       }
+
+       $client->respond($_) for ( map { $_->id } @res );
+       return undef;
+}
+
 sub search_where {
        my $self = shift;
        my $client = shift;