From b0d777005df586e7e5294cc4f6b43842156e9370 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sat, 13 Sep 2014 13:47:02 -0400 Subject: [PATCH 1/1] Add check for other volumes before delete a bib. Modify NCIP::ILS::Evergreen->delete_copy() to check for call numbers other than the one already being deleted on a bib prior to deleting that bib. If there are other call numbers that are not themselves deleted, then we do not delete the bib. Signed-off-by: Jason Stephenson --- lib/NCIP/ILS/Evergreen.pm | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/NCIP/ILS/Evergreen.pm b/lib/NCIP/ILS/Evergreen.pm index 996b737..0e2a174 100644 --- a/lib/NCIP/ILS/Evergreen.pm +++ b/lib/NCIP/ILS/Evergreen.pm @@ -1327,7 +1327,7 @@ sub delete_copy { 'open-ils.pcrud.retrieve.acn', $self->{session}->{authtoken}, $copy->call_number(), - {flesh => 1, flesh_fields => {acn => ['record']}} + {flesh => 2, flesh_fields => {acn => ['record'], bre => ['call_numbers']}} )->gather(1); if ($acn) { # Get the bib and deflesh the acn. @@ -1343,17 +1343,16 @@ sub delete_copy { if ($r) { # Check if we created the bib. if ($bib->creator() == $self->{session}->{user}->id()) { - $r = $session->request( - 'open-ils.pcrud.delete.bre', - $self->{session}->{authtoken}, - $bib - )->gather(1); + # Check for other call numbers on the bib: + my @vols = map {$_->id() != $acn->id() && !$U->is_true($_->deleted())} @{$bib->call_numbers()}; + unless (@vols) { + $r = $session->request( + 'open-ils.pcrud.delete.bre', + $self->{session}->{authtoken}, + $bib + )->gather(1); + } } - # We should probably check for other call - # numbers on the bib, first, but no one - # else should be using the bib - # record. We'll add that check if it ever - # happens in the real world. } } } -- 2.43.2