From 10aee05be6251c61b9b53908e7971664c31748d4 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 8 Jul 2005 18:19:07 +0000 Subject: [PATCH] abstract search method git-svn-id: svn://svn.open-ils.org/ILS/trunk@1103 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Storage/CDBI.pm | 1 + .../OpenILS/Application/Storage/Publisher.pm | 33 ++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm index a46f2fefc2..9176210d2c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm @@ -1,6 +1,7 @@ package OpenILS::Application::Storage::CDBI; use base qw/Class::DBI/; use Class::DBI; +use Class::DBI::AbstractSearch; use OpenILS::Application::Storage::CDBI::actor; use OpenILS::Application::Storage::CDBI::action; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher.pm index 923c004d56..23486ab5dd 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher.pm @@ -125,24 +125,30 @@ sub retrieve_node { return undef; } +sub search_where { + my $self = shift; + my $client = shift; + my @args = @_; + + my $cdbi = $self->{cdbi}; + + for my $obj ($cdbi->search_where(@args)) { + next unless ref($obj); + $client->respond( $obj->to_fieldmapper ); + } + return undef; +} + sub search { my $self = shift; my $client = shift; my @args = @_; - #my $searches = shift; - #my $options = shift; my $cdbi = $self->{cdbi}; (my $search_type = $self->api_name) =~ s/.*\.(search[^.]*).*/$1/o; - #$log->debug("Searching $cdbi for { ". - # join(',', map { "$_ => $$searches{$_}" } keys %$searches). - # " } using $search_type",DEBUG); - - #for my $obj ($cdbi->$search_type($searches, $options)) { for my $obj ($cdbi->$search_type(@args)) { - warn "$obj -> ".ref($obj); next unless ref($obj); $client->respond( $obj->to_fieldmapper ); } @@ -329,6 +335,17 @@ for my $fmclass ( (Fieldmapper->classes) ) { ); } + unless ( __PACKAGE__->is_registered( $api_prefix.'.search_where' ) ) { + __PACKAGE__->register_method( + api_name => $api_prefix.'.search_where', + method => 'search_where', + api_level => 1, + stream => 1, + cdbi => $cdbi, + cachable => 1, + ); + } + unless ( __PACKAGE__->is_registered( $api_prefix.'.search_like' ) ) { __PACKAGE__->register_method( api_name => $api_prefix.'.search_like', -- 2.43.2