my $start_date;
my $end_date;
my $ids_only;
+my $id_file;
my $count_only;
my $out_file;
my $help;
'ids-only' => \$ids_only,
'count-only' => \$count_only,
'out-file=s' => \$out_file,
+ 'id-file=s' => \$id_file,
'help' => \$help
) || help();
--count-only
Only print the number of bibs that would be exported to STDOUT.
+ --id-file </path/to/file>
+ Export bibs based on IDs found in this file. This bypasses the
+ normal date-filtered query. IDs listed one per line.
+
HELP
exit;
}
help() if $help;
-$KU->announce('ERR', "--start-date and --end-date required", 1)
- unless $start_date && $end_date;
+if (!$id_file) {
+
+ $KU->announce('ERR', "--start-date and --end-date required", 1)
+ unless $start_date && $end_date;
-$KU->announce('ERR', "Invalid date format", 1) unless
- $start_date =~ /^\d{4}-\d{2}-\d{2}$/ &&
- $end_date =~ /^\d{4}-\d{2}-\d{2}$/;
+ $KU->announce('ERR', "Invalid date format", 1) unless
+ $start_date =~ /^\d{4}-\d{2}-\d{2}$/ &&
+ $end_date =~ /^\d{4}-\d{2}-\d{2}$/;
+}
$KU->announce('ERR', "--out-file <filename> required", 1)
unless $out_file || $count_only;
+# Returns a SQL query which returns a set of bib record IDs
sub bib_query {
+
+ if ($id_file) {
+ open(ID_FILE, $id_file)
+ or die "Cannot open --id-file '$id_file': $!\n";
+
+ my $ids = join(',', map { chomp $_; $_ } <ID_FILE>);
+
+ close(ID_FILE);
+
+ return "SELECT id FROM biblio.record_entry WHERE id IN ($ids)";
+ }
+
my $sql = <<SQL;
-- viable_records include filters applied to all records.