$e->requestor($requestor);
$$report_args{e} = $e;
- $$report_args{import_error} = undef;
$$report_args{evt} = undef;
+ $$report_args{import_error} = undef;
my $rec = $e->$retrieve_func([
$rec_id,
{
from => [
$overlay_func,
- $rec->id,
+ $rec_id,
$overlay_target,
$merge_profile
]
if($res and ($res = $res->[0])) {
if($res->{$overlay_func} eq 't') {
- $logger->info("vl: $type direct overlay succeeded for queued rec " .
- $rec->id . " and overlay target $overlay_target");
+ $logger->info("vl: $type direct overlay succeeded for queued rec ".
+ "$rec_id and overlay target $overlay_target");
$imported = 1;
}
} else {
- if($auto_overlay_1match) {
- # caller says to overlay if there is exactly 1 match
+ if($auto_overlay_1match) { # overlay if there is exactly 1 match
my %match_recs = map { $_->eg_record => 1 } @{$rec->matches};
if( scalar(keys %match_recs) == 1) { # all matches point to the same record
+ # $auto_overlay_best_func will find the 1 match and
+ # overlay if the quality ratio allows it
+
my $res = $e->json_query(
{
from => [
- $overlay_func,
- $rec->id,
- $rec->matches->[0]->eg_record,
- $merge_profile
+ $auto_overlay_best_func,
+ $rec_id,
+ $merge_profile,
+ $match_quality_ratio
]
}
);
if($res and ($res = $res->[0])) {
- if($res->{$overlay_func} eq 't') {
- $logger->info("vl: $type overlay-1match succeeded for queued rec " . $rec->id);
+ if($res->{$auto_overlay_best_func} eq 't') {
+ $logger->info("vl: $type overlay-1match succeeded for queued rec $rec_id");
$imported = 1;
+ } else {
+ $$report_args{import_error} = 'overlay.record.quality' if $match_quality_ratio > 0;
+ $logger->info("vl: $type overlay-1match failed for queued rec $rec_id");
}
} else {
$error = 1;
- $logger->error("vl: Error attempting overlay with func=$overlay_func, profile=$merge_profile, record=$rec_id");
+ $logger->error("vl: Error attempting overlay with func=$auto_overlay_best_func, profile=$merge_profile, record=$rec_id");
}
}
}
if(!$imported and !$error and $auto_overlay_exact and scalar(@{$rec->matches}) == 1 ) {
# caller says to overlay if there is an /exact/ match
+ # $auto_overlay_func only proceeds and returns true on exact matches
my $res = $e->json_query(
{
from => [
$auto_overlay_func,
- $rec->id,
+ $rec_id,
$merge_profile
]
}
if($res and ($res = $res->[0])) {
if($res->{$auto_overlay_func} eq 't') {
- $logger->info("vl: $type auto-overlay succeeded for queued rec " . $rec->id);
+ $logger->info("vl: $type auto-overlay succeeded for queued rec $rec_id");
$imported = 1;
} else {
- $logger->info("vl: $type auto-overlay failed for queued rec " . $rec->id);
+ $logger->info("vl: $type auto-overlay failed for queued rec $rec_id");
}
} else {
{
from => [
$auto_overlay_best_func,
- $rec->id,
+ $rec_id,
$merge_profile,
$match_quality_ratio
]
if($res and ($res = $res->[0])) {
if($res->{$auto_overlay_best_func} eq 't') {
- $logger->info("vl: $type auto-overlay-best succeeded for queued rec " . $rec->id);
+ $logger->info("vl: $type auto-overlay-best succeeded for queued rec $rec_id");
$imported = 1;
} else {
$$report_args{import_error} = 'overlay.record.quality' if $match_quality_ratio > 0;
- $logger->info("vl: $type auto-overlay-best failed for queued rec " . $rec->id);
+ $logger->info("vl: $type auto-overlay-best failed for queued rec $rec_id");
}
} else {
$logger->info("vl: successfully imported new $type record");
$rec->imported_as($record->id);
- $rec->import_time('now');
- $rec->clear_import_error;
- $rec->clear_error_detail;
- $imported = 1 if $e->$update_func($rec);
}
}
}
if($imported) {
- push @success_rec_ids, $rec_id;
- finish_rec_import_attempt($report_args);
- } else {
- # Send an update whenever there's an error
+ $rec->import_time('now');
+ $rec->clear_import_error;
+ $rec->clear_error_detail;
+
+ if($e->$update_func($rec)) {
+
+ push @success_rec_ids, $rec_id;
+ finish_rec_import_attempt($report_args);
+
+ } else {
+ $imported = 0;
+ }
+ }
+
+ if(!$imported) {
+ $logger->info("vl: record $rec_id was not imported");
$$report_args{evt} = $e->event unless $$report_args{evt};
finish_rec_import_attempt($report_args);
}
}
# import the copies
- import_record_asset_list_impl($conn, \@success_rec_ids, $requestor);
+ import_record_asset_list_impl($conn, \@success_rec_ids, $requestor) if @success_rec_ids;
$conn->respond({total => $$report_args{total}, progress => $$report_args{progress}});
return undef;
$rec_ids = $roe->json_query({
select => {vqbr => ['id']},
from => {vqbr => 'vii'},
- where => {'+vqbr' => {import_time => {'!=' => undef}}},
+ where => {'+vqbr' => {
+ id => $rec_ids,
+ import_time => {'!=' => undef}
+ }},
distinct => 1
});
$rec_ids = [map {$_->{id}} @$rec_ids];
if($$args{report_all} or ($$args{progress} % $$args{step}) == 0) {
$$args{conn}->respond({
- map { $_ => $args->{$_} } qw/total progress success_count/,
+ total => $$args{total},
+ progress => $$args{progress},
+ success_count => $$args{success_count},
err_event => $evt
});
$$args{step} *= 2 unless $$args{step} == 256;
CREATE OR REPLACE FUNCTION vandelay.match_bib_record() RETURNS TRIGGER AS $func$
DECLARE
incoming_existing_id TEXT;
- my_bib_queue vandelay.bib_queue%ROWTYPE;
test_result vandelay.match_set_test_result%ROWTYPE;
tmp_rec BIGINT;
+ match_set INT;
BEGIN
IF TG_OP IN ('INSERT','UPDATE') AND NEW.imported_as IS NOT NULL THEN
RETURN NEW;
DELETE FROM vandelay.bib_match WHERE queued_record = NEW.id;
- SELECT * INTO my_bib_queue FROM vandelay.bib_queue WHERE id = NEW.queue;
+ SELECT q.match_set INTO match_set FROM vandelay.bib_queue q WHERE q.id = NEW.queue;
- IF my_bib_queue.match_set IS NULL THEN
- RETURN NEW;
+ IF match_set IS NOT NULL THEN
+ NEW.quality := vandelay.measure_record_quality( NEW.marc, match_set );
END IF;
- NEW.quality := vandelay.measure_record_quality( NEW.marc, my_bib_queue.match_set );
-
-- Perfect matches on 901$c exit early with a match with high quality.
incoming_existing_id :=
oils_xpath_string('//*[@tag="901"]/*[@code="c"][1]', NEW.marc);
IF incoming_existing_id IS NOT NULL AND incoming_existing_id != '' THEN
SELECT id INTO tmp_rec FROM biblio.record_entry WHERE id = incoming_existing_id::bigint;
IF tmp_rec IS NOT NULL THEN
- INSERT INTO vandelay.bib_match (queued_record, eg_record, quality) VALUES ( NEW.id, incoming_existing_id::bigint, 9999);
- RETURN NEW;
+ INSERT INTO vandelay.bib_match (queued_record, eg_record, match_score, quality)
+ SELECT
+ NEW.id,
+ b.id,
+ 9999,
+ -- note: no match_set means quality==0
+ vandelay.measure_record_quality( b.marc, match_set )
+ FROM biblio.record_entry b
+ WHERE id = incoming_existing_id::bigint;
END IF;
END IF;
+ IF match_set IS NULL THEN
+ RETURN NEW;
+ END IF;
FOR test_result IN SELECT * FROM
- vandelay.match_set_test_marcxml(my_bib_queue.match_set, NEW.marc) LOOP
+ vandelay.match_set_test_marcxml(match_set, NEW.marc) LOOP
INSERT INTO vandelay.bib_match ( queued_record, eg_record, match_score, quality )
- SELECT NEW.id,
- test_result.record,
+ SELECT
+ NEW.id,
+ test_result.record,
test_result.quality,
- vandelay.measure_record_quality( b.marc, my_bib_queue.match_set )
- FROM biblio.record_entry b
- WHERE id = test_result.record;
+ vandelay.measure_record_quality( b.marc, match_set )
+ FROM biblio.record_entry b
+ WHERE id = test_result.record;
END LOOP;
<!ENTITY vandelay.auth.attrs "Authority attributes">
<!ENTITY vandelay.auth.records "Authority Records">
<!ENTITY vandelay.auto.import.noncolliding "Import Non-Colliding Records">
-<!ENTITY vandelay.auto.import.auto_overlay_exact "Merge/Overlay Exact Matches (901c)">
-<!ENTITY vandelay.auto.import.auto_overlay_1match "Merge/Overlay Single Matches">
-<!ENTITY vandelay.auto.import.auto_overlay_best "Merge/Overlay Best Match">
-<!ENTITY vandelay.auto.import.auto_overlay_best_ratio "Best Match Minimum Quality Ratio">
+<!ENTITY vandelay.auto.import.auto_overlay_exact "Merge On Exact Match (901c)">
+<!ENTITY vandelay.auto.import.auto_overlay_1match "Merge On Single Match">
+<!ENTITY vandelay.auto.import.auto_overlay_best "Merge On Best Match">
+<!ENTITY vandelay.auto.import.auto_overlay_best_ratio "Best/Single Match Minimum Quality Ratio">
<!ENTITY vandelay.auto.import.auto_overlay_best_ratio.desc "New Record Quaility / Quality of Best Match">
-<!ENTITY vandelay.auto.import.merge_profile "Merge/Overlay Profile">
+<!ENTITY vandelay.auto.import.merge_profile "Merge Profile">
<!ENTITY vandelay.auto.width "Auto Width">
<!ENTITY vandelay.back.to.import.queue "Back To Import Queue">
<!ENTITY vandelay.bib.attrs "Bibliographic attributes">
<!ENTITY vandelay.marc.record "MARC Record">
<!ENTITY vandelay.matches "Matches">
<!ENTITY vandelay.next.page "Next »">
-<!ENTITY vandelay.overlay.selected.record "Overlay selected record with imported record">
-<!ENTITY vandelay.overlay.target "Overlay Target">
+<!ENTITY vandelay.overlay.selected.record "Merge selected record with imported record">
+<!ENTITY vandelay.overlay.target "Merge Target">
<!ENTITY vandelay.page "Page">
<!ENTITY vandelay.powered.by.evergreen "Powered by Evergreen!">
<!ENTITY vandelay.prev.page "« Previous">