Lines 577-585
sub BatchCommitRecords {
Link Here
|
577 |
my $num_ignored = 0; |
577 |
my $num_ignored = 0; |
578 |
# commit (i.e., save, all records in the batch) |
578 |
# commit (i.e., save, all records in the batch) |
579 |
SetImportBatchStatus('importing'); |
579 |
SetImportBatchStatus('importing'); |
580 |
my $overlay_action = GetImportBatchOverlayAction($batch_id); |
580 |
my $batch = GetImportBatch( $batch_id ); |
581 |
my $nomatch_action = GetImportBatchNoMatchAction($batch_id); |
581 |
my $overlay_action = $batch->{overlay_action}; |
582 |
my $item_action = GetImportBatchItemAction($batch_id); |
582 |
my $nomatch_action = $batch->{nomatch_action}; |
|
|
583 |
my $item_action = $batch->{item_action}; |
583 |
my $item_tag; |
584 |
my $item_tag; |
584 |
my $item_subfield; |
585 |
my $item_subfield; |
585 |
my $dbh = C4::Context->dbh; |
586 |
my $dbh = C4::Context->dbh; |
Lines 591-596
sub BatchCommitRecords {
Link Here
|
591 |
$sth->execute($batch_id); |
592 |
$sth->execute($batch_id); |
592 |
my $marcflavour = C4::Context->preference('marcflavour'); |
593 |
my $marcflavour = C4::Context->preference('marcflavour'); |
593 |
my $rec_num = 0; |
594 |
my $rec_num = 0; |
|
|
595 |
my $index; |
596 |
$index = $batch->{record_type} eq 'biblio' ? |
597 |
$Koha::SearchEngine::BIBLIOS_INDEX : $Koha::SearchEngine::AUTHORITIES_INDEX; |
598 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $index }); |
594 |
while (my $rowref = $sth->fetchrow_hashref) { |
599 |
while (my $rowref = $sth->fetchrow_hashref) { |
595 |
$record_type = $rowref->{'record_type'}; |
600 |
$record_type = $rowref->{'record_type'}; |
596 |
$rec_num++; |
601 |
$rec_num++; |
Lines 630-643
sub BatchCommitRecords {
Link Here
|
630 |
$num_added++; |
635 |
$num_added++; |
631 |
if ($record_type eq 'biblio') { |
636 |
if ($record_type eq 'biblio') { |
632 |
my $biblioitemnumber; |
637 |
my $biblioitemnumber; |
633 |
($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework); |
638 |
($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework, { skip_record_index => 1 }); |
634 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; |
639 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; |
635 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
640 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
636 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
641 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result, { skip_record_index => 1 }); |
637 |
$num_items_added += $bib_items_added; |
642 |
$num_items_added += $bib_items_added; |
638 |
$num_items_replaced += $bib_items_replaced; |
643 |
$num_items_replaced += $bib_items_replaced; |
639 |
$num_items_errored += $bib_items_errored; |
644 |
$num_items_errored += $bib_items_errored; |
640 |
} |
645 |
} |
|
|
646 |
$indexer->index_records( $recordid, "specialUpdate", "biblioserver" ); |
641 |
} else { |
647 |
} else { |
642 |
$recordid = AddAuthority($marc_record, undef, GuessAuthTypeCode($marc_record)); |
648 |
$recordid = AddAuthority($marc_record, undef, GuessAuthTypeCode($marc_record)); |
643 |
$query = "UPDATE import_auths SET matched_authid = ? WHERE import_record_id = ?"; |
649 |
$query = "UPDATE import_auths SET matched_authid = ? WHERE import_record_id = ?"; |
Lines 663-681
sub BatchCommitRecords {
Link Here
|
663 |
} |
669 |
} |
664 |
$oldxml = $old_marc->as_xml($marc_type); |
670 |
$oldxml = $old_marc->as_xml($marc_type); |
665 |
|
671 |
|
666 |
ModBiblio($marc_record, $recordid, $oldbiblio->frameworkcode); |
672 |
ModBiblio($marc_record, $recordid, $oldbiblio->frameworkcode, { skip_record_index => 1 }); |
667 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; |
673 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; |
668 |
|
674 |
|
669 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
675 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
670 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
676 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result, { skip_record_index => 1}); |
671 |
$num_items_added += $bib_items_added; |
677 |
$num_items_added += $bib_items_added; |
672 |
$num_items_replaced += $bib_items_replaced; |
678 |
$num_items_replaced += $bib_items_replaced; |
673 |
$num_items_errored += $bib_items_errored; |
679 |
$num_items_errored += $bib_items_errored; |
674 |
} |
680 |
} |
|
|
681 |
$indexer->index_records( $recordid, "specialUpdate", "biblioserver" ); |
675 |
} else { |
682 |
} else { |
676 |
$oldxml = GetAuthorityXML($recordid); |
683 |
$oldxml = GetAuthorityXML($recordid); |
677 |
|
684 |
|
678 |
ModAuthority($recordid, $marc_record, GuessAuthTypeCode($marc_record)); |
685 |
ModAuthority($recordid, $marc_record, GuessAuthTypeCode($marc_record) ); |
679 |
$query = "UPDATE import_auths SET matched_authid = ? WHERE import_record_id = ?"; |
686 |
$query = "UPDATE import_auths SET matched_authid = ? WHERE import_record_id = ?"; |
680 |
} |
687 |
} |
681 |
my $sth = $dbh->prepare_cached("UPDATE import_records SET marcxml_old = ? WHERE import_record_id = ?"); |
688 |
my $sth = $dbh->prepare_cached("UPDATE import_records SET marcxml_old = ? WHERE import_record_id = ?"); |
Lines 691-697
sub BatchCommitRecords {
Link Here
|
691 |
$num_ignored++; |
698 |
$num_ignored++; |
692 |
$recordid = $record_match; |
699 |
$recordid = $record_match; |
693 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
700 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
694 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
701 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result, { skip_record_index =>1 }); |
695 |
$num_items_added += $bib_items_added; |
702 |
$num_items_added += $bib_items_added; |
696 |
$num_items_replaced += $bib_items_replaced; |
703 |
$num_items_replaced += $bib_items_replaced; |
697 |
$num_items_errored += $bib_items_errored; |
704 |
$num_items_errored += $bib_items_errored; |
Lines 700-705
sub BatchCommitRecords {
Link Here
|
700 |
my $sth2 = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"); |
707 |
my $sth2 = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"); |
701 |
$sth2->execute($recordid, $rowref->{'import_record_id'}); |
708 |
$sth2->execute($recordid, $rowref->{'import_record_id'}); |
702 |
SetImportRecordOverlayStatus($rowref->{'import_record_id'}, 'match_applied'); |
709 |
SetImportRecordOverlayStatus($rowref->{'import_record_id'}, 'match_applied'); |
|
|
710 |
$indexer->index_records( $recordid, "specialUpdate", "biblioserver" ); |
703 |
} |
711 |
} |
704 |
SetImportRecordStatus($rowref->{'import_record_id'}, 'ignored'); |
712 |
SetImportRecordStatus($rowref->{'import_record_id'}, 'ignored'); |
705 |
} |
713 |
} |
Lines 750-756
sub BatchCommitItems {
Link Here
|
750 |
my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?"); |
758 |
my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?"); |
751 |
if ( $action eq "replace" && $duplicate_itemnumber ) { |
759 |
if ( $action eq "replace" && $duplicate_itemnumber ) { |
752 |
# Duplicate itemnumbers have precedence, that way we can update barcodes by overlaying |
760 |
# Duplicate itemnumbers have precedence, that way we can update barcodes by overlaying |
753 |
ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber} ); |
761 |
ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber},{ skip_record_index => 1 } ); |
754 |
$updsth->bind_param( 1, 'imported' ); |
762 |
$updsth->bind_param( 1, 'imported' ); |
755 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
763 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
756 |
$updsth->bind_param( 3, $row->{'import_items_id'} ); |
764 |
$updsth->bind_param( 3, $row->{'import_items_id'} ); |
Lines 759-765
sub BatchCommitItems {
Link Here
|
759 |
$num_items_replaced++; |
767 |
$num_items_replaced++; |
760 |
} elsif ( $action eq "replace" && $duplicate_barcode ) { |
768 |
} elsif ( $action eq "replace" && $duplicate_barcode ) { |
761 |
my $itemnumber = $duplicate_barcode->itemnumber; |
769 |
my $itemnumber = $duplicate_barcode->itemnumber; |
762 |
ModItemFromMarc( $item_marc, $biblionumber, $itemnumber ); |
770 |
ModItemFromMarc( $item_marc, $biblionumber, $itemnumber, { skip_record_index => 1} ); |
763 |
$updsth->bind_param( 1, 'imported' ); |
771 |
$updsth->bind_param( 1, 'imported' ); |
764 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
772 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
765 |
$updsth->bind_param( 3, $row->{'import_items_id'} ); |
773 |
$updsth->bind_param( 3, $row->{'import_items_id'} ); |
Lines 773-779
sub BatchCommitItems {
Link Here
|
773 |
$updsth->execute(); |
781 |
$updsth->execute(); |
774 |
$num_items_errored++; |
782 |
$num_items_errored++; |
775 |
} else { |
783 |
} else { |
776 |
my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber ); |
784 |
my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber, { skip_record_index => 1 } ); |
777 |
if( $itemnumber ) { |
785 |
if( $itemnumber ) { |
778 |
$updsth->bind_param( 1, 'imported' ); |
786 |
$updsth->bind_param( 1, 'imported' ); |
779 |
$updsth->bind_param( 2, $itemnumber ); |
787 |
$updsth->bind_param( 2, $itemnumber ); |
780 |
- |
|
|