From a5de8ec8c9b1225ceb463034c246b92c055e61a3 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Tue, 27 Oct 2015 12:32:46 -0400 Subject: [PATCH] Add creation of hold notes in NCIP::ILS::Evergreen. We'll use the hold notes to store the RequestIdentifierValue that we're given in the RequestItem and AcceptItem messages. We'll use that note to find the appropriate hold for cancellation with the CancelRequestItem message, later. NOTE: This commit requires that the UPDATE_HOLD permission be granted to the NCIPServer staff user at the consortium level, i.e. depth 0. Signed-off-by: Jason Stephenson --- lib/NCIP/ILS/Evergreen.pm | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/NCIP/ILS/Evergreen.pm b/lib/NCIP/ILS/Evergreen.pm index 45ad829..1ee1b58 100644 --- a/lib/NCIP/ILS/Evergreen.pm +++ b/lib/NCIP/ILS/Evergreen.pm @@ -307,6 +307,10 @@ sub acceptitem { return $response; } + # Add a hold note with the RequestIdentifierValue for later + # lookup in CancelRequestItem. We do not care if it fails. + $self->create_hold_note($hold, 'NCIP Remote Request ID', $request->{$message}->{RequestId}->{RequestIdentifierValue}); + # We return the RequestId and optionally, the ItemID. We'll # just return what was sent to us, since we ignored all of it # but the barcode. @@ -1004,6 +1008,9 @@ sub requestitem { if (ref($hold) eq 'NCIP::Problem') { $response->problem($hold); } else { + # Add a hold note with the RequestIdentifierValue for later + # lookup in CancelRequestItem. We do not care if it fails. + $self->create_hold_note($hold, 'NCIP Remote Request ID', $request->{$message}->{RequestId}->{RequestIdentifierValue}); my $data = { RequestId => NCIP::RequestId->new( $request->{$message}->{RequestId} @@ -2364,6 +2371,46 @@ sub cancel_hold { return $r; } +=head2 create_hold_note + + $note = $ils->create_hold_note($hold, $title, $body); + +This method creates a nold note with title of $title and body of $body +on $hold. It is used to store the RequestIdentifierValue from the +RequestItem message so that we can later retrieve holds using that ID +in order to cancel them. + +It returns a note object on success and undef on failure. + +=cut + +sub create_hold_note { + my $self = shift; + my $hold = shift; + my $title = shift; + my $body = shift; + + my $note = Fieldmapper::action::hold_request_note->new(); + $note->isnew(1); + $note->hold($hold->id()); + $note->title($title); + $note->body($body); + $note->slip(0); + $note->pub(0); + $note->staff(0); + my $result = $U->simplereq( + 'open-ils.circ', + 'open-ils.circ.hold_request.note.cud', + $self->{session}->{authtoken}, + $note + ); + if (not ref($result)) { + $note->id($result); + return $note; + } + return undef; +} + =head2 delete_copy $ils->delete_copy($copy); -- 2.43.2