From b19d538a14d382bd8405a2ec0ee4be02e3eb8368 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Fri, 29 Jan 2016 15:56:20 -0700 Subject: [PATCH] Bug 19269: Rancor - Add LCCN, pubdate to indexing Also, fix control number updating for updated records --- C4/ImportBatch.pm | 24 ++++++++++++++---------- Koha/MetaSearcher.pm | 2 ++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index b3d0564..87f4933 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -1661,15 +1661,11 @@ sub _add_auth_fields { sub _add_biblio_fields { my ($import_record_id, $marc_record) = @_; - my $controlnumber; - if ($marc_record->field('001')) { - $controlnumber = $marc_record->field('001')->data(); - } - my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record); + my ($title, $author, $isbn, $issn, $controlnumber, $lccn, $pubdate) = _parse_biblio_fields($marc_record); my $dbh = C4::Context->dbh; # FIXME no originalsource $isbn = C4::Koha::GetNormalizedISBN($isbn); - my $sth = $dbh->prepare("INSERT INTO import_biblios (import_record_id, title, author, isbn, issn, control_number) VALUES (?, ?, ?, ?, ?, ?)"); + my $sth = $dbh->prepare("INSERT INTO import_biblios (import_record_id, title, author, isbn, issn, control_number, lccn, pubdate) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); $sth->execute($import_record_id, $title, $author, $isbn, $issn, $controlnumber); $sth->finish(); @@ -1678,14 +1674,14 @@ sub _add_biblio_fields { sub _update_biblio_fields { my ($import_record_id, $marc_record) = @_; - my ($title, $author, $isbn, $issn) = _parse_biblio_fields($marc_record); + my ($title, $author, $isbn, $issn, $controlnumber, $lccn, $pubdate) = _parse_biblio_fields($marc_record); my $dbh = C4::Context->dbh; # FIXME no originalsource # FIXME 2 - should regularize normalization of ISBN wherever it is done $isbn = C4::Koha::GetNormalizedISBN($isbn); - my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ? + my $sth = $dbh->prepare("UPDATE import_biblios SET title = ?, author = ?, isbn = ?, issn = ?, control_number = ?, lccn = ?, pubdate = ? WHERE import_record_id = ?"); - $sth->execute($title, $author, $isbn, $issn, $import_record_id); + $sth->execute($title, $author, $isbn, $issn, $controlnumber, $lccn, $pubdate$import_record_id); $sth->finish(); } @@ -1694,7 +1690,15 @@ sub _parse_biblio_fields { my $dbh = C4::Context->dbh; my $bibliofields = TransformMarcToKoha($marc_record, ''); - return ($bibliofields->{'title'}, $bibliofields->{'author'}, $bibliofields->{'isbn'}, $bibliofields->{'issn'}); + my $controlnumber; + if ($marc_record->field('001')) { + $controlnumber = $marc_record->field('001')->data(); + } + my $pubdate; + if ($marc_record->field('008')) { + $pubdate = substr( $marc_record->field('008')->data(), 7, 4 ); + } + return ($bibliofields->{'title'}, $bibliofields->{'author'}, $bibliofields->{'isbn'}, $bibliofields->{'issn'}, $contralnumber, $bibliofields->{'lccn'}, $pubdate); } diff --git a/Koha/MetaSearcher.pm b/Koha/MetaSearcher.pm index bff7ce3..44e2f8d 100644 --- a/Koha/MetaSearcher.pm +++ b/Koha/MetaSearcher.pm @@ -205,6 +205,8 @@ our $_batch_db_mapping = { issn => 'import_biblios.issn', 'local-number' => 'import_biblios.control_number', title => 'import_biblios.title', + lccn => 'import_biblios.lccn', + date => 'import_biblios.pubdate', }; our $_batch_db_text_columns = { -- 2.7.4