From 7820f6e0c091afe1e759c8cdfc94033d99db4549 Mon Sep 17 00:00:00 2001 From: Charles Farmer Date: Fri, 10 Aug 2018 17:28:38 -0400 Subject: [PATCH] Bug 11297: Add support for custom PQF attributes for Z39.50 server searches. Adds the "Attributes" field to z3950 servers. The feature here is not quite de same. In the old patches, the attributes were applied to individual query parts if the part already contains "@attr" and the additionnal attribute is not already in the query part. Here, the content of the new field is prepended to all PQF queries sent to the server. This new way of doing is simpler and works for the sponsor. Test plan: I) Apply the patch II) Run updatedatabase.pl 1) Add a new z3950 server with the following parameters: Hostname : catalogue.banq.qc.ca Port : 210 Database : IRIS Syntax : Marc21 2) Perform a z3950 search on that server. Keyword (Any) : egypt 2.1) Nothing Found. 3) Add attributes on the server administration page @attr 4=1 4) Perform the same z3950 search 4.1) A lot of results Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- C4/Breeding.pm | 23 ++++++++++++++----- admin/z3950servers.pl | 2 +- .../prog/en/modules/admin/z3950servers.tt | 10 ++++++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/C4/Breeding.pm b/C4/Breeding.pm index 9afd2f123d..8de7d1840d 100644 --- a/C4/Breeding.pm +++ b/C4/Breeding.pm @@ -157,10 +157,14 @@ sub Z3950Search { ); my @servers = $rs->all; foreach my $server ( @servers ) { + my $server_zquery = $zquery; + if(my $attributes = $server->{attributes}){ + $server_zquery = "$attributes $zquery"; + } $oConnection[$s] = _create_connection( $server ); $oResult[$s] = $server->{servertype} eq 'zed'? - $oConnection[$s]->search_pqf( $zquery ): + $oConnection[$s]->search_pqf( $server_zquery ): $oConnection[$s]->search(new ZOOM::Query::CQL( _translate_query( $server, $squery ))); $s++; @@ -614,11 +618,18 @@ sub Z3950SearchAuth { while ( $server = $sth->fetchrow_hashref ) { $oConnection[$s] = _create_connection( $server ); - $oResult[$s] = - $server->{servertype} eq 'zed'? - $oConnection[$s]->search_pqf( $zquery ): - $oConnection[$s]->search(new ZOOM::Query::CQL( - _translate_query( $server, $squery ))); + if ( $server->{servertype} eq 'zed' ) { + my $server_zquery = $zquery; + if ( my $attributes = $server->{attributes} ) { + $server_zquery = "$attributes $zquery"; + } + $oResult[$s] = $oConnection[$s]->search_pqf( $server_zquery ); + } + else { + $oResult[$s] = $oConnection[$s]->search( + new ZOOM::Query::CQL(_translate_query( $server, $squery )) + ); + } $encoding[$s] = ($server->{encoding}?$server->{encoding}:"iso-5426"); $servers[$s] = $server; $s++; diff --git a/admin/z3950servers.pl b/admin/z3950servers.pl index d1fe85b2f0..8e085edc45 100755 --- a/admin/z3950servers.pl +++ b/admin/z3950servers.pl @@ -66,7 +66,7 @@ if( $op eq 'delete_confirmed' && $id ) { $id = 0; } elsif ( $op eq 'add_validated' ) { my @fields=qw/host port db userid password rank syntax encoding timeout - recordtype checked servername servertype sru_options sru_fields + recordtype checked servername servertype sru_options sru_fields attributes add_xslt/; my $formdata = _form_data_hashref( $input, \@fields ); if( $id ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt index c027fbd19b..add64cee93 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt @@ -86,6 +86,10 @@
  • + [% IF (server.servertype||type) == 'zed' %] +
  • +
  • + [% END %]