make this into a new setting --onlyholdings which only exports
authorJames Fournie <jfournie@sitka.bclibraries.ca>
Mon, 31 Oct 2011 20:09:43 +0000 (13:09 -0700)
committerJames Fournie <jfournie@sitka.bclibraries.ca>
Mon, 31 Oct 2011 20:09:43 +0000 (13:09 -0700)
items that successfully get an 852 holdings field
Signed-off-by: James Fournie <jfournie@sitka.bclibraries.ca>
marc_export_custom/marc_export_custom

index 604d75c..d09af70 100755 (executable)
@@ -29,6 +29,7 @@ my ($config,$format,$encoding,$location,$dollarsign,$idl,$help,$holdings,$timeou
 my ($exclusion_ini,$collapse_to_depth, $output_file);
 my $cfg;
 my $force901;
+my $onlyholdings;
 
 GetOptions(
         'help'       => \$help,
@@ -46,6 +47,7 @@ GetOptions(
         'force901'  => \$force901,
         'exclusion_ini=s' => \$exclusion_ini,
         'collapse_to_depth=i' => \$collapse_to_depth,
+        'onlyholdings' => \$onlyholdings,
         'output-file=s' => \$output_file,
 );
 
@@ -241,15 +243,20 @@ sub export_record {
 
         my $r = MARC::Record->new_from_xml( $bib->marc, $encoding, $format );
         if ($type eq 'biblio') {
-            # Remove old 852 fields
-            my @f = $r->field('852');
-            $r->delete_fields(@f) if @f;
-            # Add new 852 fields 
-            add_bib_holdings($bib, $r);
-            # Check that at least one 852 was added
-            @f = $r->field('852');
-            # If not, we should NOT add this item to the export 
-            return unless @f;
+
+            if($onlyholdings){
+                # Remove old 852 fields
+                my @f = $r->field('852');
+                $r->delete_fields(@f) if @f;
+                # Add new 852 fields 
+                add_bib_holdings($bib, $r);
+                # Check that at least one 852 was added
+                @f = $r->field('852');
+                # If not, we should NOT add this item to the export 
+                return unless @f;
+            } else {
+                add_bib_holdings($bib, $r);
+            }
         }
 
         if($force901){