From: Bill Erickson Date: Mon, 26 Sep 2016 14:18:42 +0000 (-0400) Subject: JBAS-1437 Auth-2-auth linker --file option X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4f74e2ba4e1889ed2b2f123e452ddbc484c86838;p=working%2FEvergreen.git JBAS-1437 Auth-2-auth linker --file option Supports a --file option pointing to file of authority record IDs, one ID per line. Signed-off-by: Bill Erickson --- diff --git a/KCLS/linking/authority_authority_linker.pl b/KCLS/linking/authority_authority_linker.pl index a7f3ffcded..bf0f8ec524 100755 --- a/KCLS/linking/authority_authority_linker.pl +++ b/KCLS/linking/authority_authority_linker.pl @@ -47,6 +47,7 @@ my ($start_id, $end_id); my $bootstrap = '/openils/conf/opensrf_core.xml'; my @records; my $verbose; +my $input_file =''; my $db_host = $ENV{PGHOST} || 'localhost'; my $db_port = $ENV{PGPORT} || '5432'; my $db_user = $ENV{PGDATABASE} || 'evergreen'; @@ -61,8 +62,9 @@ my $result = GetOptions( 'record=i' => \@records, 'all', 'help', 'start_id=i' => \$start_id, - 'end_id=i' => \$end_id, - 'verbose' => \$verbose, + 'end_id=i' => \$end_id, + 'file=s' => \$input_file, + 'verbose' => \$verbose, "db-host=s" => \$db_host, "db-user=s" => \$db_user, "db-pass=s" => \$db_pass, @@ -119,6 +121,24 @@ if (@records) { } elsif ($start_id and $end_id) { $query = sprintf($query, "WHERE sh2.record BETWEEN ? AND ?"); @bind_params = ($start_id, $end_id); + +} elsif ($input_file) { + # Load authority record IDs from a file. + announce("Reading authority record IDs from $input_file"); + + open FILE, "<", $input_file or die "Can't open file $input_file\n"; + while() { + chomp; + push(@records, $_) if $_; + } + close FILE; + + announce("Read ".scalar(@records)." from $input_file"); + + # No bind_params needed. + my $recstr = join(',', @records); + $query = sprintf($query, "WHERE sh2.record IN ($recstr)"); + } else { pod2usage(0); }