Bug 11297: Add support for custom PQF attributes for Z39.50 server searches.
authorCharles Farmer <charles.farmer@inLibro.com>
Fri, 10 Aug 2018 21:28:38 +0000 (17:28 -0400)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 19 Feb 2020 16:07:59 +0000 (16:07 +0000)
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 <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/Breeding.pm
admin/z3950servers.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt

index 5d2f49b..c3e6c7c 100644 (file)
@@ -151,10 +151,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++;
@@ -554,12 +558,19 @@ sub Z3950SearchAuth {
         while ( my $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 )));
-            $encoding[$s]   = $server->{encoding} // "iso-5426";
+            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++;
         }   ## while fetch
index cb22666..d2e85c6 100755 (executable)
@@ -67,7 +67,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 ) {
index 9efe6ce..65b996d 100644 (file)
         </li>
         <li><label for="rank">Rank (display order): </label> <input type="text" name="rank" id="rank" size="4" value="[% server.rank | html %]" />
         </li>
+        [% IF (server.servertype||type) == 'zed' %]
+        <li><label for="attributes">Attributes (additional PQF attributes added to each query): </label><input type="text" name="attributes" id="attributes" size="30" value="[% server.attributes %]" />
+        </li>
+        [% END %]
 
         <li><label for="syntax">Syntax (z3950 can send<br /> records in various format. Choose one): </label>
         <select name="syntax" id="syntax">
         You searched for [% searchfield | html %]
     [% END %]
     <table id="serverst">
-        <thead><tr><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Preselected</th><th>Rank</th><th>Syntax</th><th>Encoding</th><th>Timeout</th><th>Record type</th><th></th>
+
+        <thead><tr><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Preselected</th><th>Rank</th><th>Syntax</th><th>Encoding</th><th>Timeout</th><th>Record type</th><th>Attributes</th><th>Options</th>
         </tr></thead>
         <tbody>
         [% FOREACH loo IN loop %]
                 <span>Authority</span>
                 [% END %]
             </td>
+            <td>[% loo.attributes %]</td>
             <td>
                 <div class="dropdown">
                     <a class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown" href="#">
             $(document).ready(function() {
                 $("#serverst").dataTable($.extend(true, {}, dataTablesDefaults, {
                     "aoColumnDefs": [
-                        { "aTargets": [2,3,4,7,8,9,10,11], "bSortable": false, "bSearchable": false },
+                        { "aTargets": [-1], "bSortable": false, "bSearchable": false },
                     ],
                     "sPaginationType": "full"
                 }));