LP1940662: Add a --pipe option to marc_export
authorJason Stephenson <jason@sigio.com>
Thu, 2 Mar 2023 15:33:34 +0000 (10:33 -0500)
committerJason Stephenson <jason@sigio.com>
Thu, 2 Mar 2023 15:33:34 +0000 (10:33 -0500)
Add a --pipe option to marc_export to force reading of record ids from
standard input when one or more of the --library, or --descendants
options are used.  This permits more flexibility when exporting
records with holdings for given libraries or subsets of a collection.

It is an error to specify the --all or --since and --pipe options in
the same command line.

Co-authored-by: Josh Stompro <stomproj@larl.org>

Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Josh Stompro <stomproj@larl.org>

Open-ILS/src/support-scripts/marc_export.in
docs/RELEASE_NOTES_NEXT/Administration/marc_export_pipe.adoc [new file with mode: 0644]
docs/modules/development/pages/support_scripts.adoc

index fd6a33d..c3bf95e 100755 (executable)
@@ -100,7 +100,8 @@ sub new {
                'since=s',
                'store=s',
                'uris',
-               'debug');
+               'debug',
+               'pipe');
 
     if ($opts{help}) {
         print <<"HELP";
@@ -132,6 +133,8 @@ Usage: $0 [options]
  --store            Use the given storage backend to connect to the database.
                     Choices are (reporter, cstore, storage) [reporter]
  --since            Export records modified since a certain date and time.
+ --pipe             Force record ids to be read from list on standard input,
+                    despite other options to the contrary
 
  Additional options for type = 'BIBLIO':
  --items or -i      Include items (holdings) in the output
@@ -192,6 +195,15 @@ HELP
         die('Incompatible arguments: you cannot combine a request for all ' .
                 'records with a request for records added or changed since a certain date');
     }
+    if ($opts{all} && $opts{pipe}) {
+        die('Incompatible arguments: you cannot combine a request for all ' .
+                'records with the option to read record ids via standard input');
+    }
+    if ($opts{since} && $opts{pipe}) {
+        die('Incompatible arguments: you cannot combine a request for records added or '. 
+                'changed since a certain date with ' .
+                'the option to read record ids via standard input');
+    }
     $opts{type} = lc($opts{type});
     if (none {$_ eq $opts{type}} (TYPES)) {
         die "Please select a supported type.  ".
@@ -291,10 +303,13 @@ sub need_ids {
     my $self = shift;
     my $rv = 1;
 
-    $rv = 0 if ($self->{options}->{all});
     $rv = 0 if ($self->{options}->{since});
     $rv = 0 if ($self->{options}->{library});
     $rv = 0 if ($self->{options}->{descendants});
+    # --pipe trumps the above.
+    $rv = 1 if ($self->{options}->{pipe});
+    # --all trumps --pipe, but we should throw an error before we get here.
+    $rv = 0 if ($self->{options}->{all});
 
     return $rv;
 }
diff --git a/docs/RELEASE_NOTES_NEXT/Administration/marc_export_pipe.adoc b/docs/RELEASE_NOTES_NEXT/Administration/marc_export_pipe.adoc
new file mode 100644 (file)
index 0000000..7aca6d3
--- /dev/null
@@ -0,0 +1,25 @@
+== --pipe option for marc_export ==
+
+Add a --pipe option to marc_export to force reading of record ids from
+standard input when one or more of the --library, or
+--descendants options are used.  This permits more flexibility when
+exporting records with holdings for given libraries or subsets of a
+collection.
+
+It is an error to specify the --all or --since  and --pipe options in the same
+command line.
+
+
+[source]
+--------
+        --pipe
+
+Some examples:
+
+        --pipe --library BR1   [Filter the list of bib ids by those 
+                                with BR1 as the Owning Library]
+
+        --pipe --descendants BR1 [Filters the list of bib ids by those 
+                                  with BR1 or descendants as the Owning Library]
+
+--------
index 04e993c..404ab30 100644 (file)
@@ -171,6 +171,17 @@ All of the specified org. units and their descendants will be included
 in the output.  You can also combine `--library` and `--descendants`
 options when necessary.
 
+==== --pipe ====
+
+If you want to use the `--library` and `--descendants` options with a list
+of bib ids from standard input, you can make use of the `--pipe` option.
+
+If you have a master list of bib ids, and only want to export bibs that have
+holdings from certain owning libraries then this option will help you reach 
+that goal.
+
+It will not work to combine `--all` or `--since` with `--pipe`.
+
 ==== --items ====
 
 The `--items` option will add an 852 field for every relevant item to the MARC