Lines 701-707
sub BatchCommitRecords {
Link Here
|
701 |
} elsif ($record_result eq 'ignore') { |
701 |
} elsif ($record_result eq 'ignore') { |
702 |
$recordid = $record_match; |
702 |
$recordid = $record_match; |
703 |
$num_ignored++; |
703 |
$num_ignored++; |
704 |
$recordid = $record_match; |
|
|
705 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
704 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
706 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
705 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
707 |
$num_items_added += $bib_items_added; |
706 |
$num_items_added += $bib_items_added; |
Lines 1190-1195
sub GetBestRecordMatch {
Link Here
|
1190 |
WHERE import_record_matches.import_record_id = ? AND |
1189 |
WHERE import_record_matches.import_record_id = ? AND |
1191 |
( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR |
1190 |
( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR |
1192 |
(import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) ) |
1191 |
(import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) ) |
|
|
1192 |
AND chosen = 1 |
1193 |
ORDER BY score DESC, candidate_match_id DESC"); |
1193 |
ORDER BY score DESC, candidate_match_id DESC"); |
1194 |
$sth->execute($import_record_id); |
1194 |
$sth->execute($import_record_id); |
1195 |
my ($record_id) = $sth->fetchrow_array(); |
1195 |
my ($record_id) = $sth->fetchrow_array(); |
Lines 1470-1481
sub GetImportRecordMatches {
Link Here
|
1470 |
my $dbh = C4::Context->dbh; |
1470 |
my $dbh = C4::Context->dbh; |
1471 |
# FIXME currently biblio only |
1471 |
# FIXME currently biblio only |
1472 |
my $sth = $dbh->prepare_cached("SELECT title, author, biblionumber, |
1472 |
my $sth = $dbh->prepare_cached("SELECT title, author, biblionumber, |
1473 |
candidate_match_id, score, record_type |
1473 |
candidate_match_id, score, record_type, |
|
|
1474 |
chosen |
1474 |
FROM import_records |
1475 |
FROM import_records |
1475 |
JOIN import_record_matches USING (import_record_id) |
1476 |
JOIN import_record_matches USING (import_record_id) |
1476 |
LEFT JOIN biblio ON (biblionumber = candidate_match_id) |
1477 |
LEFT JOIN biblio ON (biblionumber = candidate_match_id) |
1477 |
WHERE import_record_id = ? |
1478 |
WHERE import_record_id = ? |
1478 |
ORDER BY score DESC, biblionumber DESC"); |
1479 |
ORDER BY score DESC, chosen DESC, biblionumber DESC"); |
1479 |
$sth->bind_param(1, $import_record_id); |
1480 |
$sth->bind_param(1, $import_record_id); |
1480 |
my $results = []; |
1481 |
my $results = []; |
1481 |
$sth->execute(); |
1482 |
$sth->execute(); |
Lines 1508-1517
sub SetImportRecordMatches {
Link Here
|
1508 |
$delsth->execute($import_record_id); |
1509 |
$delsth->execute($import_record_id); |
1509 |
$delsth->finish(); |
1510 |
$delsth->finish(); |
1510 |
|
1511 |
|
1511 |
my $sth = $dbh->prepare("INSERT INTO import_record_matches (import_record_id, candidate_match_id, score) |
1512 |
my $sth = $dbh->prepare("INSERT INTO import_record_matches (import_record_id, candidate_match_id, score, chosen) |
1512 |
VALUES (?, ?, ?)"); |
1513 |
VALUES (?, ?, ?, ?)"); |
|
|
1514 |
my $chosen = 1; #The first match is defaulted to be chosen |
1513 |
foreach my $match (@matches) { |
1515 |
foreach my $match (@matches) { |
1514 |
$sth->execute($import_record_id, $match->{'record_id'}, $match->{'score'}); |
1516 |
$sth->execute($import_record_id, $match->{'record_id'}, $match->{'score'}, $chosen); |
|
|
1517 |
$chosen = 0; #After the first we do not default to other matches |
1515 |
} |
1518 |
} |
1516 |
} |
1519 |
} |
1517 |
|
1520 |
|
Lines 1728-1768
sub _get_commit_action {
Link Here
|
1728 |
if ($record_type eq 'biblio') { |
1731 |
if ($record_type eq 'biblio') { |
1729 |
my ($bib_result, $bib_match, $item_result); |
1732 |
my ($bib_result, $bib_match, $item_result); |
1730 |
|
1733 |
|
1731 |
if ($overlay_status ne 'no_match') { |
1734 |
$bib_match = GetBestRecordMatch($import_record_id); |
1732 |
$bib_match = GetBestRecordMatch($import_record_id); |
1735 |
if ($overlay_status ne 'no_match' && defined($bib_match)) { |
1733 |
if ($overlay_action eq 'replace') { |
1736 |
|
1734 |
$bib_result = defined($bib_match) ? 'replace' : 'create_new'; |
1737 |
$bib_result = $overlay_action; |
1735 |
} elsif ($overlay_action eq 'create_new') { |
1738 |
|
1736 |
$bib_result = 'create_new'; |
1739 |
if($item_action eq 'always_add' or $item_action eq 'add_only_for_matches'){ |
1737 |
} elsif ($overlay_action eq 'ignore') { |
|
|
1738 |
$bib_result = 'ignore'; |
1739 |
} |
1740 |
if($item_action eq 'always_add' or $item_action eq 'add_only_for_matches'){ |
1741 |
$item_result = 'create_new'; |
1740 |
$item_result = 'create_new'; |
1742 |
} |
1741 |
} elsif($item_action eq 'replace'){ |
1743 |
elsif($item_action eq 'replace'){ |
1742 |
$item_result = 'replace'; |
1744 |
$item_result = 'replace'; |
1743 |
} else { |
1745 |
} |
1744 |
$item_result = 'ignore'; |
1746 |
else { |
1745 |
} |
1747 |
$item_result = 'ignore'; |
1746 |
|
1748 |
} |
|
|
1749 |
} else { |
1747 |
} else { |
1750 |
$bib_result = $nomatch_action; |
1748 |
$bib_result = $nomatch_action; |
1751 |
$item_result = ($item_action eq 'always_add' or $item_action eq 'add_only_for_new') ? 'create_new' : 'ignore'; |
1749 |
$item_result = ($item_action eq 'always_add' or $item_action eq 'add_only_for_new') ? 'create_new' : 'ignore'; |
1752 |
} |
1750 |
} |
1753 |
return ($bib_result, $item_result, $bib_match); |
1751 |
return ($bib_result, $item_result, $bib_match); |
1754 |
} else { # must be auths |
1752 |
} else { # must be auths |
1755 |
my ($auth_result, $auth_match); |
1753 |
my ($auth_result, $auth_match); |
1756 |
|
1754 |
|
1757 |
if ($overlay_status ne 'no_match') { |
1755 |
$auth_match = GetBestRecordMatch($import_record_id); |
1758 |
$auth_match = GetBestRecordMatch($import_record_id); |
1756 |
if ($overlay_status ne 'no_match' && defined($auth_match)) { |
1759 |
if ($overlay_action eq 'replace') { |
1757 |
$auth_result = $overlay_action; |
1760 |
$auth_result = defined($auth_match) ? 'replace' : 'create_new'; |
|
|
1761 |
} elsif ($overlay_action eq 'create_new') { |
1762 |
$auth_result = 'create_new'; |
1763 |
} elsif ($overlay_action eq 'ignore') { |
1764 |
$auth_result = 'ignore'; |
1765 |
} |
1766 |
} else { |
1758 |
} else { |
1767 |
$auth_result = $nomatch_action; |
1759 |
$auth_result = $nomatch_action; |
1768 |
} |
1760 |
} |