Bug 17600: Standardize our EXPORT_OK
[srvgit] / Koha / SearchEngine / Zebra / Indexer.pm
1 package Koha::SearchEngine::Zebra::Indexer;
2
3 # Copyright 2020 ByWater Solutions
4 #
5 # This file is part of Koha.
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 Modern::Perl;
21 use C4::Biblio qw( ModZebra ); # FIXME This is terrible, we should move the indexation code outside of C4::Biblio
22 use base qw(Class::Accessor);
23
24 =head1 NAME
25
26 Koha::SearchEngine::Elasticsearch::Indexer - handles adding new records to the index
27
28 =head1 SYNOPSIS
29
30     my $indexer = Koha::SearchEngine::Zebra::Indexer->new();
31     $indexer->index_records( $record_numbers, $op, $server, $records);
32
33
34 =head1 FUNCTIONS
35
36 =head2 new
37
38     This is a dummy function to create the object. C4::Biblio->ModZebra is doing the real work
39     now and needed variables are passed to index_records
40
41 =cut
42
43 sub new {
44     my $class = shift @_;
45     my $self = $class->SUPER::new(@_);
46 }
47
48 =head2 index_records($record_numbers, $op, $server, $records)
49
50     This is simply a wrapper to C4::Biblio::ModZebra that takes an array of records and
51     passes them through individually
52
53     The final parameter $records is not used in Zebra, it exists for parity with Elasticsearch calls
54
55 =cut
56
57 sub index_records {
58     my ( $self, $record_numbers, $op, $server, $records ) = @_;
59     $record_numbers = [$record_numbers] if ref $record_numbers ne 'ARRAY' && defined $record_numbers;
60     foreach my $record_number ( @$record_numbers ){
61         ModZebra( $record_number, $op, $server );
62     }
63 }
64
65 1;