Lines 711-717
sub BatchCommitRecords {
Link Here
|
711 |
} elsif ($record_result eq 'ignore') { |
711 |
} elsif ($record_result eq 'ignore') { |
712 |
$recordid = $record_match; |
712 |
$recordid = $record_match; |
713 |
$num_ignored++; |
713 |
$num_ignored++; |
714 |
$recordid = $record_match; |
|
|
715 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
714 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
716 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
715 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
717 |
$num_items_added += $bib_items_added; |
716 |
$num_items_added += $bib_items_added; |
Lines 1200-1205
sub GetBestRecordMatch {
Link Here
|
1200 |
WHERE import_record_matches.import_record_id = ? AND |
1199 |
WHERE import_record_matches.import_record_id = ? AND |
1201 |
( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR |
1200 |
( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR |
1202 |
(import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) ) |
1201 |
(import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) ) |
|
|
1202 |
AND chosen = 1 |
1203 |
ORDER BY score DESC, candidate_match_id DESC"); |
1203 |
ORDER BY score DESC, candidate_match_id DESC"); |
1204 |
$sth->execute($import_record_id); |
1204 |
$sth->execute($import_record_id); |
1205 |
my ($record_id) = $sth->fetchrow_array(); |
1205 |
my ($record_id) = $sth->fetchrow_array(); |
Lines 1480-1491
sub GetImportRecordMatches {
Link Here
|
1480 |
my $dbh = C4::Context->dbh; |
1480 |
my $dbh = C4::Context->dbh; |
1481 |
# FIXME currently biblio only |
1481 |
# FIXME currently biblio only |
1482 |
my $sth = $dbh->prepare_cached("SELECT title, author, biblionumber, |
1482 |
my $sth = $dbh->prepare_cached("SELECT title, author, biblionumber, |
1483 |
candidate_match_id, score, record_type |
1483 |
candidate_match_id, score, record_type, |
|
|
1484 |
chosen |
1484 |
FROM import_records |
1485 |
FROM import_records |
1485 |
JOIN import_record_matches USING (import_record_id) |
1486 |
JOIN import_record_matches USING (import_record_id) |
1486 |
LEFT JOIN biblio ON (biblionumber = candidate_match_id) |
1487 |
LEFT JOIN biblio ON (biblionumber = candidate_match_id) |
1487 |
WHERE import_record_id = ? |
1488 |
WHERE import_record_id = ? |
1488 |
ORDER BY score DESC, biblionumber DESC"); |
1489 |
ORDER BY score DESC, chosen DESC, biblionumber DESC"); |
1489 |
$sth->bind_param(1, $import_record_id); |
1490 |
$sth->bind_param(1, $import_record_id); |
1490 |
my $results = []; |
1491 |
my $results = []; |
1491 |
$sth->execute(); |
1492 |
$sth->execute(); |
Lines 1518-1527
sub SetImportRecordMatches {
Link Here
|
1518 |
$delsth->execute($import_record_id); |
1519 |
$delsth->execute($import_record_id); |
1519 |
$delsth->finish(); |
1520 |
$delsth->finish(); |
1520 |
|
1521 |
|
1521 |
my $sth = $dbh->prepare("INSERT INTO import_record_matches (import_record_id, candidate_match_id, score) |
1522 |
my $sth = $dbh->prepare("INSERT INTO import_record_matches (import_record_id, candidate_match_id, score, chosen) |
1522 |
VALUES (?, ?, ?)"); |
1523 |
VALUES (?, ?, ?, ?)"); |
|
|
1524 |
my $chosen = 1; #The first match is defaulted to be chosen |
1523 |
foreach my $match (@matches) { |
1525 |
foreach my $match (@matches) { |
1524 |
$sth->execute($import_record_id, $match->{'record_id'}, $match->{'score'}); |
1526 |
$sth->execute($import_record_id, $match->{'record_id'}, $match->{'score'}, $chosen); |
|
|
1527 |
$chosen = 0; #After the first we do not default to other matches |
1525 |
} |
1528 |
} |
1526 |
} |
1529 |
} |
1527 |
|
1530 |
|
Lines 1738-1778
sub _get_commit_action {
Link Here
|
1738 |
if ($record_type eq 'biblio') { |
1741 |
if ($record_type eq 'biblio') { |
1739 |
my ($bib_result, $bib_match, $item_result); |
1742 |
my ($bib_result, $bib_match, $item_result); |
1740 |
|
1743 |
|
1741 |
if ($overlay_status ne 'no_match') { |
1744 |
$bib_match = GetBestRecordMatch($import_record_id); |
1742 |
$bib_match = GetBestRecordMatch($import_record_id); |
1745 |
if ($overlay_status ne 'no_match' && defined($bib_match)) { |
1743 |
if ($overlay_action eq 'replace') { |
1746 |
|
1744 |
$bib_result = defined($bib_match) ? 'replace' : 'create_new'; |
1747 |
$bib_result = $overlay_action; |
1745 |
} elsif ($overlay_action eq 'create_new') { |
1748 |
|
1746 |
$bib_result = 'create_new'; |
1749 |
if($item_action eq 'always_add' or $item_action eq 'add_only_for_matches'){ |
1747 |
} elsif ($overlay_action eq 'ignore') { |
|
|
1748 |
$bib_result = 'ignore'; |
1749 |
} |
1750 |
if($item_action eq 'always_add' or $item_action eq 'add_only_for_matches'){ |
1751 |
$item_result = 'create_new'; |
1750 |
$item_result = 'create_new'; |
1752 |
} |
1751 |
} elsif($item_action eq 'replace'){ |
1753 |
elsif($item_action eq 'replace'){ |
1752 |
$item_result = 'replace'; |
1754 |
$item_result = 'replace'; |
1753 |
} else { |
1755 |
} |
1754 |
$item_result = 'ignore'; |
1756 |
else { |
1755 |
} |
1757 |
$item_result = 'ignore'; |
1756 |
|
1758 |
} |
|
|
1759 |
} else { |
1757 |
} else { |
1760 |
$bib_result = $nomatch_action; |
1758 |
$bib_result = $nomatch_action; |
1761 |
$item_result = ($item_action eq 'always_add' or $item_action eq 'add_only_for_new') ? 'create_new' : 'ignore'; |
1759 |
$item_result = ($item_action eq 'always_add' or $item_action eq 'add_only_for_new') ? 'create_new' : 'ignore'; |
1762 |
} |
1760 |
} |
1763 |
return ($bib_result, $item_result, $bib_match); |
1761 |
return ($bib_result, $item_result, $bib_match); |
1764 |
} else { # must be auths |
1762 |
} else { # must be auths |
1765 |
my ($auth_result, $auth_match); |
1763 |
my ($auth_result, $auth_match); |
1766 |
|
1764 |
|
1767 |
if ($overlay_status ne 'no_match') { |
1765 |
$auth_match = GetBestRecordMatch($import_record_id); |
1768 |
$auth_match = GetBestRecordMatch($import_record_id); |
1766 |
if ($overlay_status ne 'no_match' && defined($auth_match)) { |
1769 |
if ($overlay_action eq 'replace') { |
1767 |
$auth_result = $overlay_action; |
1770 |
$auth_result = defined($auth_match) ? 'replace' : 'create_new'; |
|
|
1771 |
} elsif ($overlay_action eq 'create_new') { |
1772 |
$auth_result = 'create_new'; |
1773 |
} elsif ($overlay_action eq 'ignore') { |
1774 |
$auth_result = 'ignore'; |
1775 |
} |
1776 |
} else { |
1768 |
} else { |
1777 |
$auth_result = $nomatch_action; |
1769 |
$auth_result = $nomatch_action; |
1778 |
} |
1770 |
} |