use of org.folio.circulation.domain.ClaimItemReturnedRequest in project mod-circulation by folio-org.
the class ClaimItemReturnedResource method createRequest.
private Result<ClaimItemReturnedRequest> createRequest(RoutingContext routingContext) {
final String loanId = routingContext.pathParam("id");
final JsonObject body = routingContext.getBodyAsJson();
final ClaimItemReturnedRequest request = ClaimItemReturnedRequest.from(loanId, body);
if (request.getItemClaimedReturnedDateTime() == null) {
return failed(singleValidationError("Item claimed returned date is a required field", ITEM_CLAIMED_RETURNED_DATE, null));
}
return succeeded(ClaimItemReturnedRequest.from(loanId, body));
}
use of org.folio.circulation.domain.ClaimItemReturnedRequest in project mod-circulation by folio-org.
the class ClaimItemReturnedResource method processClaimItemReturned.
private CompletableFuture<Result<Loan>> processClaimItemReturned(RoutingContext routingContext, ClaimItemReturnedRequest request) {
final Clients clients = Clients.create(new WebContext(routingContext), client);
final var itemRepository = new ItemRepository(clients);
final var userRepository = new UserRepository(clients);
final var loanRepository = new LoanRepository(clients, itemRepository, userRepository);
final ChangeItemStatusService changeItemStatusService = new ChangeItemStatusService(loanRepository, new StoreLoanAndItem(loanRepository, itemRepository));
return changeItemStatusService.getOpenLoan(request).thenApply(loan -> declareLoanClaimedReturned(loan, request)).thenCompose(changeItemStatusService::updateLoanAndItem);
}
Aggregations