From f2aaaa5360aa4b0164dc65d55b5f1ec658ef02f1 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Fri, 19 Dec 2014 15:52:33 -0500 Subject: [PATCH] options for excluding certain items by internal item id's and by barcodes. --exclude-item-id-file= --exclude-item-barcodes-file= Works in conjunction with --exclude-itemless-bibs, so if that argument is in effect and all items on a given bib are effectively filtered out via an --exclude-item argument, then the bib itself will not be included in the output. Signed-off-by: Jason Etheridge --- Open-ILS/src/support-scripts/marc_export.in | 53 +++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/support-scripts/marc_export.in b/Open-ILS/src/support-scripts/marc_export.in index cc12de93e3..c7cfe898d4 100755 --- a/Open-ILS/src/support-scripts/marc_export.in +++ b/Open-ILS/src/support-scripts/marc_export.in @@ -83,6 +83,8 @@ sub new { 'help', 'items', 'exclude-itemless-bibs', + 'exclude-item-id-file=s', + 'exclude-item-barcode-file=s', 'mfhd', 'all', 'replace_001', @@ -129,16 +131,18 @@ Usage: $0 [options] --since Export records modified since a certain date and time. Additional options for type = 'BIBLIO': - --items or -i Include items (holdings) in the output - --exclude-itemless-bibs Don't output bibs without holdings (requires --items) - --money Currency symbol to use in item price field [\$] - --mfhd Export serial MFHD records for associated bib records - Not compatible with --format=BRE - --location or -l MARC Location Code for holdings from - http://www.loc.gov/marc/organizations/orgshome.html - --library Export the bibliographic records that have attached - holdings for the listed library or libraries as - identified by shortname + --items or -i Include items (holdings) in the output + --exclude-item-id-file File containing list of item ids to exclude + --exclude-item-barcode-file File containing list of item barcodes to exclude + --exclude-itemless-bibs Don't output bibs without holdings (requires --items) + --money Currency symbol to use in item price field [\$] + --mfhd Export serial MFHD records for associated bib records + Not compatible with --format=BRE + --location or -l MARC Location Code for holdings from + http://www.loc.gov/marc/organizations/orgshome.html + --library Export the bibliographic records that have attached + holdings for the listed library or libraries as + identified by shortname Examples: @@ -200,6 +204,33 @@ HELP if ($opts{'exclude-itemless-bibs'} && ! $opts{items}) { die "If excluding itemless bibs, must export holdings."; } + $opts{'exclude-item-ids'} = {}; + if ($opts{'exclude-item-id-file'}) { + if (-e $opts{'exclude-item-id-file'}) { + open FILE, $opts{'exclude-item-id-file'}; + while (my $item_id = ) { + chomp $item_id; + $opts{'exclude-item-ids'}->{$item_id} = 1; + } + close FILE; + } else { + die "Could not find file for exclude-item-id-file: " . $opts{'exclude-item-id-file'}; + } + } + $opts{'exclude-item-barcodes'} = {}; + if ($opts{'exclude-item-barcode-file'}) { + if (-e $opts{'exclude-item-barcode-file'}) { + open FILE, $opts{'exclude-item-barcode-file'}; + while (my $item_barcode = ) { + chomp $item_barcode; + $opts{'exclude-item-barcodes'}->{$item_barcode} = 1; + } + close FILE; + } else { + die "Could not find file for exclude-item-barcode-file: " . $opts{'exclude-item-barcode-file'}; + } + } + if ($opts{mfhd}) { if ($opts{type} ne 'biblio') { @@ -466,6 +497,8 @@ sub next { my $item_count = 0; foreach my $acp (@acps) { next unless ($acp); + next if defined $Marque::config->option_value('exclude-item-ids')->{$acp->id()}; + next if defined $Marque::config->option_value('exclude-item-barcodes')->{$acp->barcode()}; $item_count++; my $location = $Marque::config->option_value('location'); my $price = ($acp->price() ? $Marque::config->option_value('money').$acp->price() : ''); -- 2.11.0