Skip to content

Commit

Permalink
Merge pull request #208 from ResearchCollectionsAndPreservation/stage…
Browse files Browse the repository at this point in the history
…3-dev

Stage3 dev
  • Loading branch information
srinduri04 authored Aug 26, 2021
2 parents 109fd6b + 231e283 commit 20311d4
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 23 deletions.
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
# scsb-circ
## SCSB-CIRC

The SCSB Middleware codebase and components are all licensed under the Apache 2.0 license, with the exception of a set of API design components (JSF, JQuery, and Angular JS), which are licensed under MIT X11.

SCSB-CIRC is a microservice application that provides the core functionalities for request scenarios. All the requests received are handled and processed in this application. Other major processes handled are Submit Collection, Bulk Request Process, Accession Reconciliation process, Status Reconciliation process, Daily Reconciliation process. All the SIP calls to the ILS and IMS are made through this application.

//TeXt Added for testing
## Software Required

- Java 11
- Docker 19.03.13

## Prerequisite

1.**Cloud Config Server**

Dspring.cloud.config.uri=http://phase4-scsb-config-server:8888

## Build

Download the Project , navigate inside project folder and build the project using below command

**./gradlew clean build -x test**

## Docker Image Creation

Naviagte Inside project folder where Dockerfile is present and Execute the below command

**sudo docker build -t phase4-scsb-circ .**

## Docker Run

User the below command to Run the Docker

**sudo docker run --name phase4-scsb-circ -v /data:/recap-vol --label collect_logs_with_filebeat="true" --label decode_log_event_to_json_object="true" -p 9095:9095 -e "ENV= -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/recap-vol/scsb-circ/heapdump/ -Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*" -Dspring.cloud.config.uri=http://phase4-scsb-config-server:8888 " --network=scsb -d phase4-scsb-circ**
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repositories {


dependencies {
compile fileTree(dir: '/data/commonjar',include: '*1.6.jar')
compile fileTree(dir: '/data/commonjar',include: '*1.6.1.jar')
compile fileTree(dir: '/data/commonjar', include: 'jsip2-1.1.0.jar')
compile fileTree(dir: '/data/commonjar', include: 'ncip.jar')
implementation 'org.projectlombok:lombok:1.18.12'
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/recap/ScsbConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ public final class ScsbConstants {

public static final String GFA_SERVICE_PARAM = "filter";

public static final String GFA_STATUS_NOT_ON_FILE = "NOT ON FILE";
public static final String GFA_STATUS_SCH_ON_REFILE_WORK_ORDER = "SCH ON REFILE WO:";
public static final String CANNOT_REFILE_FIRST_SCAN_REQUEST ="Cannot place recall for requests placed on first scan LAS status";
public static final String REQUESTS_STUCK_IN_PENDING = "Requests stuck in pending";
public static final String NO_PENDING_REQUESTS_FOUND = "There are no pending requests or no new pending request";
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/recap/ims/service/GFALasService.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,20 @@ public ItemInformationResponse executeRetrieveOrder(ItemRequestInformation itemR
if (StringUtils.isBlank(itemRequestInfo.getImsLocationCode())) {
itemResponseInformation.setSuccess(false);
itemResponseInformation.setScreenMessage(ScsbConstants.REQUEST_SCSB_EXCEPTION + ScsbConstants.IMS_LOCATION_CODE_BLANK_ERROR);
} else if (commonUtil.checkIfImsItemStatusIsRequestableNotRetrievable(itemRequestInfo.getImsLocationCode(), gfaOnlyStatus)) {
log.info("Request Received while GFA status is Sch on Refile WO");
itemResponseInformation.setRequestTypeForScheduledOnWO(true);
itemResponseInformation.setSuccess(true);
itemResponseInformation.setScreenMessage(ScsbConstants.GFA_RETRIVAL_ORDER_SUCCESSFUL);
} else if (commonUtil.checkIfImsItemStatusIsAvailableOrNotAvailable(itemRequestInfo.getImsLocationCode(), gfaOnlyStatus, true)) {
if (itemRequestInfo.getRequestType().equalsIgnoreCase(ScsbCommonConstants.REQUEST_TYPE_RETRIEVAL)) {
itemResponseInformation = callItemRetrievable(itemRequestInfo, itemResponseInformation);
} else if (itemRequestInfo.getRequestType().equalsIgnoreCase(ScsbCommonConstants.REQUEST_TYPE_EDD)) {
itemResponseInformation = callItemEDDRetrievable(itemRequestInfo, itemResponseInformation);
}
} else if (ScsbConstants.GFA_STATUS_SCH_ON_REFILE_WORK_ORDER.toLowerCase().contains(gfaOnlyStatus.toLowerCase())) {
log.info("Request Received while GFA status is Sch on Refile WO");
itemResponseInformation.setRequestTypeForScheduledOnWO(true);
itemResponseInformation.setSuccess(true);
itemResponseInformation.setScreenMessage(ScsbConstants.GFA_RETRIVAL_ORDER_SUCCESSFUL);
} else {
itemResponseInformation.setSuccess(false);
itemResponseInformation.setScreenMessage(ScsbConstants.GFA_RETRIVAL_ITEM_NOT_AVAILABLE);
itemResponseInformation.setScreenMessage(ScsbConstants.GFA_RETRIVAL_ITEM_NOT_AVAILABLE + " (" + itemStatus + ")");
}
} else {
lasPolling(itemRequestInfo, itemResponseInformation);
Expand Down Expand Up @@ -516,13 +516,13 @@ public String buildRequestInfoAndReplaceToLAS(RequestItemEntity requestItemEntit
ItemRequestInformation itemRequestInformation = itemRequestService.getItemRequestInformationByRequestEntity(requestItemEntity, requestItemEntity.getItemEntity());
String itemStatus = callGfaItemStatus(requestItemEntity.getItemEntity().getBarcode());
String imsLocationCode = commonUtil.getImsLocationCodeByItemBarcode(requestItemEntity.getItemEntity().getBarcode());
if (commonUtil.checkIfImsItemStatusIsAvailableOrNotAvailable(imsLocationCode, itemStatus, true)) {
producerTemplate.sendBodyAndHeader(ScsbConstants.SCSB_LAS_OUTGOING_QUEUE_PREFIX + imsLocationCode + ScsbConstants.OUTGOING_QUEUE_SUFFIX, itemRequestInformation, ScsbCommonConstants.REQUEST_TYPE_QUEUE_HEADER, requestItemEntity.getRequestTypeEntity().getRequestTypeCode());
} else if (StringUtils.isNotBlank(itemStatus)) {
if (commonUtil.checkIfImsItemStatusIsRequestableNotRetrievable(imsLocationCode, itemStatus)) {
RequestStatusEntity requestStatusEntity = requestItemStatusDetailsRepository.findByRequestStatusCode(ScsbConstants.LAS_REFILE_REQUEST_PLACED);
requestItemEntity.setRequestStatusEntity(requestStatusEntity);
requestItemEntity.setRequestStatusId(requestStatusEntity.getId());
requestItemDetailsRepository.save(requestItemEntity);
} else if (commonUtil.checkIfImsItemStatusIsAvailableOrNotAvailable(imsLocationCode, itemStatus, true)) {
producerTemplate.sendBodyAndHeader(ScsbConstants.SCSB_LAS_OUTGOING_QUEUE_PREFIX + imsLocationCode + ScsbConstants.OUTGOING_QUEUE_SUFFIX, itemRequestInformation, ScsbCommonConstants.REQUEST_TYPE_QUEUE_HEADER, requestItemEntity.getRequestTypeEntity().getRequestTypeCode());
}
} catch (Exception exception) {
log.error(ScsbCommonConstants.REQUEST_EXCEPTION, exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,7 @@ public ItemRequestInformation getItemRequestInformationByRequestEntity(RequestIt
itemRequestInformation.setItemOwningInstitution(itemEntity.getInstitutionEntity().getInstitutionCode());
itemRequestInformation.setRequestType(requestItemEntity.getRequestTypeEntity().getRequestTypeCode());
itemRequestInformation.setDeliveryLocation(requestItemEntity.getStopCode());
itemRequestInformation.setTranslatedDeliveryLocation(requestItemEntity.getStopCode());
String imsLocationCode = commonUtil.getImsLocationCodeByItemBarcode(requestItemEntity.getItemEntity().getBarcode());
itemRequestInformation.setImsLocationCode(imsLocationCode);

Expand Down Expand Up @@ -1379,13 +1380,13 @@ private String setRequestItemEntity(ItemRequestInformation itemRequestInformatio
ObjectMapper objectMapper = new ObjectMapper();
String json = objectMapper.writeValueAsString(itemRequestInformation);
String itemStatus = gfaLasService.callGfaItemStatus(requestItemEntity.getItemEntity().getBarcode());
if (commonUtil.checkIfImsItemStatusIsAvailableOrNotAvailable(requestItemEntity.getItemEntity().getImsLocationEntity().getImsLocationCode(), itemStatus, true)) {
producerTemplate.sendBodyAndHeader(ScsbConstants.REQUEST_ITEM_QUEUE, json, ScsbCommonConstants.REQUEST_TYPE_QUEUE_HEADER, itemRequestInformation.getRequestType());
} else if (StringUtils.isNotBlank(itemStatus)) {
if (commonUtil.checkIfImsItemStatusIsRequestableNotRetrievable(requestItemEntity.getItemEntity().getImsLocationEntity().getImsLocationCode(), itemStatus)) {
RequestStatusEntity requestStatusEntity = requestItemStatusDetailsRepository.findByRequestStatusCode(ScsbConstants.LAS_REFILE_REQUEST_PLACED);
requestItemEntity.setRequestStatusEntity(requestStatusEntity);
requestItemEntity.setRequestStatusId(requestStatusEntity.getId());
requestItemDetailsRepository.save(requestItemEntity);
} else if (commonUtil.checkIfImsItemStatusIsAvailableOrNotAvailable(requestItemEntity.getItemEntity().getImsLocationEntity().getImsLocationCode(), itemStatus, true)) {
producerTemplate.sendBodyAndHeader(ScsbConstants.REQUEST_ITEM_QUEUE, json, ScsbCommonConstants.REQUEST_TYPE_QUEUE_HEADER, itemRequestInformation.getRequestType());
}
} catch (Exception exception) {
logger.error(ScsbCommonConstants.REQUEST_EXCEPTION, exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,10 @@ private void checkGfaItemStatus(List<DeAccessionItem> deAccessionItems, List<DeA
gfaItemStatus = gfaItemStatus.toUpperCase();
gfaItemStatus = gfaItemStatus.contains(":") ? gfaItemStatus.substring(0, gfaItemStatus.indexOf(':') + 1) : gfaItemStatus;
logger.info("GFA Item Status after trimming : {}", gfaItemStatus);
if ((StringUtils.isNotBlank(gfaItemStatus) && ScsbConstants.GFA_STATUS_SCH_ON_REFILE_WORK_ORDER.equals(gfaItemStatus))) {
if ((StringUtils.isNotBlank(gfaItemStatus) && commonUtil.checkIfImsItemStatusIsRequestableNotRetrievable(itemEntity.getImsLocationEntity().getImsLocationCode(), gfaItemStatus))) {
deAccessionDBResponseEntities.add(prepareFailureResponse(itemBarcode, deAccessionItem.getDeliveryLocation(), "Cannot Deaccession as Item is awaiting for Refile.Please try again later or contact ReCAP staff for further assistance.", itemEntity));
}
else if ((StringUtils.isNotBlank(gfaItemStatus) && !ScsbConstants.GFA_STATUS_NOT_ON_FILE.equalsIgnoreCase(gfaItemStatus))
else if (StringUtils.isNotBlank(gfaItemStatus)
&& ((ScsbCommonConstants.AVAILABLE.equals(scsbItemStatus) && commonUtil.checkIfImsItemStatusIsAvailableOrNotAvailable(itemEntity.getImsLocationEntity().getImsLocationCode(), gfaItemStatus, true))
|| (ScsbCommonConstants.NOT_AVAILABLE.equals(scsbItemStatus) && commonUtil.checkIfImsItemStatusIsAvailableOrNotAvailable(itemEntity.getImsLocationEntity().getImsLocationCode(), gfaItemStatus, false)))) {
barcodeAndStopCodeMap.put(itemBarcode.trim(), deAccessionItem.getDeliveryLocation());
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/recap/util/CommonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,17 @@ public boolean checkIfImsItemStatusIsAvailableOrNotAvailable(String imsLocationC
return StringUtils.startsWithAny(imsItemStatus, imsItemStatusCodes.split(","));
}

/**
* Checks if the IMS item status is requestable but not retrievable (In first scan)
* @param imsLocationCode IMS Location Code
* @param imsItemStatus IMS Item Status
* @return boolean
*/
public boolean checkIfImsItemStatusIsRequestableNotRetrievable(String imsLocationCode, String imsItemStatus) {
String imsItemStatusCodes = propertyUtil.getPropertyByImsLocationAndKey(imsLocationCode, PropertyKeyConstants.IMS.IMS_REQUESTABLE_NOT_RETRIEVABLE_ITEM_STATUS_CODES);
return StringUtils.isNotBlank(imsItemStatusCodes) && StringUtils.startsWithAny(imsItemStatus, imsItemStatusCodes.split(","));
}

public ItemRequestInformation getItemRequestInformation(ItemEntity itemEntity) {
ItemRequestInformation itemRequestInformation = new ItemRequestInformation();
itemRequestInformation.setItemBarcodes(Collections.singletonList(itemEntity.getBarcode()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,17 @@ public void testItemValidationForRECALL(){
frozenInstitutionPropertyMap.put(itemEntity.getInstitutionEntity().getInstitutionCode(),"FALSE");
Map<String, String> frozenInstitutionMessagesPropertyMap = new HashMap<>();
frozenInstitutionMessagesPropertyMap.put(itemEntity.getInstitutionEntity().getInstitutionCode(),"Test");
Mockito.when(institutionDetailsRepository.findByInstitutionCode(any())).thenReturn(getInstitutionEntity());
Mockito.when(imsLocationDetailsRepository.findById(any())).thenReturn(Optional.of(getImsLocationEntity()));
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_ENABLE_CIRCULATION_FREEZE)).thenReturn(frozenInstitutionPropertyMap);
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_CIRCULATION_FREEZE_MESSAGE)).thenReturn(frozenInstitutionMessagesPropertyMap);
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_RECALL_FUNCTIONALITY_AVAILABLE)).thenReturn(frozenInstitutionMessagesPropertyMap);
Mockito.when(itemController.findByBarcodeIn(itemBarcodes.toString())).thenReturn(Arrays.asList(itemEntity));
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndOwningInstitutionCode(any(),any())).thenReturn(ownerCodeEntity);
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndRequestingInstitution(any(),any(),anyString())).thenReturn(Collections.EMPTY_LIST);
// Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndOwningInstitutionCode(any(),any())).thenReturn(ownerCodeEntity);
// Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndRequestingInstitution(any(),any(),anyString())).thenReturn(Collections.EMPTY_LIST);
itemValidatorService.itemValidation(itemRequestInformation);
Mockito.when(institutionDetailsRepository.findByInstitutionCode(any())).thenReturn(getInstitutionEntity());
Mockito.when(deliveryCodeDetailsRepository.findByDeliveryCodeAndOwningInstitutionIdAndActive(any(), any(), anyChar())).thenReturn(getDeliveryCodeEntity());
// Mockito.when(deliveryCodeDetailsRepository.findByDeliveryCodeAndOwningInstitutionIdAndActive(any(), any(), anyChar())).thenReturn(getDeliveryCodeEntity());
Mockito.when(imsLocationDetailsRepository.findById(any())).thenReturn(Optional.of(imsLocationEntity));
itemValidatorService.itemValidation(itemRequestInformation);
ItemRequestInformation itemRequestInformation1 = getItemRequestInformation(itemBarcodes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public void checkGfaItemStatusSchOnStatus() {
DeAccessionDBResponseEntity deAccessionDBResponseEntity = getDeAccessionDBResponseEntity();
deAccessionDBResponseEntities.add(deAccessionDBResponseEntity);
Map<String, String> barcodeAndStopCodeMap = new HashMap<>();
Mockito.when(gfaLasService.callGfaItemStatus(any())).thenReturn(ScsbConstants.GFA_STATUS_SCH_ON_REFILE_WORK_ORDER);
Mockito.when(gfaLasService.callGfaItemStatus(any())).thenReturn("SCH ON REFILE WO:");
Mockito.when(itemDetailsRepository.findByBarcode(any())).thenReturn(Arrays.asList(itemEntity));
ReflectionTestUtils.invokeMethod(deAccessionService, "checkGfaItemStatus", deAccessionItems, deAccessionDBResponseEntities, barcodeAndStopCodeMap);
}
Expand Down

0 comments on commit 20311d4

Please sign in to comment.