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

(-)a/C4/Matcher.pm (-2 / +15 lines)
Lines 812-824 sub _get_match_keys { Link Here
812
    for (my $i = 0; $i <= $#{ $matchpoint->{'components'} }; $i++) {
812
    for (my $i = 0; $i <= $#{ $matchpoint->{'components'} }; $i++) {
813
        my $component = $matchpoint->{'components'}->[$i];
813
        my $component = $matchpoint->{'components'}->[$i];
814
        my $j = -1;
814
        my $j = -1;
815
        FIELD: foreach my $field ($source_record->field($component->{'tag'})) {
815
816
        my @fields = ();
817
        my $tag = $component->{'tag'};
818
        if ($tag && $tag eq 'LDR'){
819
            $fields[0] = $source_record->leader();
820
        }
821
        else {
822
            @fields = $source_record->field($tag);
823
        }
824
825
        FIELD: foreach my $field (@fields) {
816
            $j++;
826
            $j++;
817
            last FIELD if $j > 0 and $check_only_first_repeat;
827
            last FIELD if $j > 0 and $check_only_first_repeat;
818
            last FIELD if $i > 0 and $j > $#keys;
828
            last FIELD if $i > 0 and $j > $#keys;
819
829
820
            my $string;
830
            my $string;
821
            if ( $field->is_control_field() ) {
831
            if ( ! ref $field ){
832
                $string = "$field";
833
            }
834
            elsif ( $field->is_control_field() ) {
822
                $string = $field->data();
835
                $string = $field->data();
823
            } else {
836
            } else {
824
                $string = $field->as_string(
837
                $string = $field->as_string(
(-)a/t/Matcher.t (-2 / +38 lines)
Lines 27-33 use Module::Load::Conditional qw/check_install/; Link Here
27
27
28
BEGIN {
28
BEGIN {
29
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
29
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
30
        plan tests => 12;
30
        plan tests => 13;
31
    } else {
31
    } else {
32
        plan skip_all => "Need Test::DBIx::Class"
32
        plan skip_all => "Need Test::DBIx::Class"
33
    }
33
    }
Lines 264-269 subtest '_get_match_keys() tests' => sub { Link Here
264
264
265
};
265
};
266
266
267
subtest '_get_match_keys() leader tests' => sub {
268
    plan tests => 2;
269
    my $record = MARC::Record->new();
270
    my $matchpoint = get_leader_matchpoint({
271
        length => 1,
272
        offset => 6,
273
    });
274
275
    my @keys = C4::Matcher::_get_match_keys( $record, $matchpoint );
276
    is( $keys[0], ' ', 'Match key correctly calculated as " " from LDR6 when no leader available');
277
278
    $record->leader('01344cam a22003014a 4500');
279
280
    @keys = C4::Matcher::_get_match_keys( $record, $matchpoint );
281
    is( $keys[0], 'a', 'Match key correctly calculated as "a" from LDR6');
282
};
283
267
sub get_title_matchpoint {
284
sub get_title_matchpoint {
268
285
269
    my $params = shift;
286
    my $params = shift;
Lines 358-360 sub get_isbn_matchpoint { Link Here
358
375
359
    return $matchpoint;
376
    return $matchpoint;
360
}
377
}
361
- 
378
379
sub get_leader_matchpoint {
380
    my $params = shift;
381
    my $length = $params->{length} // 0;
382
    my $norms  = $params->{norms}  // [];
383
    my $offset = $params->{offset} // 0;
384
385
    my $matchpoint = {
386
        components =>  [
387
            {
388
                length    => $length,
389
                norms     => $norms,
390
                offset    => $offset,
391
                tag => 'LDR'
392
            },
393
        ],
394
    };
395
396
    return $matchpoint;
397
}

Return to bug 26199