Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr 1777 #11

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -12,12 +14,14 @@
import org.extensiblecatalog.ncip.v2.service.CheckOutItemService;
import org.extensiblecatalog.ncip.v2.service.ItemId;
import org.extensiblecatalog.ncip.v2.service.ItemIdentifierType;
import org.extensiblecatalog.ncip.v2.service.ItemOptionalFields;
import org.extensiblecatalog.ncip.v2.service.Problem;
import org.extensiblecatalog.ncip.v2.service.ProblemType;
import org.extensiblecatalog.ncip.v2.service.RemoteServiceManager;
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 All @@ -37,6 +41,7 @@ public CheckOutItemResponseData performService(CheckOutItemInitiationData initDa
ItemId itemId = initData.getItemId();
UserId userId = retrieveUserId(initData);
String dueDate = null;
String loanUuid = null;
try {
validateUserId(userId);
validateItemId(itemId);
Expand Down Expand Up @@ -79,6 +84,7 @@ public CheckOutItemResponseData performService(CheckOutItemInitiationData initDa
//THE SERVICE MANAGER CALLS THE OKAPI APIs
JsonObject checkOutItemResponseDetails = ((FolioRemoteServiceManager)serviceManager).checkOut(initData,requesterAgencyId.toLowerCase());
dueDate = checkOutItemResponseDetails.getString("dueDate");
loanUuid = checkOutItemResponseDetails.getString("id");
//DUE DATE PARSE STARTED FAILING 11-2020
//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Expand Down Expand Up @@ -110,6 +116,12 @@ public CheckOutItemResponseData performService(CheckOutItemInitiationData initDa
responseData.setDateDue(calendar);
responseData.setItemId(iId);
responseData.setUserId(uId);
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));
}
}
Loading