View | Details | Raw Unified | Return to bug 15187
Collapse All | Expand All

(-)a/Koha/Filter/MARC/Index880InZebra.pm (+88 lines)
Line 0 Link Here
1
package Koha::Filter::MARC::Index880InZebra;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
=head1 NAME
19
20
Koha::Filter::MARC::Index880InZebra - replace 880 with its linked field number
21
so that the alternate graphic representation gets indexed appropriately
22
(see Koha::SearchEngine::Elasticsearch for the ES version)
23
24
=head1 SYNOPSIS
25
26
my $processor = Koha::RecordProcessor->new({ filters => ('Index880InZebra') });
27
28
=head1 DESCRIPTION
29
30
Filter to rewrite 880 to linked field
31
32
=cut
33
34
use Modern::Perl;
35
36
use C4::Context;
37
38
use base qw(Koha::RecordProcessor::Base);
39
our $NAME = 'Index880InZebra';
40
41
our $marcflavour = lc C4::Context->preference('marcflavour');
42
43
=head2 filter
44
45
    my $newrecord = $filter->filter($record);
46
    my $newrecords = $filter->filter(\@records);
47
48
=cut
49
50
sub filter {
51
    my $self = shift;
52
    my $record = shift;
53
    my $newrecord;
54
55
    return unless defined $record;
56
57
    if (ref $record eq 'ARRAY') {
58
        my @recarray;
59
        foreach my $thisrec (@$record) {
60
            push @recarray, _processrecord($thisrec);
61
        }
62
        $newrecord = \@recarray;
63
    } elsif (ref $record eq 'MARC::Record') {
64
        $newrecord = _processrecord($record);
65
    }
66
67
    return $newrecord;
68
}
69
70
sub _processrecord {
71
72
    my $record = shift;
73
    if ($marcflavour && $marcflavour eq 'marc21'){
74
        my @fields = $record->field('880');
75
        foreach my $field (@fields){
76
            my $sub6 = $field->subfield('6');
77
            if ($sub6 =~ /^(...)-\d+/) {
78
                my $tag = $1;
79
                if ($tag){
80
                    $field->set_tag($tag);
81
                }
82
            }
83
        }
84
    }
85
    return $record;
86
}
87
88
1;
(-)a/misc/migration_tools/rebuild_zebra.pl (-1 / +1 lines)
Lines 661-666 sub get_corrected_marc_record { Link Here
661
            push @filters, 'EmbedItemsAvailability';
661
            push @filters, 'EmbedItemsAvailability';
662
            push @filters, 'EmbedSeeFromHeadings'
662
            push @filters, 'EmbedSeeFromHeadings'
663
                if C4::Context->preference('IncludeSeeFromInSearches');
663
                if C4::Context->preference('IncludeSeeFromInSearches');
664
            push @filters, 'Index880InZebra';
664
665
665
            my $normalizer = Koha::RecordProcessor->new( { filters => \@filters } );
666
            my $normalizer = Koha::RecordProcessor->new( { filters => \@filters } );
666
            $marc = $normalizer->process($marc);
667
            $marc = $normalizer->process($marc);
667
- 

Return to bug 15187