From 7aa2c5629884c6daf1fb0a913c3f372769d122a1 Mon Sep 17 00:00:00 2001 From: dbwells Date: Thu, 31 Mar 2011 18:12:39 +0000 Subject: [PATCH] Use identifer indexes for older ISxN API methods (LP Bug #728671) There are three logic layers involved in the older ISxN 'quick searches': the OPAC, the search API, and the storage API. The approach of this patch is to update the search API (which in turn fixes the OPAC), and ignore/deprecate the storage API for these identifiers. git-svn-id: svn://svn.open-ils.org/ILS/trunk@19920 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../lib/OpenILS/Application/Search/Biblio.pm | 43 +++++++++++++------- .../Application/Storage/Publisher/metabib.pm | 3 + 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 226ad44..631a9be 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -2083,7 +2083,7 @@ __PACKAGE__->register_method( signature => { desc => 'Retrieve biblio IDs for a given ISBN', params => [ - {desc => 'ISBN', type => 'string'} # or number maybe? How normalized is our storage data? + {desc => 'ISBN', type => 'string'} ], return => { desc => 'Results object like: { "count": $i, "ids": [...] }', @@ -2095,10 +2095,17 @@ __PACKAGE__->register_method( sub biblio_search_isbn { my( $self, $client, $isbn ) = @_; $logger->debug("Searching ISBN $isbn"); - # Strip hyphens from incoming ISBNs - $isbn =~ s/-//g; - my $recs = $U->storagereq('open-ils.storage.id_list.biblio.record_entry.search.isbn.atomic', $isbn); - return { ids => $recs, count => scalar(@$recs) }; + # the previous implementation of this method was essentially unlimited, + # so we will set our limit very high and let multiclass.query provide any + # actual limit + # XXX: if making this unlimited is deemed important, we might consider + # reworking 'open-ils.storage.id_list.biblio.record_entry.search.isbn', + # which is functionally deprecated at this point, or a custom call to + # 'open-ils.storage.biblio.multiclass.search_fts' + my $method = $self->method_lookup('open-ils.search.biblio.multiclass.query'); + my ($search_result) = $method->run({'limit' => 1000000}, "identifier|isbn:$isbn"); + my @recs = map { $_->[0] } @{$search_result->{'ids'}}; + return { ids => \@recs, count => $search_result->{'count'} }; } __PACKAGE__->register_method( @@ -2106,16 +2113,16 @@ __PACKAGE__->register_method( api_name => "open-ils.search.biblio.isbn_list", ); +# XXX: see biblio_search_isbn() for note concerning 'limit' sub biblio_search_isbn_batch { my( $self, $client, $isbn_list ) = @_; $logger->debug("Searching ISBNs @$isbn_list"); my @recs = (); my %rec_set = (); + my $method = $self->method_lookup('open-ils.search.biblio.multiclass.query'); foreach my $isbn ( @$isbn_list ) { - # Strip hyphens from incoming ISBNs - $isbn =~ s/-//g; - foreach my $rec ( @{ $U->storagereq( - 'open-ils.storage.id_list.biblio.record_entry.search.isbn.atomic', $isbn ) - } ) { + my ($search_result) = $method->run({'limit' => 1000000}, "identifier|isbn:$isbn"); + my @recs_subset = map { $_->[0] } @{$search_result->{'ids'}}; + foreach my $rec (@recs_subset) { if (! $rec_set{ $rec }) { $rec_set{ $rec } = 1; push @recs, $rec; @@ -2143,11 +2150,17 @@ __PACKAGE__->register_method( sub biblio_search_issn { my( $self, $client, $issn ) = @_; $logger->debug("Searching ISSN $issn"); - my $e = new_editor(); - $issn =~ s/-/ /g; - my $recs = $U->storagereq( - 'open-ils.storage.id_list.biblio.record_entry.search.issn.atomic', $issn ); - return { ids => $recs, count => scalar(@$recs) }; + # the previous implementation of this method was essentially unlimited, + # so we will set our limit very high and let multiclass.query provide any + # actual limit + # XXX: if making this unlimited is deemed important, we might consider + # reworking 'open-ils.storage.id_list.biblio.record_entry.search.issn', + # which is functionally deprecated at this point, or a custom call to + # 'open-ils.storage.biblio.multiclass.search_fts' + my $method = $self->method_lookup('open-ils.search.biblio.multiclass.query'); + my ($search_result) = $method->run({'limit' => 1000000}, "identifier|issn:$issn"); + my @recs = map { $_->[0] } @{$search_result->{'ids'}}; + return { ids => \@recs, count => $search_result->{'count'} }; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm index e14cca5..3c7c06a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm @@ -215,6 +215,9 @@ __PACKAGE__->register_method( cachable => 1, ); +# XXX: this subroutine and its two registered methods are marked for +# deprecation, as they do not work properly in 2.x (these tags are no longer +# normalized in mfr) and are not in known use sub isxn_search { my $self = shift; my $client = shift; -- 1.7.2.5