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

(-)a/Koha/Biblio.pm (-1 / +1 lines)
Lines 1321-1327 Normalizes and returns the OCLC number found in the MARC record. Link Here
1321
sub normalized_oclc {
1321
sub normalized_oclc {
1322
    my ($self) = @_;
1322
    my ($self) = @_;
1323
    my $marc_record = $self->metadata->record;
1323
    my $marc_record = $self->metadata->record;
1324
    return C4::Koha::GetNormalizedOCLCNumber($marc_record);
1324
    return $self->metadata_extractor->get_normalized_oclc;
1325
}
1325
}
1326
1326
1327
=head3 to_api
1327
=head3 to_api
(-)a/Koha/Biblio/Metadata/Extractor/MARC/MARC21.pm (+22 lines)
Lines 74-79 sub get_normalized_upc { Link Here
74
    }
74
    }
75
}
75
}
76
76
77
=head2 get_normalized_oclc
78
79
    my $normalized_oclc = $extractor->get_normalized_oclc();
80
81
Returns a normalized OCLC number.
82
83
=cut
84
85
sub get_normalized_oclc {
86
    my ($self) = @_;
87
88
    my $record = $self->metadata;
89
    my @fields = $record->field('035');
90
    foreach my $field (@fields) {
91
        my $oclc = $field->subfield('a');
92
        if ( $oclc && $oclc =~ /OCoLC/ ) {
93
            $oclc =~ s/\(OCoLC\)//;
94
            return $oclc;
95
        }
96
    }
97
}
98
77
=head1 AUTHOR
99
=head1 AUTHOR
78
100
79
Tomas Cohen Arazi, E<lt>tomascohen@theke.ioE<gt>
101
Tomas Cohen Arazi, E<lt>tomascohen@theke.ioE<gt>
(-)a/t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t (-2 / +18 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 2;
22
use Test::More tests => 3;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
Lines 69-71 subtest 'get_normalized_upc() tests' => sub { Link Here
69
    is( $extractor->get_normalized_upc, "" );
69
    is( $extractor->get_normalized_upc, "" );
70
70
71
};
71
};
72
- 
72
73
subtest 'get_normalized_oclc() tests' => sub {
74
75
    plan tests => 2;
76
77
    my $record = MARC::Record->new();
78
    $record->append_fields( MARC::Field->new( '035', ' ', ' ', a => "(OCoLC)902632762" ) );
79
80
    my $extractor = Koha::Biblio::Metadata::Extractor->new( { metadata => $record } );
81
    is( $extractor->get_normalized_oclc, '902632762' );
82
83
    $record    = MARC::Record->new();
84
    $extractor = Koha::Biblio::Metadata::Extractor->new( { metadata => $record } );
85
86
    is( $extractor->get_normalized_oclc, "" );
87
88
};

Return to bug 34828