[open-ils-commits] r12872 - trunk/Open-ILS/src/perlmods/OpenILS/Application (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Apr 14 21:47:27 EDT 2009
Author: miker
Date: 2009-04-14 21:47:25 -0400 (Tue, 14 Apr 2009)
New Revision: 12872
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
Log:
yet untested method for calling the in-db merge stored proc to handle merging of master/sub bib records
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm 2009-04-15 01:10:02 UTC (rev 12871)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm 2009-04-15 01:47:25 UTC (rev 12872)
@@ -476,6 +476,41 @@
/
);
+sub in_db_merge {
+ my( $self, $conn, $auth, $master, $records ) = @_;
+ my( $reqr, $evt ) = $U->checkses($auth);
+ return $evt if $evt;
+
+ my $editor = new_editor( requestor => $reqr, xact => 1 );
+
+ my $count = 0;
+ for my $source ( @$records ) {
+ #XXX we actually /will/ want to check perms for master and sources after record ownership exists
+
+ # This stored proc (asset.merge_record_assets(target,source)) has the side effects of
+ # moving call_number, title-type (and some volume-type) hold_request and uri-mapping
+ # objects from the source record to the target record, so must be called from within
+ # a transaction.
+
+ $count += $editor->json_query({
+ select => {
+ bre => [{
+ alias => 'count',
+ transform => 'asset.merge_record_assets',
+ column => 'id',
+ params => [$source]
+ }]
+ },
+ from => 'bre',
+ where => { id => $master }
+ })->[0]->{count}; # count of objects moved, of all types
+
+ }
+
+ $editor->commit;
+ return $count;
+}
+
sub merge {
my( $self, $conn, $auth, $master, $records ) = @_;
my( $reqr, $evt ) = $U->checkses($auth);
More information about the open-ils-commits
mailing list