Lines 689-695
sub BatchCommitRecords {
Link Here
|
689 |
} elsif ($record_result eq 'ignore') { |
689 |
} elsif ($record_result eq 'ignore') { |
690 |
$recordid = $record_match; |
690 |
$recordid = $record_match; |
691 |
$num_ignored++; |
691 |
$num_ignored++; |
692 |
$recordid = $record_match; |
|
|
693 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
692 |
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); |
693 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
695 |
$num_items_added += $bib_items_added; |
694 |
$num_items_added += $bib_items_added; |
Lines 1178-1183
sub GetBestRecordMatch {
Link Here
|
1178 |
WHERE import_record_matches.import_record_id = ? AND |
1177 |
WHERE import_record_matches.import_record_id = ? AND |
1179 |
( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR |
1178 |
( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR |
1180 |
(import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) ) |
1179 |
(import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) ) |
|
|
1180 |
AND chosen = 1 |
1181 |
ORDER BY score DESC, candidate_match_id DESC"); |
1181 |
ORDER BY score DESC, candidate_match_id DESC"); |
1182 |
$sth->execute($import_record_id); |
1182 |
$sth->execute($import_record_id); |
1183 |
my ($record_id) = $sth->fetchrow_array(); |
1183 |
my ($record_id) = $sth->fetchrow_array(); |
Lines 1442-1453
sub GetImportRecordMatches {
Link Here
|
1442 |
my $dbh = C4::Context->dbh; |
1442 |
my $dbh = C4::Context->dbh; |
1443 |
# FIXME currently biblio only |
1443 |
# FIXME currently biblio only |
1444 |
my $sth = $dbh->prepare_cached("SELECT title, author, biblionumber, |
1444 |
my $sth = $dbh->prepare_cached("SELECT title, author, biblionumber, |
1445 |
candidate_match_id, score, record_type |
1445 |
candidate_match_id, score, record_type, |
|
|
1446 |
chosen |
1446 |
FROM import_records |
1447 |
FROM import_records |
1447 |
JOIN import_record_matches USING (import_record_id) |
1448 |
JOIN import_record_matches USING (import_record_id) |
1448 |
LEFT JOIN biblio ON (biblionumber = candidate_match_id) |
1449 |
LEFT JOIN biblio ON (biblionumber = candidate_match_id) |
1449 |
WHERE import_record_id = ? |
1450 |
WHERE import_record_id = ? |
1450 |
ORDER BY score DESC, biblionumber DESC"); |
1451 |
ORDER BY score DESC, chosen DESC, biblionumber DESC"); |
1451 |
$sth->bind_param(1, $import_record_id); |
1452 |
$sth->bind_param(1, $import_record_id); |
1452 |
my $results = []; |
1453 |
my $results = []; |
1453 |
$sth->execute(); |
1454 |
$sth->execute(); |
Lines 1480-1489
sub SetImportRecordMatches {
Link Here
|
1480 |
$delsth->execute($import_record_id); |
1481 |
$delsth->execute($import_record_id); |
1481 |
$delsth->finish(); |
1482 |
$delsth->finish(); |
1482 |
|
1483 |
|
1483 |
my $sth = $dbh->prepare("INSERT INTO import_record_matches (import_record_id, candidate_match_id, score) |
1484 |
my $sth = $dbh->prepare("INSERT INTO import_record_matches (import_record_id, candidate_match_id, score, chosen) |
1484 |
VALUES (?, ?, ?)"); |
1485 |
VALUES (?, ?, ?, ?)"); |
|
|
1486 |
my $chosen = 1; #The first match is defaulted to be chosen |
1485 |
foreach my $match (@matches) { |
1487 |
foreach my $match (@matches) { |
1486 |
$sth->execute($import_record_id, $match->{'record_id'}, $match->{'score'}); |
1488 |
$sth->execute($import_record_id, $match->{'record_id'}, $match->{'score'}, $chosen); |
|
|
1489 |
$chosen = 0; #After the first we do not default to other matches |
1487 |
} |
1490 |
} |
1488 |
} |
1491 |
} |
1489 |
|
1492 |
|
Lines 1700-1740
sub _get_commit_action {
Link Here
|
1700 |
if ($record_type eq 'biblio') { |
1703 |
if ($record_type eq 'biblio') { |
1701 |
my ($bib_result, $bib_match, $item_result); |
1704 |
my ($bib_result, $bib_match, $item_result); |
1702 |
|
1705 |
|
1703 |
if ($overlay_status ne 'no_match') { |
1706 |
$bib_match = GetBestRecordMatch($import_record_id); |
1704 |
$bib_match = GetBestRecordMatch($import_record_id); |
1707 |
if ($overlay_status ne 'no_match' && defined($bib_match)) { |
1705 |
if ($overlay_action eq 'replace') { |
1708 |
|
1706 |
$bib_result = defined($bib_match) ? 'replace' : 'create_new'; |
1709 |
$bib_result = $overlay_action; |
1707 |
} elsif ($overlay_action eq 'create_new') { |
1710 |
|
1708 |
$bib_result = 'create_new'; |
1711 |
if($item_action eq 'always_add' or $item_action eq 'add_only_for_matches'){ |
1709 |
} elsif ($overlay_action eq 'ignore') { |
|
|
1710 |
$bib_result = 'ignore'; |
1711 |
} |
1712 |
if($item_action eq 'always_add' or $item_action eq 'add_only_for_matches'){ |
1713 |
$item_result = 'create_new'; |
1712 |
$item_result = 'create_new'; |
1714 |
} |
1713 |
} elsif($item_action eq 'replace'){ |
1715 |
elsif($item_action eq 'replace'){ |
1714 |
$item_result = 'replace'; |
1716 |
$item_result = 'replace'; |
1715 |
} else { |
1717 |
} |
1716 |
$item_result = 'ignore'; |
1718 |
else { |
1717 |
} |
1719 |
$item_result = 'ignore'; |
1718 |
|
1720 |
} |
|
|
1721 |
} else { |
1719 |
} else { |
1722 |
$bib_result = $nomatch_action; |
1720 |
$bib_result = $nomatch_action; |
1723 |
$item_result = ($item_action eq 'always_add' or $item_action eq 'add_only_for_new') ? 'create_new' : 'ignore'; |
1721 |
$item_result = ($item_action eq 'always_add' or $item_action eq 'add_only_for_new') ? 'create_new' : 'ignore'; |
1724 |
} |
1722 |
} |
1725 |
return ($bib_result, $item_result, $bib_match); |
1723 |
return ($bib_result, $item_result, $bib_match); |
1726 |
} else { # must be auths |
1724 |
} else { # must be auths |
1727 |
my ($auth_result, $auth_match); |
1725 |
my ($auth_result, $auth_match); |
1728 |
|
1726 |
|
1729 |
if ($overlay_status ne 'no_match') { |
1727 |
$auth_match = GetBestRecordMatch($import_record_id); |
1730 |
$auth_match = GetBestRecordMatch($import_record_id); |
1728 |
if ($overlay_status ne 'no_match' && defined($auth_match)) { |
1731 |
if ($overlay_action eq 'replace') { |
1729 |
$auth_result = $overlay_action; |
1732 |
$auth_result = defined($auth_match) ? 'replace' : 'create_new'; |
|
|
1733 |
} elsif ($overlay_action eq 'create_new') { |
1734 |
$auth_result = 'create_new'; |
1735 |
} elsif ($overlay_action eq 'ignore') { |
1736 |
$auth_result = 'ignore'; |
1737 |
} |
1738 |
} else { |
1730 |
} else { |
1739 |
$auth_result = $nomatch_action; |
1731 |
$auth_result = $nomatch_action; |
1740 |
} |
1732 |
} |