'encoding=s',
'timeout=i',
'library=s@',
+ 'descendants=s@',
'since=s',
'store=s',
'debug');
--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:
}
# 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');
}
$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;
}
$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;
--- /dev/null
+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.