use Getopt::Long;
-my @formats = qw/USMARC UNIMARC XML BRE ARE/;
+my @formats = qw/USMARC UNIMARC XML BRE ARE SRE/;
my $config = '@sysconfdir@/opensrf_core.xml';
my $format = 'USMARC';
my $export_mfhd = undef;
my $type = 'biblio';
my $all_records = undef;
+my $exclude_deleted = undef;
+my $exclude_inactive = undef;
+my $only_deleted = undef;
+my $only_inactive = undef;
my $replace_001 = undef;
my @library = ();
'items' => \$holdings,
'mfhd' => \$export_mfhd,
'all' => \$all_records,
+ 'exclude-deleted' => \$exclude_deleted,
+ 'exclude-inactive' => \$exclude_inactive,
+ 'deleted' => \$only_deleted,
+ 'inactive' => \$only_inactive,
'replace_001'=> \$replace_001,
'location=s' => \$location,
'money=s' => \$dollarsign,
Usage: $0 [options]
--help or -h This screen.
--config or -c Configuration file [@sysconfdir@/opensrf_core.xml]
- --format or -f Output format (USMARC, UNIMARC, XML, BRE, ARE) [USMARC]
+ --format or -f Output format (USMARC, UNIMARC, XML, BRE, ARE, SRE) [USMARC]
--encoding or -e Output encoding (UTF-8, ISO-8859-?, MARC8) [MARC8]
--xml-idl or -x Location of the IDL XML
--timeout Timeout for exporting a single record; increase if you
are using --holdings and are exporting records that
have a lot of items attached to them.
- --type or -t Record type (BIBLIO, AUTHORITY) [BIBLIO]
+ --type or -t Record type (BIBLIO, AUTHORITY, SERIAL) [BIBLIO]
--all or -a Export all records; ignores input list
--library Export the bibliographic records that have attached
holdings for the listed library or libraries as
identified by shortname
--replace_001 Replace the 001 field value with the record ID
+ Modifiers to --all or input list:
+ --exclude-deleted Include only non-deleted records in output
+ --exclude-inactive Include only active records in output
+ --deleted Include only deleted records in output
+ --inactive Include only active records in output
+
Additional options for type = 'BIBLIO':
--items or -i Include items (holdings) in the output
--money Currency symbol to use in item price field [\$]
IDs contained in a file named "list_of_ids":
cat list_of_ids | $0 > output_file
-To export a set of MARC21XML authority records in a file named "output.xml"
-for all authority records in the database:
- $0 --format XML --type AUTHORITY --all > output.xml
+To export a set of active, non-deleted MARC21XML authority records in a file
+named "output.xml" for all authority records in the database:
+ $0 --format XML --type AUTHORITY --all --exclude-inactive --exclude-deleted > output.xml
To export a set of USMARC bibliographic records encoded in UTF-8 in a file
named "sys1_bibs.mrc" based on records which have attached callnumbers for the
'records with a request for records by library');
}
+if ($exclude_deleted && $only_deleted) {
+ die('Incompatible arguments: you cannot combine a request for deleted ' .
+ 'records with a request excluding deleted records');
+}
+
+if ($exclude_inactive && $only_inactive) {
+ die('Incompatible arguments: you cannot combine a request for inactive ' .
+ 'records with a request excluding inactive records');
+}
+
$type = lc($type);
$format = uc($format);
$encoding = uc($encoding);
my $top_record = 0;
if ($type eq 'biblio') {
$top_record = $editor->search_biblio_record_entry([
- {deleted => 'f'},
- {order_by => { 'bre' => 'id DESC' }, limit => 1}
+ {}, {order_by => { 'bre' => 'id DESC' }, limit => 1}
])->[0]->id;
} elsif ($type eq 'authority') {
$top_record = $editor->search_authority_record_entry([
- {deleted => 'f'},
- {order_by => { 'are' => 'id DESC' }, limit => 1}
+ {}, {order_by => { 'are' => 'id DESC' }, limit => 1}
+ ])->[0]->id;
+ } elsif ($type eq 'serial') {
+ $top_record = $editor->search_serial_record_entry([
+ {}, {order_by => { 'sre' => 'id DESC' }, limit => 1}
])->[0]->id;
}
for (my $i = 0; $i++ < $top_record;) {
$bib = $s->content;
$r->finish;
+ return if (
+ ( $exclude_deleted && $bib->deleted =~ /^t/i ) ||
+ ( $exclude_inactive && $bib->active =~ /^f/i ) ||
+ ( $only_deleted && $bib->deleted =~ /^f/i ) ||
+ ( $only_inactive && $bib->active =~ /^t/i )
+ );
+
$count{bib}++;
return unless $bib;
- if ($format eq 'ARE' or $format eq 'BRE') {
+ if ($format eq 'ARE' or $format eq 'BRE' or $format eq 'SRE') {
print OpenSRF::Utils::JSON->perl2JSON($bib);
stats();
$count{did}++;