7577bc4a624d011df0f2318efa173a8538b8860a
[koha-equinox.git] / Koha / QueryParser / Driver / PQF / query_plan / modifier.pm
1 package Koha::QueryParser::Driver::PQF::query_plan::modifier;
2
3 # This file is part of Koha.
4 #
5 # Copyright 2012 C & P Bibliography Services
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use base 'OpenILS::QueryParser::query_plan::modifier';
21
22 use strict;
23 use warnings;
24
25 =head1 NAME
26
27 Koha::QueryParser::Driver::PQF::query_plan::modifer - modifier subclass for PQF driver
28
29 =head1 FUNCTIONS
30
31 =head2 Koha::QueryParser::Driver::PQF::query_plan::modifier::target_syntax
32
33     my $pqf = $modifier->target_syntax($server, $query_plan);
34
35 Transforms an OpenILS::QueryParser::query_plan::modifier object into PQF. Do not use
36 directly. The second argument points ot the query_plan, since modifiers do
37 not have a reference to their parent query_plan.
38
39 =cut
40
41 sub target_syntax {
42     my ($self, $server, $query_plan) = @_;
43     my $pqf = '';
44     my @fields;
45
46     my $attributes = $query_plan->QueryParser->bib1_mapping_by_name('modifier', $self->name, $server);
47     $pqf = ($attributes->{'op'} ? $attributes->{'op'} . ' ' : '') . ($self->negate ? '@not @attr 1=_ALLRECORDS @attr 2=103 "" ' : '') . $attributes->{'attr_string'};
48     return $pqf;
49 }
50
51 1;