Skip to content

Commit

Permalink
PR-1777 Return requester id in request item call
Browse files Browse the repository at this point in the history
  • Loading branch information
JanisSaldabols committed Jun 3, 2024
1 parent 9edf190 commit 7662d35
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

import org.apache.log4j.Logger;
import org.extensiblecatalog.ncip.v2.service.AgencyId;
import org.extensiblecatalog.ncip.v2.service.AuthenticationInput;
Expand All @@ -19,6 +21,7 @@
import org.extensiblecatalog.ncip.v2.service.ServiceContext;
import org.extensiblecatalog.ncip.v2.service.UserId;
import org.extensiblecatalog.ncip.v2.service.UserIdentifierType;
import org.extensiblecatalog.ncip.v2.service.UserOptionalFields;
import org.folio.ncip.Constants;
import org.folio.ncip.FolioRemoteServiceManager;

Expand Down Expand Up @@ -113,9 +116,12 @@ public CheckOutItemResponseData performService(CheckOutItemInitiationData initDa
responseData.setDateDue(calendar);
responseData.setItemId(iId);
responseData.setUserId(uId);
ItemOptionalFields o = new ItemOptionalFields();
o.setHoldQueue(loanUuid);
responseData.setItemOptionalFields(o);
UserId loanId = new UserId();
loanId.setUserIdentifierValue(loanUuid);
loanId.setUserIdentifierType(new UserIdentifierType(Constants.SCHEME, "loanUuid"));
UserOptionalFields userOptionalFields = new UserOptionalFields();
userOptionalFields.setUserIds(List.of(loanId));
responseData.setUserOptionalFields(userOptionalFields);

return responseData;
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/folio/ncip/services/FolioRequestItemService.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.extensiblecatalog.ncip.v2.service.RequestType;
import org.extensiblecatalog.ncip.v2.service.ServiceContext;
import org.extensiblecatalog.ncip.v2.service.UserId;
import org.extensiblecatalog.ncip.v2.service.UserIdentifierType;
import org.extensiblecatalog.ncip.v2.service.UserOptionalFields;
import org.folio.ncip.Constants;
import org.folio.ncip.FolioNcipException;
import org.folio.ncip.FolioRemoteServiceManager;
Expand Down Expand Up @@ -73,10 +75,12 @@ public RequestItemResponseData performService(RequestItemInitiationData initData
RequestId ncipRequestId = new RequestId();
ItemDescription itemDescription = new ItemDescription();
LocationNameInstance locationNameInstance = new LocationNameInstance();
UserId optionalUserId = new UserId();
try {
JsonObject requestItemResponseDetails = ((FolioRemoteServiceManager)serviceManager)
.requestItem(bibliographicId.getBibliographicRecordId().getBibliographicRecordIdentifier(), userId, titleRequest, requestType, pickUpLocationCode);
String assignedRequestId = requestItemResponseDetails.getString("id");
String requesterId = requestItemResponseDetails.getString("requesterId");
String barcode = null;
String callNumber = null;
String locationName = null;
Expand All @@ -92,6 +96,7 @@ public RequestItemResponseData performService(RequestItemInitiationData initData
itemDescription.setCallNumber(callNumber);
locationNameInstance.setLocationNameValue(locationName);
itemId.setItemIdentifierValue(barcode);
optionalUserId.setUserIdentifierValue(requesterId);
}
catch(Exception exception) {
logger.error("Failed to Page RequestItem " + exception.getLocalizedMessage());
Expand All @@ -112,13 +117,19 @@ public RequestItemResponseData performService(RequestItemInitiationData initData
itemOptionalFields.setLocations(List.of(location));
itemId.setItemIdentifierType(itemIdentifierType);
ncipRequestId.setRequestIdentifierType(requestIdentifierType);

optionalUserId.setUserIdentifierType(new UserIdentifierType(Constants.SCHEME,"uuid"));
UserOptionalFields userOptionalFields = new UserOptionalFields();
userOptionalFields.setUserIds(List.of(optionalUserId));

RequestItemResponseData requestItemResponseData = new RequestItemResponseData();
requestItemResponseData.setItemId(itemId);
requestItemResponseData.setRequestId(ncipRequestId);
requestItemResponseData.setUserId(userId);
requestItemResponseData.setItemOptionalFields(itemOptionalFields);
requestItemResponseData.setRequestType(new RequestType(Constants.SCHEME, Constants.PAGE));
requestItemResponseData.setRequestScopeType(new RequestScopeType(Constants.SCHEME, Constants.ITEM));
requestItemResponseData.setUserOptionalFields(userOptionalFields);
return requestItemResponseData;
}

Expand Down
3 changes: 3 additions & 0 deletions src/test/java/org/folio/ncip/RequestItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class RequestItem extends TestBase {
private static final String ITEM_IDENTIFIER = "<ns1:ItemIdentifierValue>0000005</ns1:ItemIdentifierValue>";
private static final String CALL_NUMBER = "<ns1:CallNumber>58.95</ns1:CallNumber>";
private static final String LOCATION = "Annex : Datalogisk Institut";
private static final String REQUESTER_ID = "764fe3bf-e09b-4fcc-b4a9-c78aab6995f1";

/**
* @throws java.lang.Exception
Expand All @@ -41,6 +42,7 @@ public void callRequestItem() throws MalformedURLException {
assertTrue(body.contains(ITEM_IDENTIFIER));
assertTrue(body.contains(CALL_NUMBER));
assertTrue(body.contains(LOCATION));
assertTrue(body.contains(REQUESTER_ID));
}


Expand All @@ -55,5 +57,6 @@ public void callRequestItemTitle() throws MalformedURLException {
assertTrue(body.contains(ITEM_IDENTIFIER));
assertTrue(body.contains(CALL_NUMBER));
assertTrue(body.contains(LOCATION));
assertTrue(body.contains(REQUESTER_ID));
}
}

0 comments on commit 7662d35

Please sign in to comment.