Skip to content

Commit

Permalink
MODDCB-90 Accept existing circulation request ID
Browse files Browse the repository at this point in the history
  • Loading branch information
MagzhanArtykov committed Mar 4, 2024
1 parent 121427f commit 287d750
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public class EcsTlrTransactionApiController implements EcsRequestTransactionsApi

@Override
public ResponseEntity<TransactionStatusResponse> createEcsRequestTransactions(
String ecsTlrTransactionId, DcbTransaction dcbTransaction) {
String ecsTlrTransactionsId, DcbTransaction dcbTransaction) {
log.info("createEcsTlrTransaction:: creating ECS TLR Transaction {} with id {} ",
dcbTransaction, ecsTlrTransactionId);
dcbTransaction, ecsTlrTransactionsId);
TransactionStatusResponse transactionStatusResponse;
try {
transactionStatusResponse = ecsTlrTransactionsService.createEcsTlrTransaction(
ecsTlrTransactionId, dcbTransaction);
transactionStatusResponse = ecsTlrTransactionsService.createEcsTlrTransactions(
ecsTlrTransactionsId, dcbTransaction);
} catch (Exception ex) {
transactionAuditService.logErrorIfTransactionAuditNotExists(ecsTlrTransactionId,
transactionAuditService.logErrorIfTransactionAuditNotExists(ecsTlrTransactionsId,
dcbTransaction, ex.getMessage());
throw ex;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
import org.folio.dcb.domain.dto.TransactionStatusResponse;

public interface EcsTlrTransactionsService {
TransactionStatusResponse createEcsTlrTransaction(String dcbTransactionId, DcbTransaction dcbTransaction);
TransactionStatusResponse createEcsTlrTransactions(String ecsTlrTransactionsId, DcbTransaction dcbTransaction);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ public class EcsTlrTransactionsServiceImpl implements EcsTlrTransactionsService
private final CirculationRequestService circulationRequestService;

@Override
public TransactionStatusResponse createEcsTlrTransaction(String dcbTransactionId, DcbTransaction dcbTransaction) {
public TransactionStatusResponse createEcsTlrTransactions(String ecsTlrTransactionsId,
DcbTransaction dcbTransaction) {
log.info("createCirculationRequest:: creating new transaction request for role {} ",
dcbTransaction.getRole());
checkEcsTransactionExistsAndThrow(dcbTransactionId);
CirculationRequest circulationRequest = circulationRequestService.fetchRequestById(dcbTransaction.getRequestId());
if(circulationRequest != null && RequestStatus.isRequestOpen(RequestStatus.from(circulationRequest.getStatus()))) {
checkEcsTransactionExistsAndThrow(ecsTlrTransactionsId);
CirculationRequest circulationRequest = circulationRequestService.fetchRequestById(
dcbTransaction.getRequestId());
if(circulationRequest != null && RequestStatus.isRequestOpen(
RequestStatus.from(circulationRequest.getStatus()))) {
if (dcbTransaction.getRole() == LENDER) {
dcbTransaction.setItem(DcbItem.builder()
.id(String.valueOf(circulationRequest.getItemId()))
Expand All @@ -44,7 +47,8 @@ public TransactionStatusResponse createEcsTlrTransaction(String dcbTransactionId
dcbTransaction.setPickup(DcbPickup.builder()
.servicePointId(String.valueOf(circulationRequest.getPickupServicePointId()))
.build());
baseLibraryService.saveDcbTransaction(dcbTransactionId, dcbTransaction, dcbTransaction.getRequestId());
baseLibraryService.saveDcbTransaction(ecsTlrTransactionsId, dcbTransaction,
dcbTransaction.getRequestId());
} else {
throw new IllegalArgumentException("Unimplemented role: " + dcbTransaction.getRole());
}
Expand Down

0 comments on commit 287d750

Please sign in to comment.