Bugzilla – Attachment 29949 Details for
Bug 12624
Getting all search results in C4::Breeding::Z3950Search, instead of pageful
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12624 - Getting all search results in C4::Breeding::Z3950Search, instead of pageful
Bug-12624---Getting-all-search-results-in-C4Breedi.patch (text/plain), 4.66 KB, created by
Olli-Antti Kivilahti
on 2014-07-22 09:28:47 UTC
(
hide
)
Description:
Bug 12624 - Getting all search results in C4::Breeding::Z3950Search, instead of pageful
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2014-07-22 09:28:47 UTC
Size:
4.66 KB
patch
obsolete
>From a4f3e4f7ea5c0267ea65cffdf7105f9d7db559b8 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Tue, 22 Jul 2014 12:21:25 +0300 >Subject: [PATCH] Bug 12624 - Getting all search results in > C4::Breeding::Z3950Search, instead of pageful > >Fetching ALL component parts from a remote Z3950 repository is difficult. >Also the Z3950Search() function only works directly to templates. > >This patch changes the Z3950Search() to OPTIONALLY return all search results as a HASH instead of a Template-object. >Previous functionality is left untouched. > >This makes scripting with it a LOT easier! >--- > C4/Breeding.pm | 61 +++++++++++++++++++++++++++++++++++++++++++--------------- > 1 file changed, 45 insertions(+), 16 deletions(-) > >diff --git a/C4/Breeding.pm b/C4/Breeding.pm >index 69adcf4..0ea7866 100644 >--- a/C4/Breeding.pm >+++ b/C4/Breeding.pm >@@ -218,17 +218,19 @@ sub BreedingSearch { > > =head2 Z3950Search > >-Z3950Search($pars, $template); >+Z3950Search($pars, $template, $getAll); > > Parameters for Z3950 search are all passed via the $pars hash. It may contain isbn, title, author, dewey, subject, lccall, controlnumber, stdid, srchany. > Also it should contain an arrayref id that points to a list of id's of the z3950 targets to be queried (see z3950servers table). > This code is used in acqui/z3950_search and cataloging/z3950_search. > The second parameter $template is a Template object. The routine uses this parameter to store the found values into the template. > >+Param3 $getAll, Get all the results instead of a small subset. $template is interpreted as a HASH where the search object is stored. >+ > =cut > > sub Z3950Search { >- my ($pars, $template)= @_; >+ my ($pars, $template, $getAll)= @_; > > my @id= @{$pars->{id}}; > my $page= $pars->{page}; >@@ -356,7 +358,18 @@ sub Z3950Search { > my $numresults = $oResult[$k]->size(); > my $i; > my $result = ''; >- if ( $numresults > 0 and $numresults >= (($page-1)*20)) { >+ if ($getAll && $numresults > 0) { >+ for ($i = 0 ; $i < $numresults ; $i++) { >+ if($oResult[$k]->record($i)) { >+ my $res=_handle_one_result($oResult[$k]->record($i), $serverinfo[$k], ++$imported, $biblionumber); #ignores error in sequence numbering >+ push @breeding_loop, $res if $res; >+ } >+ else { >+ push(@breeding_loop,{'server'=>$serverinfo[$k]->{name},'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1,'biblionumber'=>-1}); >+ } >+ } >+ } >+ elsif ( $numresults > 0 and $numresults >= (($page-1)*20)) { > $show_next = 1 if $numresults >= ($page*20); > $total_pages = int($numresults/20)+1 if $total_pages < ($numresults/20); > for ($i = ($page-1)*20; $i < (($numresults < ($page*20)) ? $numresults : ($page*20)); $i++) { >@@ -371,14 +384,23 @@ sub Z3950Search { > } #if $numresults > } > } # if $k !=0 >- >- $template->param( >- numberpending => $nremaining, >- current_page => $page, >- total_pages => $total_pages, >- show_nextbutton => $show_next?1:0, >- show_prevbutton => $page!=1, >- ); >+ >+ if ($getAll) { >+ $template->{numberpending} = $nremaining; >+ $template->{current_page} = $page; >+ $template->{total_pages} = $total_pages; >+ $template->{show_nextbutton} = $show_next; >+ $template->{show_prevbutton} = $page; >+ } >+ else { >+ $template->param( >+ numberpending => $nremaining, >+ current_page => $page, >+ total_pages => $total_pages, >+ show_nextbutton => $show_next?1:0, >+ show_prevbutton => $page!=1, >+ ); >+ } > } # while nremaining > > #close result sets and connections >@@ -391,11 +413,18 @@ sub Z3950Search { > foreach my $id (@id) { > push @servers, {id => $id}; > } >- $template->param( >- breeding_loop => \@breeding_loop, >- servers => \@servers, >- errconn => \@errconn >- ); >+ if ($getAll) { >+ $template->{breeding_loop} = \@breeding_loop; >+ $template->{servers} = \@servers; >+ $template->{errconn} = \@errconn; >+ } >+ else { >+ $template->param( >+ breeding_loop => \@breeding_loop, >+ servers => \@servers, >+ errconn => \@errconn >+ ); >+ } > } > > sub _handle_one_result { >-- >1.8.1.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12624
: 29949