Bug 9728: XISBN use bibliographic search instead of SQL to fetch related bibs

XISBN API uses normalized ISBN of a biblio to get a list of ISBNs
of related editions, then searched via SQL in database for biblios
with those ISBNs.

I noticed that if input ISBN has hyphens, the ISBNs returned by the
OCLC XISBN service also have hyphens; otherwise, if the input ISBN
doesn't have hyphens, the returned ISBNs don't either.

Consequently, an SQL query on biblioitems.isbn may not turn up
the right biblios.

Also, if biblio has several ISBNs, only first one can be found with
the original SQL query (isbn LIKE '$xisbn%').

This patch replaces SQL query by a simple search "nb=$xisbn". This will
find biblio from ISBN with or without hyphen.

Test plan :
- Activate FRBRizeEditions and XISBN sysprefs
- Go to a biblio witch has several editions
- Note its normalized ISBN (you may look in amazon links)
- Replace [ISBN] by biblio normalized ISBN in this URL : http://xisbn.worldcat.org/webservices/xid/isbn/[ISBN]?method=getEditions&format=xml&fl=form,year,lang,ed
- Go to this URL and see which ISBNs are returned
- Perform a simple search on thoses ISBNs : nb:1234567890
- Look at "Editions" tab
=> Check that diplayed biblios are the same you found by simple search

Signed-off-by: jmbroust <jean-manuel.broust@univ-lyon2.fr>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Fridolyn SOMERS 2013-02-28 12:36:24 +01:00 committed by Galen Charlton
parent 85d1e35b6c
commit dd7fbbd70d
1 changed files with 13 additions and 11 deletions

View File

@ -21,6 +21,7 @@ use XML::Simple;
#use LWP::Simple;
use C4::Biblio;
use C4::Koha;
use C4::Search;
use C4::External::Syndetics qw(get_syndetics_editions);
use LWP::UserAgent;
use HTTP::Request::Common;
@ -61,18 +62,19 @@ This module provides facilities for retrieving ThingISBN and XISBN content in Ko
sub _get_biblio_from_xisbn {
my $xisbn = shift;
$xisbn.='%';
my $dbh = C4::Context->dbh;
my $query = "SELECT biblionumber FROM biblioitems WHERE isbn LIKE ?";
my $sth = $dbh->prepare($query);
$sth->execute($xisbn);
my $xbib_data = $sth->fetchrow_hashref();
my $xbiblio;
if ($xbib_data->{biblionumber}) {
$xbiblio = GetBiblioData($xbib_data->{biblionumber});
$xbiblio->{normalized_isbn} = GetNormalizedISBN($xbiblio->{isbn});
}
return ($xbiblio);
my ( $errors, $results, $total_hits ) = SimpleSearch( "nb=$xisbn", 0, 1 );
return unless ( !$errors && scalar @$results );
my $record = MARC::Record::new_from_usmarc( $results->[0] );
my $biblionumber = C4::Biblio::get_koha_field_from_marc('biblio', 'biblionumber', $record, '');
return unless $biblionumber;
my $xbiblio = GetBiblioData($biblionumber);
return unless $xbiblio;
$xbiblio->{normalized_isbn} = GetNormalizedISBN($xbiblio->{isbn});
return $xbiblio;
}
=head1 get_xisbns($isbn);