Lines 50-76
This module provides facilities for retrieving ThingISBN and XISBN content in Ko
Link Here
|
50 |
|
50 |
|
51 |
=cut |
51 |
=cut |
52 |
|
52 |
|
53 |
sub _get_biblio_from_xisbn { |
53 |
sub _get_biblios_from_xisbn { |
54 |
my $xisbn = shift; |
54 |
my $xisbn = shift; |
55 |
my $dbh = C4::Context->dbh; |
55 |
my $dbh = C4::Context->dbh; |
56 |
|
56 |
|
57 |
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); |
57 |
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); |
58 |
my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( "nb=$xisbn", 0, 1 ); |
58 |
my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( "nb=$xisbn", 0, 50 ); |
59 |
return unless ( !$errors && scalar @$results ); |
59 |
return unless ( !$errors && scalar @$results ); |
60 |
|
60 |
|
61 |
my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[0] ); |
61 |
my @biblios; |
62 |
my $biblionumber = C4::Biblio::TransformMarcToKoha({ |
62 |
for my $result (@$results) { |
63 |
kohafields => ['biblio.biblionumber'], |
63 |
my $record = C4::Search::new_record_from_zebra( 'biblioserver', $result ); |
64 |
record => $record |
64 |
my $biblionumber = C4::Biblio::TransformMarcToKoha({ |
65 |
})->{biblionumber}; |
65 |
kohafields => ['biblio.biblionumber'], |
66 |
return unless $biblionumber; |
66 |
record => $record |
67 |
|
67 |
})->{biblionumber}; |
68 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
68 |
next unless $biblionumber; |
69 |
return unless $biblio; |
69 |
|
70 |
my $isbn = $biblio->biblioitem->isbn; |
70 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
71 |
$biblio = $biblio->unblessed; |
71 |
next unless $biblio; |
72 |
$biblio->{normalized_isbn} = GetNormalizedISBN($isbn); |
72 |
my $isbn = $biblio->biblioitem->isbn; |
73 |
return $biblio; |
73 |
$biblio = $biblio->unblessed; |
|
|
74 |
$biblio->{normalized_isbn} = GetNormalizedISBN($isbn); |
75 |
push(@biblios, $biblio); |
76 |
} |
77 |
return \@biblios; |
74 |
} |
78 |
} |
75 |
|
79 |
|
76 |
=head1 get_xisbns($isbn, $biblionumber); |
80 |
=head1 get_xisbns($isbn, $biblionumber); |
Lines 97-103
sub get_xisbns {
Link Here
|
97 |
$syndetics_response = {isbn => \@syndetics_response}; |
101 |
$syndetics_response = {isbn => \@syndetics_response}; |
98 |
} |
102 |
} |
99 |
|
103 |
|
100 |
$response->{isbn} = [ @{ $syndetics_response->{isbn} or [] }, @{ $thing_response->{isbn} or [] } ]; |
104 |
$response->{isbn} = [{content => $isbn}, @{ $syndetics_response->{isbn} or [] }, @{ $thing_response->{isbn} or [] } ]; |
101 |
my @xisbns; |
105 |
my @xisbns; |
102 |
my $unique_xisbns; # a hashref |
106 |
my $unique_xisbns; # a hashref |
103 |
|
107 |
|
Lines 105-113
sub get_xisbns {
Link Here
|
105 |
for my $response_data( @{ $response->{ isbn } } ) { |
109 |
for my $response_data( @{ $response->{ isbn } } ) { |
106 |
next if $unique_xisbns->{ $response_data->{content} }; |
110 |
next if $unique_xisbns->{ $response_data->{content} }; |
107 |
$unique_xisbns->{ $response_data->{content} }++; |
111 |
$unique_xisbns->{ $response_data->{content} }++; |
108 |
my $xbiblio= _get_biblio_from_xisbn($response_data->{content}); |
112 |
my $xbiblios= _get_biblios_from_xisbn($response_data->{content}); |
109 |
next unless $xbiblio; |
113 |
push @xisbns, grep {$_->{biblionumber} ne $biblionumber} @$xbiblios; |
110 |
push @xisbns, $xbiblio if $xbiblio && $xbiblio->{biblionumber} ne $biblionumber; |
|
|
111 |
} |
114 |
} |
112 |
if ( wantarray ) { |
115 |
if ( wantarray ) { |
113 |
return (\@xisbns, $errors); |
116 |
return (\@xisbns, $errors); |
114 |
- |
|
|