Lines 690-696
sub BatchCommitRecords {
Link Here
|
690 |
} elsif ($record_result eq 'ignore') { |
690 |
} elsif ($record_result eq 'ignore') { |
691 |
$recordid = $record_match; |
691 |
$recordid = $record_match; |
692 |
$num_ignored++; |
692 |
$num_ignored++; |
693 |
$recordid = $record_match; |
|
|
694 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
693 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
695 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
694 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
696 |
$num_items_added += $bib_items_added; |
695 |
$num_items_added += $bib_items_added; |
Lines 1179-1184
sub GetBestRecordMatch {
Link Here
|
1179 |
WHERE import_record_matches.import_record_id = ? AND |
1178 |
WHERE import_record_matches.import_record_id = ? AND |
1180 |
( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR |
1179 |
( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR |
1181 |
(import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) ) |
1180 |
(import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) ) |
|
|
1181 |
AND chosen = 1 |
1182 |
ORDER BY score DESC, candidate_match_id DESC"); |
1182 |
ORDER BY score DESC, candidate_match_id DESC"); |
1183 |
$sth->execute($import_record_id); |
1183 |
$sth->execute($import_record_id); |
1184 |
my ($record_id) = $sth->fetchrow_array(); |
1184 |
my ($record_id) = $sth->fetchrow_array(); |
Lines 1459-1470
sub GetImportRecordMatches {
Link Here
|
1459 |
my $dbh = C4::Context->dbh; |
1459 |
my $dbh = C4::Context->dbh; |
1460 |
# FIXME currently biblio only |
1460 |
# FIXME currently biblio only |
1461 |
my $sth = $dbh->prepare_cached("SELECT title, author, biblionumber, |
1461 |
my $sth = $dbh->prepare_cached("SELECT title, author, biblionumber, |
1462 |
candidate_match_id, score, record_type |
1462 |
candidate_match_id, score, record_type, |
|
|
1463 |
chosen |
1463 |
FROM import_records |
1464 |
FROM import_records |
1464 |
JOIN import_record_matches USING (import_record_id) |
1465 |
JOIN import_record_matches USING (import_record_id) |
1465 |
LEFT JOIN biblio ON (biblionumber = candidate_match_id) |
1466 |
LEFT JOIN biblio ON (biblionumber = candidate_match_id) |
1466 |
WHERE import_record_id = ? |
1467 |
WHERE import_record_id = ? |
1467 |
ORDER BY score DESC, biblionumber DESC"); |
1468 |
ORDER BY score DESC, chosen DESC, biblionumber DESC"); |
1468 |
$sth->bind_param(1, $import_record_id); |
1469 |
$sth->bind_param(1, $import_record_id); |
1469 |
my $results = []; |
1470 |
my $results = []; |
1470 |
$sth->execute(); |
1471 |
$sth->execute(); |
Lines 1497-1506
sub SetImportRecordMatches {
Link Here
|
1497 |
$delsth->execute($import_record_id); |
1498 |
$delsth->execute($import_record_id); |
1498 |
$delsth->finish(); |
1499 |
$delsth->finish(); |
1499 |
|
1500 |
|
1500 |
my $sth = $dbh->prepare("INSERT INTO import_record_matches (import_record_id, candidate_match_id, score) |
1501 |
my $sth = $dbh->prepare("INSERT INTO import_record_matches (import_record_id, candidate_match_id, score, chosen) |
1501 |
VALUES (?, ?, ?)"); |
1502 |
VALUES (?, ?, ?, ?)"); |
|
|
1503 |
my $chosen = 1; #The first match is defaulted to be chosen |
1502 |
foreach my $match (@matches) { |
1504 |
foreach my $match (@matches) { |
1503 |
$sth->execute($import_record_id, $match->{'record_id'}, $match->{'score'}); |
1505 |
$sth->execute($import_record_id, $match->{'record_id'}, $match->{'score'}, $chosen); |
|
|
1506 |
$chosen = 0; #After the first we do not default to other matches |
1504 |
} |
1507 |
} |
1505 |
} |
1508 |
} |
1506 |
|
1509 |
|
Lines 1717-1757
sub _get_commit_action {
Link Here
|
1717 |
if ($record_type eq 'biblio') { |
1720 |
if ($record_type eq 'biblio') { |
1718 |
my ($bib_result, $bib_match, $item_result); |
1721 |
my ($bib_result, $bib_match, $item_result); |
1719 |
|
1722 |
|
1720 |
if ($overlay_status ne 'no_match') { |
1723 |
$bib_match = GetBestRecordMatch($import_record_id); |
1721 |
$bib_match = GetBestRecordMatch($import_record_id); |
1724 |
if ($overlay_status ne 'no_match' && defined($bib_match)) { |
1722 |
if ($overlay_action eq 'replace') { |
1725 |
|
1723 |
$bib_result = defined($bib_match) ? 'replace' : 'create_new'; |
1726 |
$bib_result = $overlay_action; |
1724 |
} elsif ($overlay_action eq 'create_new') { |
1727 |
|
1725 |
$bib_result = 'create_new'; |
1728 |
if($item_action eq 'always_add' or $item_action eq 'add_only_for_matches'){ |
1726 |
} elsif ($overlay_action eq 'ignore') { |
|
|
1727 |
$bib_result = 'ignore'; |
1728 |
} |
1729 |
if($item_action eq 'always_add' or $item_action eq 'add_only_for_matches'){ |
1730 |
$item_result = 'create_new'; |
1729 |
$item_result = 'create_new'; |
1731 |
} |
1730 |
} elsif($item_action eq 'replace'){ |
1732 |
elsif($item_action eq 'replace'){ |
1731 |
$item_result = 'replace'; |
1733 |
$item_result = 'replace'; |
1732 |
} else { |
1734 |
} |
1733 |
$item_result = 'ignore'; |
1735 |
else { |
1734 |
} |
1736 |
$item_result = 'ignore'; |
1735 |
|
1737 |
} |
|
|
1738 |
} else { |
1736 |
} else { |
1739 |
$bib_result = $nomatch_action; |
1737 |
$bib_result = $nomatch_action; |
1740 |
$item_result = ($item_action eq 'always_add' or $item_action eq 'add_only_for_new') ? 'create_new' : 'ignore'; |
1738 |
$item_result = ($item_action eq 'always_add' or $item_action eq 'add_only_for_new') ? 'create_new' : 'ignore'; |
1741 |
} |
1739 |
} |
1742 |
return ($bib_result, $item_result, $bib_match); |
1740 |
return ($bib_result, $item_result, $bib_match); |
1743 |
} else { # must be auths |
1741 |
} else { # must be auths |
1744 |
my ($auth_result, $auth_match); |
1742 |
my ($auth_result, $auth_match); |
1745 |
|
1743 |
|
1746 |
if ($overlay_status ne 'no_match') { |
1744 |
$auth_match = GetBestRecordMatch($import_record_id); |
1747 |
$auth_match = GetBestRecordMatch($import_record_id); |
1745 |
if ($overlay_status ne 'no_match' && defined($auth_match)) { |
1748 |
if ($overlay_action eq 'replace') { |
1746 |
$auth_result = $overlay_action; |
1749 |
$auth_result = defined($auth_match) ? 'replace' : 'create_new'; |
|
|
1750 |
} elsif ($overlay_action eq 'create_new') { |
1751 |
$auth_result = 'create_new'; |
1752 |
} elsif ($overlay_action eq 'ignore') { |
1753 |
$auth_result = 'ignore'; |
1754 |
} |
1755 |
} else { |
1747 |
} else { |
1756 |
$auth_result = $nomatch_action; |
1748 |
$auth_result = $nomatch_action; |
1757 |
} |
1749 |
} |