@@ -, +, @@ Net::Z3950::RPN::* packages --- Koha/Z3950Responder/GenericSession.pm | 1 - Makefile.PL | 1 + Net/Z3950/RPN/And.pm | 57 ++++++++++++++++++++++ Net/Z3950/RPN/AndNot.pm | 53 ++++++++++++++++++++ Net/Z3950/RPN/Or.pm | 53 ++++++++++++++++++++ .../Z3950Responder/RPN.pm => Net/Z3950/RPN/Term.pm | 49 ++++++++----------- 6 files changed, 183 insertions(+), 31 deletions(-) create mode 100644 Net/Z3950/RPN/And.pm create mode 100644 Net/Z3950/RPN/AndNot.pm create mode 100644 Net/Z3950/RPN/Or.pm rename Koha/Z3950Responder/RPN.pm => Net/Z3950/RPN/Term.pm (80%) --- a/Koha/Z3950Responder/GenericSession.pm +++ a/Koha/Z3950Responder/GenericSession.pm @@ -26,7 +26,6 @@ use base qw( Koha::Z3950Responder::Session ); use Koha::Logger; use Koha::SearchEngine::Search; use Koha::SearchEngine::QueryBuilder; -use Koha::Z3950Responder::RPN; =head1 NAME --- a/Makefile.PL +++ a/Makefile.PL @@ -340,6 +340,7 @@ my $target_map = { './koha-tmpl/opac-tmpl' => {target => 'OPAC_TMPL_DIR', trimdir => -1}, './kohaversion.pl' => 'INTRANET_CGI_DIR', './labels' => 'INTRANET_CGI_DIR', + './Net' => 'PERL_MODULE_DIR', './mainpage.pl' => 'INTRANET_CGI_DIR', './Makefile.PL' => 'NONE', './MANIFEST.SKIP' => 'NONE', --- a/Net/Z3950/RPN/And.pm +++ a/Net/Z3950/RPN/And.pm @@ -0,0 +1,57 @@ +# Copyright The National Library of Finland 2018 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +package Net::Z3950::RPN::And; + +use Modern::Perl; +our @ISA = qw(Net::Z3950::RPN::Node); + +=head1 NAME + +Net::Z3950::RPN::And + +=cut + +=head1 SYNOPSIS + +Overrides for the C classes adding a C method that +converts the query to a syntax that C understands. + +=cut + +=head1 DESCRIPTION + +The previous method used is described in C of +C, but Perl critic doesn't like it, so +we are using whole package overrides here. + +=cut + +=head2 to_koha + + Convert query to a syntax that C understands. + +=cut + +sub to_koha { + my ($self, $mappings) = @_; + + return '(' . $self->[0]->to_koha($mappings) . ' AND ' . + $self->[1]->to_koha($mappings) . ')'; +} + +1; --- a/Net/Z3950/RPN/AndNot.pm +++ a/Net/Z3950/RPN/AndNot.pm @@ -0,0 +1,53 @@ +# Copyright The National Library of Finland 2018 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +package Net::Z3950::RPN::AndNot; + +use Modern::Perl; +our @ISA = qw(Net::Z3950::RPN::Node); + +=head1 NAME + +Net::Z3950::RPN::AndNot + +=head1 SYNOPSIS + +Overrides for the C classes adding a C method that +converts the query to a syntax that C understands. + +=head1 DESCRIPTION + +The previous method used is described in C of +C, but Perl critic doesn't like it, so +we are using whole package overrides here. + +=cut + +=head2 to_koha + + Convert query to a syntax that C understands. + +=cut + +sub to_koha { + my ($self, $mappings) = @_; + + return '(' . $self->[0]->to_koha($mappings) . ' NOT ' . + $self->[1]->to_koha($mappings) . ')'; +} + +1; --- a/Net/Z3950/RPN/Or.pm +++ a/Net/Z3950/RPN/Or.pm @@ -0,0 +1,53 @@ +# Copyright The National Library of Finland 2018 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +package Net::Z3950::RPN::Or; + +use Modern::Perl; +our @ISA = qw(Net::Z3950::RPN::Node); + +=head1 NAME + +Net::Z3950::RPN::Or + +=head1 SYNOPSIS + +Overrides for the C classes adding a C method that +converts the query to a syntax that C understands. + +=head1 DESCRIPTION + +The previous method used is described in C of +C, but Perl critic doesn't like it, so +we are using whole package overrides here. + +=cut + +=head2 to_koha + + Convert query to a syntax that C understands. + +=cut + +sub to_koha { + my ($self, $mappings) = @_; + + return '(' . $self->[0]->to_koha($mappings) . ' OR ' . + $self->[1]->to_koha($mappings) . ')'; +} + +1; --- a/Koha/Z3950Responder/RPN.pm +++ a/Koha/Z3950Responder/RPN.pm @@ -1,5 +1,3 @@ -#!/usr/bin/perl - # Copyright The National Library of Finland 2018 # # This file is part of Koha. @@ -17,11 +15,14 @@ # You should have received a copy of the GNU General Public License # along with Koha; if not, see . +package Net::Z3950::RPN::Term; + use Modern::Perl; +our @ISA = qw(Net::Z3950::RPN::Node); =head1 NAME -Koha::Z3950Responder::RPN +Net::Z3950::RPN::Term =head1 SYNOPSIS @@ -30,12 +31,18 @@ converts the query to a syntax that C understands. =head1 DESCRIPTION -The method used here is described in C of -C. +The previous method used is described in C of +C, but Perl critic doesn't like it, so +we are using whole package overrides here. + +=cut + +=head2 to_koha + + Convert query to a syntax that C understands. =cut -package Net::Z3950::RPN::Term; sub to_koha { my ($self, $mappings) = @_; @@ -93,6 +100,12 @@ sub to_koha { return '(' . join(' OR ', @terms) . ')'; } +=head2 escape + + Escape the term + +=cut + sub escape { my ($self, $term) = @_; @@ -100,28 +113,4 @@ sub escape { return $term; } -package Net::Z3950::RPN::And; -sub to_koha { - my ($self, $mappings) = @_; - - return '(' . $self->[0]->to_koha($mappings) . ' AND ' . - $self->[1]->to_koha($mappings) . ')'; -} - -package Net::Z3950::RPN::Or; -sub to_koha { - my ($self, $mappings) = @_; - - return '(' . $self->[0]->to_koha($mappings) . ' OR ' . - $self->[1]->to_koha($mappings) . ')'; -} - -package Net::Z3950::RPN::AndNot; -sub to_koha { - my ($self, $mappings) = @_; - - return '(' . $self->[0]->to_koha($mappings) . ' NOT ' . - $self->[1]->to_koha($mappings) . ')'; -} - 1; --