use of org.folio.circulation.domain.representations.ChangeItemStatusRequest in project mod-circulation by folio-org.
the class DeclareClaimedReturnedItemAsMissingResource method createRequest.
private Result<ChangeItemStatusRequest> createRequest(RoutingContext routingContext) {
final String loanId = routingContext.pathParam("id");
final JsonObject body = routingContext.getBodyAsJson();
final ChangeItemStatusRequest request = ChangeItemStatusRequest.from(loanId, body);
if (request.getComment() == null) {
return failed(singleValidationError("Comment is a required field", "comment", null));
}
return succeeded(request);
}
use of org.folio.circulation.domain.representations.ChangeItemStatusRequest in project mod-circulation by folio-org.
the class DeclareClaimedReturnedItemAsMissingResource method processDeclareClaimedReturnedItemAsMissing.
private CompletableFuture<Result<Loan>> processDeclareClaimedReturnedItemAsMissing(RoutingContext routingContext, ChangeItemStatusRequest 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(NotInItemStatusValidator::refuseWhenItemIsNotClaimedReturned).thenApply(r -> declareLoanMissing(r, request)).thenCompose(changeItemStatusService::updateLoanAndItem).thenCompose(r -> r.after(loan -> createNote(clients, loan)));
}
use of org.folio.circulation.domain.representations.ChangeItemStatusRequest in project mod-circulation by folio-org.
the class ClaimItemReturnedRequest method from.
public static ClaimItemReturnedRequest from(String loanId, JsonObject body) {
final ChangeItemStatusRequest changeStatusRequest = ChangeItemStatusRequest.from(loanId, body);
final ZonedDateTime itemClaimedReturnedDate = JsonPropertyFetcher.getDateTimeProperty(body, ITEM_CLAIMED_RETURNED_DATE);
return new ClaimItemReturnedRequest(loanId, itemClaimedReturnedDate, changeStatusRequest.getComment());
}
Aggregations