Bugzilla – Attachment 26170 Details for
Bug 6536
Z3950 Search Enhancements: SRU targets and additional XSLT processing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[TESTPATCH 3.8] 6536 part 2
6536-2.patch (text/plain), 29.96 KB, created by
Marcel de Rooy
on 2014-03-12 12:40:11 UTC
(
hide
)
Description:
[TESTPATCH 3.8] 6536 part 2
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2014-03-12 12:40:11 UTC
Size:
29.96 KB
patch
obsolete
>From f55f1193ebbf9fb492d10a578a6b80a50417fb80 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 15 Oct 2012 13:50:32 +0200 >Subject: [PATCH] 6536 2 >Content-Type: text/plain; charset=utf-8 > >--- > C4/Breeding.pm | 222 +++++++++++++++++++++++++++++++++++++++- > acqui/z3950_search.pl | 243 +++++-------------------------------------- > cataloguing/z3950_search.pl | 243 ++++-------------------------------------- > 3 files changed, 269 insertions(+), 439 deletions(-) > >diff --git a/C4/Breeding.pm b/C4/Breeding.pm >index 2959ecf..85e8bbd 100644 >--- a/C4/Breeding.pm >+++ b/C4/Breeding.pm >@@ -20,10 +20,13 @@ package C4::Breeding; > use strict; > use warnings; > >+#use Encode; >+use MARC::File::USMARC; >+#use ZOOM; #has been loaded already in Context >+ > use C4::Biblio; > use C4::Koha; > use C4::Charset; >-use MARC::File::USMARC; > use C4::ImportBatch; > > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); >@@ -33,7 +36,7 @@ BEGIN { > $VERSION = 3.08.01.002; > require Exporter; > @ISA = qw(Exporter); >- @EXPORT = qw(&ImportBreeding &BreedingSearch); >+ @EXPORT = qw(&ImportBreeding &BreedingSearch Z3950Search); > } > > =head1 NAME >@@ -211,6 +214,221 @@ sub BreedingSearch { > return($count, @results); > } # sub breedingsearch > >+ >+=head2 Z3950Search >+ >+Z3950Search($pars, $template); >+ >+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. >+ >+=cut >+ >+sub Z3950Search { >+ my ($pars, $template)= @_; >+ >+ my $server; >+ my $marcdata; >+ my @encoding; >+ my @serverhost; >+ my @servername; >+ my @breeding_loop = (); >+ my $numberpending; >+ >+ my $dbh = C4::Context->dbh; >+ my @id = @{$pars->{id}}; >+ my @oConnection; >+ my @oResult; >+ my @errconn; >+ my $s = 0; >+ my $query = ''; >+ my $nterms; >+ my $term; >+ if ($pars->{isbn}) { >+ $term=$pars->{isbn}; >+ $query .= " \@or \@attr 1=8 \"$term\" \@attr 1=7 \"$term\" "; >+ $nterms++; >+ } >+ if ($pars->{title}) { >+ $term=$pars->{title}; >+ utf8::decode($term); >+ $query .= " \@attr 1=4 \"$term\" "; >+ $nterms++; >+ } >+ if ($pars->{author}) { >+ $term=$pars->{author}; >+ utf8::decode($term); >+ $query .= " \@attr 1=1003 \"$term\" "; >+ $nterms++; >+ } >+ if ($pars->{dewey}) { >+ $term=$pars->{dewey}; >+ $query .= " \@attr 1=16 \"$term\" "; >+ $nterms++; >+ } >+ if ($pars->{subject}) { >+ $term=$pars->{subject}; >+ utf8::decode($term); >+ $query .= " \@attr 1=21 \"$term\" "; >+ $nterms++; >+ } >+ if ($pars->{lccall}) { >+ $term=$pars->{lccall}; >+ $query .= " \@attr 1=16 \@attr 2=3 \@attr 3=1 \@attr 4=1 \@attr 5=1 \@attr 6=1 \"$term\" "; >+ $nterms++; >+ } >+ if ($pars->{controlnumber}) { >+ $term=$pars->{controlnumber}; >+ $query .= " \@attr 1=12 \"$term\" "; >+ $nterms++; >+ } >+ if ($pars->{stdid}) { >+ $term=$pars->{stdid}; >+ $query .= " \@attr 1=1007 \"$term\" "; >+ $nterms++; >+ } >+ if ($pars->{srchany}) { >+ $term=$pars->{srchany}; >+ $query .= " \@attr 1=1016 \"$term\" "; >+ $nterms++; >+ } >+ >+ for my $i (1..$nterms-1) { >+ $query = "\@and " . $query; >+ } >+ >+ foreach my $servid (@id) { >+ my $sth = $dbh->prepare("SELECT * FROM z3950servers WHERE id=? ORDER BY rank, name"); >+ $sth->execute($servid); >+ while ( $server = $sth->fetchrow_hashref ) { >+ my $option1 = new ZOOM::Options(); >+ $option1->option('async' => 1); >+ $option1->option('elementSetName', 'F'); >+ $option1->option('databaseName', $server->{db}); >+ $option1->option('user', $server->{userid} ) if $server->{userid}; >+ $option1->option('password', $server->{password}) if $server->{password}; >+ $option1->option('preferredRecordSyntax', $server->{syntax}); >+ $option1->option( 'timeout', $server->{timeout} ) if ($server->{timeout}); >+ $oConnection[$s] = create ZOOM::Connection($option1) >+ || $DEBUG >+ && warn( "" . $oConnection[$s]->errmsg() ); >+ warn( "server data", $server->{name}, $server->{port} ) if $DEBUG; >+ $oConnection[$s]->connect( $server->{host}, $server->{port} ) >+ || $DEBUG >+ && warn( "" . $oConnection[$s]->errmsg() ); >+ $serverhost[$s] = $server->{host}; >+ $servername[$s] = $server->{name}; >+ $encoding[$s] = ($server->{encoding}?$server->{encoding}:"iso-5426"); >+ $s++; >+ } ## while fetch >+ } # foreach >+ my $nremaining = $s; >+ my $firstresult = 1; >+ >+ for ( my $z = 0 ; $z < $s ; $z++ ) { >+ warn "doing the search" if $DEBUG; >+ $oResult[$z] = $oConnection[$z]->search_pqf($query) >+ || $DEBUG >+ && warn( "somthing went wrong: " . $oConnection[$s]->errmsg() ); >+ >+ } >+ >+ AGAIN: >+ my $k; >+ my $event; >+ while ( ( $k = ZOOM::event( \@oConnection ) ) != 0 ) { >+ $event = $oConnection[ $k - 1 ]->last_event(); >+ warn( "connection ", $k - 1, ": event $event (", >+ ZOOM::event_str($event), ")\n" ) >+ if $DEBUG; >+ last if $event == ZOOM::Event::ZEND; >+ } >+ >+ if ( $k != 0 ) { >+ $k--; >+ warn $serverhost[$k] if $DEBUG; >+ my ( $error, $errmsg, $addinfo, $diagset ) = >+ $oConnection[$k]->error_x(); >+ if ($error) { >+ if ($error =~ m/^(10000|10007)$/ ) { >+ push(@errconn, {'server' => $serverhost[$k], 'error' => $error}); >+ } >+ $DEBUG and warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n"; >+ } >+ else { >+ my $numresults = $oResult[$k]->size(); >+ my $i; >+ my $result = ''; >+ if ( $numresults > 0 ) { >+ for ($i = 0; $i < (($numresults < 20) ? $numresults : 20); $i++) { >+ my $rec = $oResult[$k]->record($i); >+ if ($rec) { >+ my $marcrecord; >+ $marcdata = $rec->raw(); >+ >+ my ($charset_result, $charset_errors); >+ ($marcrecord, $charset_result, $charset_errors) = >+ MarcToUTF8Record($marcdata, C4::Context->preference('marcflavour'), $encoding[$k]); >+ SetUTF8Flag($marcrecord); >+####WARNING records coming from Z3950 clients are in various character sets MARC8,UTF8,UNIMARC etc >+## In HEAD i change everything to UTF-8 >+# In rel2_2 i am not sure what encoding is so no character conversion is done here >+##Add necessary encoding changes to here -TG >+ my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, "" ); >+ $oldbiblio->{isbn} =~ s/ |-|\.//g if $oldbiblio->{isbn}; >+ # pad | and ( with spaces to allow line breaks in the HTML >+ $oldbiblio->{isbn} =~ s/\|/ \| /g if $oldbiblio->{isbn}; >+ $oldbiblio->{isbn} =~ s/\(/ \(/g if $oldbiblio->{isbn}; >+ >+ $oldbiblio->{issn} =~ s/ |-|\.//g if $oldbiblio->{issn}; >+ # pad | and ( with spaces to allow line breaks in the HTML >+ $oldbiblio->{issn} =~ s/\|/ \| /g if $oldbiblio->{issn}; >+ $oldbiblio->{issn} =~ s/\(/ \(/g if $oldbiblio->{issn}; >+ my ( >+ $notmarcrecord, $alreadyindb, $alreadyinfarm, >+ $imported, $breedingid >+ ) >+ = ImportBreeding( $marcdata, 2, $serverhost[$k], $encoding[$k], $pars->{random}, 'z3950' ); >+ my %row_data; >+ $row_data{server} = $servername[$k]; >+ $row_data{isbn} = $oldbiblio->{isbn}; >+ $row_data{lccn} = $oldbiblio->{lccn}; >+ $row_data{title} = $oldbiblio->{title}; >+ $row_data{author} = $oldbiblio->{author}; >+ $row_data{date} = $oldbiblio->{copyrightdate}; >+ $row_data{edition} = $oldbiblio->{editionstatement}; >+ $row_data{breedingid} = $breedingid; >+ $row_data{biblionumber} = $pars->{biblionumber}; >+ push( @breeding_loop, \%row_data ); >+ >+ } else { >+ push(@breeding_loop,{'server'=>$servername[$k],'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1,'biblionumber'=>-1}); >+ } # $rec >+ } >+ } #$numresults >+ } >+ } # if $k !=0 >+ $numberpending = $nremaining - 1; >+ $template->param( >+ breeding_loop => \@breeding_loop, >+ server => $servername[$k], >+ numberpending => $numberpending, >+ biblionumber => $pars->{biblionumber}, >+ errconn => \@errconn >+ ); >+ >+ return if $numberpending==0; >+ >+ $firstresult++; >+ >+ MAYBE_AGAIN: >+ if ( --$nremaining > 0 ) { >+ goto AGAIN; >+ } >+} >+ > 1; > __END__ > >diff --git a/acqui/z3950_search.pl b/acqui/z3950_search.pl >index 252f05e..aea4fa2 100755 >--- a/acqui/z3950_search.pl >+++ b/acqui/z3950_search.pl >@@ -19,19 +19,19 @@ > # with Koha; if not, write to the Free Software Foundation, Inc., > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > >-use warnings; > use strict; >+use warnings; > use CGI; > > use C4::Auth; > use C4::Output; >-use C4::Biblio; >+#use C4::Biblio; > use C4::Context; > use C4::Breeding; > use C4::Koha; >-use C4::Charset; >+#use C4::Charset; > use C4::Bookseller qw/ GetBookSellerFromId /; >-use ZOOM; >+#use ZOOM; > > my $input = new CGI; > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >@@ -47,10 +47,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > > > my $dbh = C4::Context->dbh; >-my $error = $input->param('error'); >-my $biblionumber = $input->param('biblionumber'); >-$biblionumber = 0 unless $biblionumber; >-my $frameworkcode = $input->param('frameworkcode'); >+my $biblionumber = $input->param('biblionumber') || 0; >+my $frameworkcode = $input->param('frameworkcode') || ''; > my $title = $input->param('title'); > my $author = $input->param('author'); > my $isbn = $input->param('isbn'); >@@ -60,34 +58,9 @@ my $lccall = $input->param('lccall'); > my $subject= $input->param('subject'); > my $dewey = $input->param('dewey'); > my $controlnumber = $input->param('controlnumber'); >-my $op = $input->param('op'); >+my $op = $input->param('op')||''; > my $booksellerid = $input->param('booksellerid'); > my $basketno = $input->param('basketno'); >-my $noconnection; >-my $attr = ''; >-my $term; >-my $host; >-my $server; >-my $database; >-my $port; >-my $marcdata; >-my @encoding; >-my @results; >-my $count; >-my $toggle; >-my $record; >-my $oldbiblio; >-my $errmsg; >-my @serverhost; >-my @servername; >-my @breeding_loop = (); >-my $random = $input->param('random'); >-unless ($random) >-{ # this var is not useful anymore just kept to keep rel2_2 compatibility >- $random = rand(1000000000); >-} >- >-my $DEBUG = $ENV{DEBUG} || 0; # if set to 1, many debug message are send on syslog. > > # get framework list > my $frameworks = getframeworks; >@@ -130,195 +103,29 @@ if ( $op ne "do_search" ) { > biblionumber => $biblionumber, > ); > output_html_with_http_headers $input, $cookie, $template->output; >- exit; > } >- >+else { > my @id = $input->param('id'); >- >- if ( not @id ) { >+ if (@id==0) { > # empty server list -> report and exit > $template->param( emptyserverlist => 1 ); > output_html_with_http_headers $input, $cookie, $template->output; > exit; > } >- >- my @oConnection; >- my @oResult; >- my @errconn; >- my $s = 0; >- my $query; >- my $nterms; >- if ($isbn || $issn) { >- $term=$isbn if ($isbn); >- $term=$issn if ($issn); >- $query .= " \@or \@attr 1=8 \"$term\" \@attr 1=7 \"$term\" "; >- $nterms++; >- } >- if ($title) { >- utf8::decode($title); >- $query .= " \@attr 1=4 \"$title\" "; >- $nterms++; >- } >- if ($author) { >- utf8::decode($author); >- $query .= " \@attr 1=1003 \"$author\" "; >- $nterms++; >- } >- if ($dewey) { >- $query .= " \@attr 1=16 \"$dewey\" "; >- $nterms++; >- } >- if ($subject) { >- utf8::decode($subject); >- $query .= " \@attr 1=21 \"$subject\" "; >- $nterms++; >- } >- if ($lccn) { >- $query .= " \@attr 1=9 $lccn "; >- $nterms++; >- } >- if ($lccall) { >- $query .= " \@attr 1=16 \@attr 2=3 \@attr 3=1 \@attr 4=1 \@attr 5=1 \@attr 6=1 \"$lccall\" "; >- $nterms++; >- } >- if ($controlnumber) { >- $query .= " \@attr 1=12 \"$controlnumber\" "; >- $nterms++; >- } >-for my $i (1..$nterms-1) { >- $query = "\@and " . $query; >+ my $pars= { >+ random => $input->param('random') || rand(1000000000), >+ biblionumber => $biblionumber, >+ id => \@id, >+ isbn => $isbn, >+ title => $title, >+ author => $author, >+ dewey => $dewey, >+ subject => $subject, >+ lccall => $lccall, >+ controlnumber => $controlnumber, >+ stdid => 0, >+ srchany => 0, >+ }; >+ Z3950Search($pars, $template); >+ output_html_with_http_headers $input, $cookie, $template->output; > } >-warn "query ".$query if $DEBUG; >- >- foreach my $servid (@id) { >- my $sth = $dbh->prepare("select * from z3950servers where id=?"); >- $sth->execute($servid); >- while ( $server = $sth->fetchrow_hashref ) { >- warn "serverinfo ".join(':',%$server) if $DEBUG; >- my $option1 = new ZOOM::Options(); >- $option1->option( 'async' => 1 ); >- $option1->option( 'elementSetName', 'F' ); >- $option1->option( 'databaseName', $server->{db} ); >- $option1->option( 'user', $server->{userid} ) if $server->{userid}; >- $option1->option( 'password', $server->{password} ) >- if $server->{password}; >- $option1->option( 'preferredRecordSyntax', $server->{syntax} ); >- $oConnection[$s] = create ZOOM::Connection($option1) >- || $DEBUG >- && warn( "" . $oConnection[$s]->errmsg() ); >- warn( "server data", $server->{name}, $server->{port} ) if $DEBUG; >- $oConnection[$s]->connect( $server->{host}, $server->{port} ) >- || $DEBUG >- && warn( "" . $oConnection[$s]->errmsg() ); >- $serverhost[$s] = $server->{host}; >- $servername[$s] = $server->{name}; >- $encoding[$s] = ($server->{encoding}?$server->{encoding}:"iso-5426"); >- $s++; >- } ## while fetch >- } # foreach >- my $nremaining = $s; >- my $firstresult = 1; >- >- for ( my $z = 0 ; $z < $s ; $z++ ) { >- warn "doing the search" if $DEBUG; >- $oResult[$z] = $oConnection[$z]->search_pqf($query) >- || $DEBUG >- && warn( "somthing went wrong: " . $oConnection[$s]->errmsg() ); >- >- # $oResult[$z] = $oConnection[$z]->search_pqf($query); >- } >- >- warn "# nremaining = $nremaining\n" if $DEBUG; >- >- while ( $nremaining-- ) { >- >- my $k; >- my $event; >- while ( ( $k = ZOOM::event( \@oConnection ) ) != 0 ) { >- $event = $oConnection[ $k - 1 ]->last_event(); >- warn( "connection ", $k - 1, ": event $event (", >- ZOOM::event_str($event), ")\n" ) >- if $DEBUG; >- last if $event == ZOOM::Event::ZEND; >- } >- >- if ( $k != 0 ) { >- $k--; >- warn "event from $k server = ",$serverhost[$k] if $DEBUG; >- my ( $error, $errmsg, $addinfo, $diagset ) = >- $oConnection[$k]->error_x(); >- if ($error) { >- if ($error =~ m/^(10000|10007)$/ ) { >- push(@errconn, {'server' => $serverhost[$k]}); >- } >- $DEBUG and warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n"; >- } >- else { >- my $numresults = $oResult[$k]->size(); >- warn "numresults = $numresults" if $DEBUG; >- my $i; >- my $result = ''; >- if ( $numresults > 0 ) { >- for ( >- $i = 0 ; >- $i < ( ( $numresults < 20 ) ? ($numresults) : (20) ) ; >- $i++ >- ) >- { >- my $rec = $oResult[$k]->record($i); >- if ($rec) { >- my $marcrecord; >- $marcdata = $rec->raw(); >- >- my ($charset_result, $charset_errors); >- ($marcrecord, $charset_result, $charset_errors) = >- MarcToUTF8Record($marcdata, C4::Context->preference('marcflavour'), $encoding[$k]); >- SetUTF8Flag($marcrecord); >-####WARNING records coming from Z3950 clients are in various character sets MARC8,UTF8,UNIMARC etc >-## In HEAD i change everything to UTF-8 >-# In rel2_2 i am not sure what encoding is so no character conversion is done here >-##Add necessary encoding changes to here -TG >- my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, "" ); >- $oldbiblio->{isbn} =~ s/ |-|\.//g if $oldbiblio->{isbn}; >- # pad | and ( with spaces to allow line breaks in the HTML >- $oldbiblio->{isbn} =~ s/\|/ \| /g if $oldbiblio->{isbn}; >- $oldbiblio->{isbn} =~ s/\(/ \(/g if $oldbiblio->{isbn}; >- >- $oldbiblio->{issn} =~ s/ |-|\.//g if $oldbiblio->{issn}; >- # pad | and ( with spaces to allow line breaks in the HTML >- $oldbiblio->{issn} =~ s/\|/ \| /g if $oldbiblio->{issn}; >- $oldbiblio->{issn} =~ s/\(/ \(/g if $oldbiblio->{issn}; >- my ( >- $notmarcrecord, $alreadyindb, $alreadyinfarm, >- $imported, $breedingid >- ) >- = ImportBreeding( $marcdata, 2, $serverhost[$k], $encoding[$k], $random, 'z3950' ); >- my %row_data; >- $row_data{server} = $servername[$k]; >- $row_data{isbn} = $oldbiblio->{isbn}; >- $row_data{lccn} = $oldbiblio->{lccn}; >- $row_data{title} = $oldbiblio->{title}; >- $row_data{author} = $oldbiblio->{author}; >- $row_data{breedingid} = $breedingid; >- $row_data{biblionumber} = $biblionumber; >- push( @breeding_loop, \%row_data ); >- >- } else { >- push(@breeding_loop,{'server'=>$servername[$k],'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1,'biblionumber'=>-1}); >- } # $rec >- } # upto 5 results >- } #$numresults >- } >- } # if $k !=0 >- # print $template->output if $firstresult !=1; >- $firstresult++; >- >- } # while nremaining >- >-$template->param( >-breeding_loop => \@breeding_loop, >-#server => $servername[$k], >-numberpending => $nremaining > 0 ? $nremaining : 0, >-errconn => \@errconn >-); >-output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/cataloguing/z3950_search.pl b/cataloguing/z3950_search.pl >index 18b0ff2..9364756 100755 >--- a/cataloguing/z3950_search.pl >+++ b/cataloguing/z3950_search.pl >@@ -19,23 +19,22 @@ > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > > use strict; >-#use warnings; FIXME - Bug 2505 >+use warnings; > use CGI; > > use C4::Auth; > use C4::Output; >-use C4::Biblio; >+#use C4::Biblio; > use C4::Context; > use C4::Breeding; >-use C4::Koha; >-use C4::Charset; >-use ZOOM; >+#use C4::Koha; >+#use C4::Charset; >+#use ZOOM; > > my $input = new CGI; > my $dbh = C4::Context->dbh; >-my $error = $input->param('error'); > my $biblionumber = $input->param('biblionumber') || 0; >-my $frameworkcode = $input->param('frameworkcode'); >+my $frameworkcode = $input->param('frameworkcode') || ''; > my $title = $input->param('title'); > my $author = $input->param('author'); > my $isbn = $input->param('isbn'); >@@ -47,28 +46,7 @@ my $dewey = $input->param('dewey'); > my $controlnumber = $input->param('controlnumber'); > my $stdid = $input->param('stdid'); > my $srchany = $input->param('srchany'); >-my $random = $input->param('random') || rand(1000000000); # this var is not useful anymore just kept for rel2_2 compatibility >-my $op = $input->param('op'); >-my $numberpending; >-my $attr = ''; >-my $term; >-my $host; >-my $server; >-my $database; >-my $port; >-my $marcdata; >-my @encoding; >-my @results; >-my $count; >-my $record; >-my $oldbiblio; >-my $errmsg; >-my @serverloop = (); >-my @serverhost; >-my @servername; >-my @breeding_loop = (); >- >-my $DEBUG = 0; # if set to 1, many debug message are send on syslog. >+my $op = $input->param('op') || ''; > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ > template_name => "cataloguing/z3950_search.tmpl", >@@ -103,199 +81,26 @@ if ( $op ne "do_search" ) { > } > else { > my @id = $input->param('id'); >- >- if ( not defined @id ) { >+ if(@id==0) { > # empty server list -> report and exit > $template->param( emptyserverlist => 1 ); > output_html_with_http_headers $input, $cookie, $template->output; > exit; > } >- >- my @oConnection; >- my @oResult; >- my @errconn; >- my $s = 0; >- my $query = ''; >- my $nterms; >- if ($isbn || $issn) { >- $term=$isbn if ($isbn); >- $term=$issn if ($issn); >- $query .= " \@or \@attr 1=8 \"$term\" \@attr 1=7 \"$term\" "; >- $nterms++; >- } >- if ($title) { >- utf8::decode($title); >- $query .= " \@attr 1=4 \"$title\" "; >- $nterms++; >- } >- if ($author) { >- utf8::decode($author); >- $query .= " \@attr 1=1003 \"$author\" "; >- $nterms++; >- } >- if ($dewey) { >- $query .= " \@attr 1=16 \"$dewey\" "; >- $nterms++; >- } >- if ($subject) { >- utf8::decode($subject); >- $query .= " \@attr 1=21 \"$subject\" "; >- $nterms++; >- } >- if ($lccn) { >- $query .= " \@attr 1=9 $lccn "; >- $nterms++; >- } >- if ($lccall) { >- $query .= " \@attr 1=16 \@attr 2=3 \@attr 3=1 \@attr 4=1 \@attr 5=1 \@attr 6=1 \"$lccall\" "; >- $nterms++; >- } >- if ($controlnumber) { >- $query .= " \@attr 1=12 \"$controlnumber\" "; >- $nterms++; >- } >- if ($stdid) { >- $query .= " \@attr 1=1007 \"$stdid\" "; >- $nterms++; >- } >- if ($srchany) { >- $query .= " \@attr 1=1016 \"$srchany\" "; >- $nterms++; >- } >-for my $i (1..$nterms-1) { >- $query = "\@and " . $query; >-} >-warn "query ".$query if $DEBUG; >- >- foreach my $servid (@id) { >- my $sth = $dbh->prepare("SELECT * FROM z3950servers WHERE id=? ORDER BY rank, name"); >- $sth->execute($servid); >- while ( $server = $sth->fetchrow_hashref ) { >- warn "serverinfo ".join(':',%$server) if $DEBUG; >- my $option1 = new ZOOM::Options(); >- $option1->option('async' => 1); >- $option1->option('elementSetName', 'F'); >- $option1->option('databaseName', $server->{db}); >- $option1->option('user', $server->{userid} ) if $server->{userid}; >- $option1->option('password', $server->{password}) if $server->{password}; >- $option1->option('preferredRecordSyntax', $server->{syntax}); >- $option1->option( 'timeout', $server->{timeout} ) if ($server->{timeout}); >- $oConnection[$s] = create ZOOM::Connection($option1) >- || $DEBUG >- && warn( "" . $oConnection[$s]->errmsg() ); >- warn( "server data", $server->{name}, $server->{port} ) if $DEBUG; >- $oConnection[$s]->connect( $server->{host}, $server->{port} ) >- || $DEBUG >- && warn( "" . $oConnection[$s]->errmsg() ); >- $serverhost[$s] = $server->{host}; >- $servername[$s] = $server->{name}; >- $encoding[$s] = ($server->{encoding}?$server->{encoding}:"iso-5426"); >- $s++; >- } ## while fetch >- } # foreach >- my $nremaining = $s; >- my $firstresult = 1; >- >- for ( my $z = 0 ; $z < $s ; $z++ ) { >- warn "doing the search" if $DEBUG; >- $oResult[$z] = $oConnection[$z]->search_pqf($query) >- || $DEBUG >- && warn( "somthing went wrong: " . $oConnection[$s]->errmsg() ); >- >- # $oResult[$z] = $oConnection[$z]->search_pqf($query); >- } >- >- AGAIN: >- my $k; >- my $event; >- while ( ( $k = ZOOM::event( \@oConnection ) ) != 0 ) { >- $event = $oConnection[ $k - 1 ]->last_event(); >- warn( "connection ", $k - 1, ": event $event (", >- ZOOM::event_str($event), ")\n" ) >- if $DEBUG; >- last if $event == ZOOM::Event::ZEND; >- } >- >- if ( $k != 0 ) { >- $k--; >- warn $serverhost[$k] if $DEBUG; >- my ( $error, $errmsg, $addinfo, $diagset ) = >- $oConnection[$k]->error_x(); >- if ($error) { >- if ($error =~ m/^(10000|10007)$/ ) { >- push(@errconn, {'server' => $serverhost[$k], 'error' => $error}); >- } >- $DEBUG and warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n"; >- } >- else { >- my $numresults = $oResult[$k]->size(); >- my $i; >- my $result = ''; >- if ( $numresults > 0 ) { >- for ($i = 0; $i < (($numresults < 20) ? $numresults : 20); $i++) { >- my $rec = $oResult[$k]->record($i); >- if ($rec) { >- my $marcrecord; >- $marcdata = $rec->raw(); >- >- my ($charset_result, $charset_errors); >- ($marcrecord, $charset_result, $charset_errors) = >- MarcToUTF8Record($marcdata, C4::Context->preference('marcflavour'), $encoding[$k]); >- SetUTF8Flag($marcrecord); >-####WARNING records coming from Z3950 clients are in various character sets MARC8,UTF8,UNIMARC etc >-## In HEAD i change everything to UTF-8 >-# In rel2_2 i am not sure what encoding is so no character conversion is done here >-##Add necessary encoding changes to here -TG >- my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, "" ); >- $oldbiblio->{isbn} =~ s/ |-|\.//g if $oldbiblio->{isbn}; >- # pad | and ( with spaces to allow line breaks in the HTML >- $oldbiblio->{isbn} =~ s/\|/ \| /g if $oldbiblio->{isbn}; >- $oldbiblio->{isbn} =~ s/\(/ \(/g if $oldbiblio->{isbn}; >- >- $oldbiblio->{issn} =~ s/ |-|\.//g if $oldbiblio->{issn}; >- # pad | and ( with spaces to allow line breaks in the HTML >- $oldbiblio->{issn} =~ s/\|/ \| /g if $oldbiblio->{issn}; >- $oldbiblio->{issn} =~ s/\(/ \(/g if $oldbiblio->{issn}; >- my ( >- $notmarcrecord, $alreadyindb, $alreadyinfarm, >- $imported, $breedingid >- ) >- = ImportBreeding( $marcdata, 2, $serverhost[$k], $encoding[$k], $random, 'z3950' ); >- my %row_data; >- $row_data{server} = $servername[$k]; >- $row_data{isbn} = $oldbiblio->{isbn}; >- $row_data{lccn} = $oldbiblio->{lccn}; >- $row_data{title} = $oldbiblio->{title}; >- $row_data{author} = $oldbiblio->{author}; >- $row_data{date} = $oldbiblio->{copyrightdate}; >- $row_data{edition} = $oldbiblio->{editionstatement}; >- $row_data{breedingid} = $breedingid; >- $row_data{biblionumber} = $biblionumber; >- push( @breeding_loop, \%row_data ); >- >- } else { >- push(@breeding_loop,{'server'=>$servername[$k],'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1,'biblionumber'=>-1}); >- } # $rec >- } >- } #$numresults >- } >- } # if $k !=0 >- $numberpending = $nremaining - 1; >- $template->param( >- breeding_loop => \@breeding_loop, >- server => $servername[$k], >- numberpending => $numberpending, >- biblionumber => $biblionumber, >- errconn => \@errconn >- ); >- >- output_html_with_http_headers $input, $cookie, $template->output if $numberpending == 0; >- >- # print $template->output if $firstresult !=1; >- $firstresult++; >- >- MAYBE_AGAIN: >- if ( --$nremaining > 0 ) { >- goto AGAIN; >- } >+ my $pars= { >+ random => $input->param('random') || rand(1000000000), >+ biblionumber => $biblionumber, >+ id => \@id, >+ isbn => $isbn, >+ title => $title, >+ author => $author, >+ dewey => $dewey, >+ subject => $subject, >+ lccall => $lccall, >+ controlnumber => $controlnumber, >+ stdid => $stdid, >+ srchany => $srchany, >+ }; >+ Z3950Search($pars, $template); >+ output_html_with_http_headers $input, $cookie, $template->output; > } ## if op=search >-- >1.7.7.6
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 6536
:
4540
|
4541
|
4959
|
6901
|
6919
|
6920
|
6924
|
13462
|
26169
|
26170
|
26171
|
26172
|
29754
|
29755
|
29756
|
29779
|
29780
|
29788
|
29790
|
29791
|
29812
|
29813
|
29814
|
29815
|
29816
|
29817
|
29818
|
29819
|
30189
|
30190
|
30191
|
30192
|
30193
|
30194
|
30900
|
30901
|
30902
|
30903
|
30904
|
30905
|
30906
|
30907
|
30929
|
30930
|
30931
|
30932
|
30933
|
30934
|
30935
|
30936
|
31046
|
31048
|
31137
|
31193
|
31194
|
31195
|
31227
|
31247
|
31248
|
37264