X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=eg_staged_bib_overlay;h=1d8f04a50e5a8d7b63d4d1465d2112c5769b76ec;hp=8b419b509d2fd8cde95df7c67344838dc52cc88b;hb=be81214f660ec475396d21085ab6e28df3c7cddf;hpb=f1cf1b50a081ad0ca08718c9ee3a389f7057279c diff --git a/eg_staged_bib_overlay b/eg_staged_bib_overlay index 8b419b5..1d8f04a 100755 --- a/eg_staged_bib_overlay +++ b/eg_staged_bib_overlay @@ -67,7 +67,8 @@ abort(q{--action must be "stage_bibs", "filter_bibs", "load_bibs", "stage_auths" $action eq 'overlay_auths_stage1' or $action eq 'overlay_auths_stage2' or $action eq 'overlay_auths_stage3' or - $action eq 'link_auth_auth' + $action eq 'link_auth_auth' or + $action eq 'link_auth_bib' ; my $dbh = connect_db($db, $dbuser, $dbpw, $dbhost); @@ -112,6 +113,9 @@ if ($action eq 'overlay_auths_stage3') { if ($action eq 'link_auth_auth') { handle_link_auth_auth($dbh, $schema, $batch); } +if ($action eq 'link_auth_bib') { + handle_link_auth_bib($dbh, $schema, $batch); +} sub abort { my $msg = shift; @@ -161,6 +165,9 @@ This program has several modes controlled by the --action switch: --action link_auth_auth - run authority_authority_linker.pl for the authorities that were overlaid or added in this batch. + --action link_auth_bib - run authority_control_fields.pl for + the bibs that were overlaid in this + batch. Several switches are used regardless of the specified action: @@ -765,3 +772,26 @@ sub handle_link_auth_auth { WHERE name = 'ingest.disable_authority_auto_update'; }); } + +sub handle_link_auth_bib { + my $dbh = shift; + my $schema = shift; + my $batch = shift; + + my $sth = $dbh->prepare(qq{ + SELECT bib_id AS id + FROM $schema.$batch + WHERE imported + ORDER BY 1 + }); + $sth->execute(); + my @ids = map { $_->{id} } @{ $sth->fetchall_arrayref({}) }; + my $i = 0; + report_progress(scalar(@ids) . " records to do auth-bib linking"); + foreach my $id (@ids) { + $i++; + report_progress('... auth-bib linkings processed', $i) if 0 == $i % 10 or $i == scalar(@ids); + system "/openils/bin/authority_control_fields.pl --record $id -c /openils/conf/opensrf_core.xml"; + } + +}