[open-ils-commits] r8818 -
trunk/Open-ILS/src/perlmods/OpenILS/Application
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Feb 22 10:50:47 EST 2008
Author: erickson
Date: 2008-02-22 10:20:05 -0500 (Fri, 22 Feb 2008)
New Revision: 8818
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
Log:
added logic to migrate holds from the deleted records to the master record in title merging
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm 2008-02-22 15:18:51 UTC (rev 8817)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm 2008-02-22 15:20:05 UTC (rev 8818)
@@ -769,8 +769,7 @@
signature => q/
Merges a group of records
@param auth The login session key
- @param master The id of the record all other r
- ecords should be merged into
+ @param master The id of the record all other records should be merged into
@param records Array of records to be merged into the master record
@return 1 on success, Event on error.
/
@@ -783,13 +782,49 @@
my $editor = new_editor( requestor => $reqr, xact => 1 );
my $v = OpenILS::Application::Cat::Merge::merge_records($editor, $master, $records);
return $v if $v;
- $editor->finish;
- return 1;
+ $editor->commit;
+ # tell the client the merge is complete, then merge the holds
+ $conn->respond_complete(1);
+ merge_holds($master, $records);
+ return undef;
}
+sub merge_holds {
+ my($master, $records) = @_;
+ return unless $master and @$records;
+ return if @$records == 1 and $master == $$records[0];
+ my $e = new_editor(xact=>1);
+ my $holds = $e->search_action_hold_request(
+ { cancel_time => undef,
+ fulfillment_time => undef,
+ hold_type => 'T',
+ target => $records
+ },
+ {idlist=>1}
+ );
+ for my $hold_id (@$holds) {
+ my $hold = $e->retrieve_action_hold_request($hold_id);
+
+ $logger->info("Changing hold ".$hold->id.
+ " target from ".$hold->target." to $master in record merge");
+
+ $hold->target($master);
+ unless($e->update_action_hold_request($hold)) {
+ my $evt = $e->event;
+ $logger->error("Error updating hold ". $evt->textcode .":". $evt->desc .":". $evt->stacktrace);
+ }
+ }
+
+ $e->commit;
+ return undef;
+}
+
+
+
+
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
More information about the open-ils-commits
mailing list