Bug 18624: Minor refactoring to ease testing

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit ff41b87302)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 4c50a19ab9)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
This commit is contained in:
Tomas Cohen Arazi 2017-08-07 16:07:40 -03:00 committed by Katrin Fischer
parent 98631a3e76
commit 35bbde5093
1 changed files with 14 additions and 13 deletions

View File

@ -47,7 +47,7 @@ use Modern::Perl;
use URI::Escape;
use C4::Context;
use Data::Dumper; # TODO remove
use Koha::Exceptions;
=head2 build_query
@ -408,6 +408,16 @@ appropriate search object.
=cut
our $koha_to_index_name = {
mainmainentry => 'Heading-Main',
mainentry => 'Heading',
match => 'Match',
'match-heading' => 'Match-heading',
'see-from' => 'Match-heading-see-from',
thesaurus => 'Subject-heading-thesaurus',
any => ''
};
sub build_authorities_query_compat {
my ( $self, $marclist, $and_or, $excluding, $operator, $value,
$authtypecode, $orderby )
@ -417,24 +427,15 @@ sub build_authorities_query_compat {
# extensible hash form that is understood by L<build_authorities_query>.
my @searches;
my %koha_to_index_name = (
mainmainentry => 'Heading-Main',
mainentry => 'Heading',
match => 'Match',
'match-heading' => 'Match-heading',
'see-from' => 'Match-heading-see-from',
thesaurus => 'Subject-heading-thesaurus',
any => '',
);
# Make sure everything exists
foreach my $m (@$marclist) {
confess "Invalid marclist field provided: $m" unless exists $koha_to_index_name{$m};
Koha::Exceptions::WrongParameter->throw("Invalid marclist field provided: $m")
unless exists $koha_to_index_name->{$m};
}
for ( my $i = 0 ; $i < @$value ; $i++ ) {
push @searches,
{
where => $koha_to_index_name{$marclist->[$i]},
where => $koha_to_index_name->{$marclist->[$i]},
operator => $operator->[$i],
value => $value->[$i],
};