[open-ils-commits] [GIT] Evergreen ILS branch master updated. 1c83704e0ed0ddca391f8324689751f5adc0c80b

Evergreen Git git at git.evergreen-ils.org
Fri May 19 09:48:42 EDT 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  1c83704e0ed0ddca391f8324689751f5adc0c80b (commit)
      from  75e65606a3151c6229b1197ab31d2cf0bd922b7c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1c83704e0ed0ddca391f8324689751f5adc0c80b
Author: Jason Stephenson <jason at sigio.com>
Date:   Sat Apr 22 08:17:53 2017 -0400

    LP 1672519: Make marc_export descendants aware.
    
    Add a --descendants option to marc_export to get records for an
    org. unit and its descendants.
    
    To test
    -------
    [1] Run marc_export with -i --library FOO. Verify that the resulting
        records have 852 fields only from FOO.
    [2] Run marc_export with -i --descendants FOO. Verify that the resulting
        records have 852 fields from FOO *and* all descendants of FOO.
    [3] Run marc_export using various combinations of --library and --descendants;
        verify that items from the expected libraries show up as 852 fields.
    
    Signed-off-by: Jason Stephenson <jason at sigio.com>
    Signed-off-by: Rogan Hamby <rogan.hamby at gmail.com>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/support-scripts/marc_export.in b/Open-ILS/src/support-scripts/marc_export.in
index 5c0115c..b693d03 100755
--- a/Open-ILS/src/support-scripts/marc_export.in
+++ b/Open-ILS/src/support-scripts/marc_export.in
@@ -95,6 +95,7 @@ sub new {
                'encoding=s',
                'timeout=i',
                'library=s@',
+               'descendants=s@',
                'since=s',
                'store=s',
                'debug');
@@ -138,6 +139,10 @@ Usage: $0 [options]
  --library          Export the bibliographic records that have attached
                     holdings for the listed library or libraries as
                     identified by shortname
+ --descendants      Like the --library option, but org. tree aware. It
+                    exports records that have attached holdings for the
+                    specified org. unit and all of its descendants in
+                    the tree.
 
 Examples:
 
@@ -166,7 +171,7 @@ HELP
     }
 
     # Validate some of the settings.
-    if ($opts{all} && $opts{library}) {
+    if ($opts{all} && ($opts{library} || $opts{descendants})) {
         die('Incompatible arguments: you cannot combine a request for all ' .
                 'records with a request for records by library');
     }
@@ -249,6 +254,7 @@ sub need_ids {
     $rv = 0 if ($self->{options}->{all});
     $rv = 0 if ($self->{options}->{since});
     $rv = 0 if ($self->{options}->{library});
+    $rv = 0 if ($self->{options}->{descendants});
 
     return $rv;
 }
@@ -335,6 +341,20 @@ sub new {
             $sth->finish();
         }
     }
+    # Ditto for descendants.  We don't worry about redundancy, the db can deal with it.
+    if ($Marque::config->option_value('descendants')) {
+        # Unlike the above, we're looping to make this simpler in the database.
+        my $sth = $self->{handle}->prepare(
+                'select id from actor.org_unit_descendants((select id from actor.org_unit where shortname=?))');
+        foreach my $shortname (@{$Marque::config->option_value('descendants')}) {
+            if ($sth->execute($shortname)) {
+                my $r = $sth->fetchall_arrayref();
+                my @ids = map {$_->[0]} @{$r};
+                push(@{$self->{libs}}, @ids);
+                $sth->finish();
+            }
+        }
+    }
 
     bless $self, $class;
     return $self;
diff --git a/docs/RELEASE_NOTES_NEXT/Administration/marc_export-descendants-option.adoc b/docs/RELEASE_NOTES_NEXT/Administration/marc_export-descendants-option.adoc
new file mode 100644
index 0000000..ffc8c82
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/Administration/marc_export-descendants-option.adoc
@@ -0,0 +1,16 @@
+New marc_export --descendants option
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The marc_export script has a new option, --descendants.  This option
+takes one argument of an organizational unit shortname.  It works much
+like the existing --library option except that it is aware of the
+org. tree and will export records with holdings at the specified
+organizational unit and all of its decendants.  This is handy if you
+want to export the records for all of the branches of a system.  You
+can do that by specifying this option and the system's shortname,
+instead of specifying multiple --library options for each branch.
+
+The --descendants option can be repeated, as the --library option can.
+All of the specified org. units and their descendants will be included
+in the output.  It can also be combined with individual --library
+options when necessary.

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/support-scripts/marc_export.in        |   22 +++++++++++++++++++-
 .../marc_export-descendants-option.adoc            |   16 ++++++++++++++
 2 files changed, 37 insertions(+), 1 deletions(-)
 create mode 100644 docs/RELEASE_NOTES_NEXT/Administration/marc_export-descendants-option.adoc


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list