Search in sources :

Example 1 with ClosedLibraryStrategyService

use of org.folio.circulation.domain.policy.library.ClosedLibraryStrategyService in project mod-circulation by folio-org.

the class CheckOutByBarcodeResource method checkOut.

private CompletableFuture<Result<LoanAndRelatedRecords>> checkOut(LoanAndRelatedRecords relatedRecords, JsonObject request, Clients clients) {
    ZonedDateTime loanDate = relatedRecords.getLoan().getLoanDate();
    final ClosedLibraryStrategyService strategyService = ClosedLibraryStrategyService.using(clients, loanDate, false);
    if (CHECKED_OUT_THROUGH_OVERRIDE.getValue().equals(relatedRecords.getLoan().getAction()) && relatedRecords.getLoan().hasDueDateChanged()) {
        return completedFuture(succeeded(relatedRecords));
    }
    return completedFuture(succeeded(relatedRecords)).thenApply(r -> r.next(this::calculateDefaultInitialDueDate)).thenCompose(r -> r.after(strategyService::applyClosedLibraryDueDateManagement));
}
Also used : UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) UpdateRequestQueue(org.folio.circulation.domain.UpdateRequestQueue) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository) ConfigurationRepository(org.folio.circulation.infrastructure.storage.ConfigurationRepository) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) ZonedDateTime(java.time.ZonedDateTime) RequestQueueRepository(org.folio.circulation.infrastructure.storage.requests.RequestQueueRepository) LoanPolicyRepository(org.folio.circulation.infrastructure.storage.loans.LoanPolicyRepository) Router(io.vertx.ext.web.Router) RoutingContext(io.vertx.ext.web.RoutingContext) ClosedLibraryStrategyService(org.folio.circulation.domain.policy.library.ClosedLibraryStrategyService) CheckOutByBarcodeRequest(org.folio.circulation.domain.representations.CheckOutByBarcodeRequest) FAILED_TO_FETCH_PROXY_USER(org.folio.circulation.resources.handlers.error.CirculationErrorType.FAILED_TO_FETCH_PROXY_USER) LoanAndRelatedRecords(org.folio.circulation.domain.LoanAndRelatedRecords) LostItemPolicyRepository(org.folio.circulation.infrastructure.storage.loans.LostItemPolicyRepository) PatronNoticePolicyRepository(org.folio.circulation.infrastructure.storage.notices.PatronNoticePolicyRepository) FAILED_TO_FETCH_ITEM(org.folio.circulation.resources.handlers.error.CirculationErrorType.FAILED_TO_FETCH_ITEM) JsonObject(io.vertx.core.json.JsonObject) LoanScheduledNoticeService(org.folio.circulation.domain.notice.schedule.LoanScheduledNoticeService) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) Result.succeeded(org.folio.circulation.support.results.Result.succeeded) Loan(org.folio.circulation.domain.Loan) FAILED_TO_PUBLISH_CHECKOUT_EVENT(org.folio.circulation.resources.handlers.error.CirculationErrorType.FAILED_TO_PUBLISH_CHECKOUT_EVENT) Result(org.folio.circulation.support.results.Result) LoanPolicy(org.folio.circulation.domain.policy.LoanPolicy) EventPublisher(org.folio.circulation.services.EventPublisher) RouteRegistration(org.folio.circulation.support.RouteRegistration) LoanRepresentation(org.folio.circulation.domain.LoanRepresentation) PatronActionSessionService(org.folio.circulation.domain.notice.session.PatronActionSessionService) LoanService(org.folio.circulation.domain.LoanService) CirculationErrorType(org.folio.circulation.resources.handlers.error.CirculationErrorType) CHECKED_OUT_THROUGH_OVERRIDE(org.folio.circulation.domain.LoanAction.CHECKED_OUT_THROUGH_OVERRIDE) CheckOutValidators(org.folio.circulation.domain.validation.CheckOutValidators) RequestRepository(org.folio.circulation.infrastructure.storage.requests.RequestRepository) HttpClient(io.vertx.core.http.HttpClient) Clients(org.folio.circulation.support.Clients) OverdueFinePolicyRepository(org.folio.circulation.infrastructure.storage.loans.OverdueFinePolicyRepository) WebContext(org.folio.circulation.support.http.server.WebContext) CompletableFuture(java.util.concurrent.CompletableFuture) FAILED_TO_SAVE_SESSION_RECORD(org.folio.circulation.resources.handlers.error.CirculationErrorType.FAILED_TO_SAVE_SESSION_RECORD) HttpResponse(org.folio.circulation.support.http.server.HttpResponse) JsonHttpResponse.ok(org.folio.circulation.support.http.server.JsonHttpResponse.ok) OkapiPermissions(org.folio.circulation.support.http.OkapiPermissions) RequestQueue(org.folio.circulation.domain.RequestQueue) ScheduledNoticesRepository(org.folio.circulation.infrastructure.storage.notices.ScheduledNoticesRepository) OverridingErrorHandler(org.folio.circulation.resources.handlers.error.OverridingErrorHandler) FAILED_TO_FETCH_USER(org.folio.circulation.resources.handlers.error.CirculationErrorType.FAILED_TO_FETCH_USER) PatronActionSessionRepository(org.folio.circulation.infrastructure.storage.sessions.PatronActionSessionRepository) Result.ofAsync(org.folio.circulation.support.results.Result.ofAsync) CirculationErrorHandler(org.folio.circulation.resources.handlers.error.CirculationErrorHandler) JsonHttpResponse.created(org.folio.circulation.support.http.server.JsonHttpResponse.created) CHECKED_OUT(org.folio.circulation.domain.ItemStatus.CHECKED_OUT) PatronGroupRepository(org.folio.circulation.infrastructure.storage.users.PatronGroupRepository) ZonedDateTime(java.time.ZonedDateTime) ClosedLibraryStrategyService(org.folio.circulation.domain.policy.library.ClosedLibraryStrategyService)

Example 2 with ClosedLibraryStrategyService

use of org.folio.circulation.domain.policy.library.ClosedLibraryStrategyService in project mod-circulation by folio-org.

the class RenewalResource method renew.

private CompletableFuture<Result<RenewalContext>> renew(RenewalContext renewalContext, Clients clients, CirculationErrorHandler errorHandler) {
    if (errorHandler.hasAny(ITEM_DOES_NOT_EXIST, FAILED_TO_FIND_SINGLE_OPEN_LOAN, FAILED_TO_FETCH_USER)) {
        return completedFuture(succeeded(renewalContext));
    }
    if (isRenewalBlockOverrideRequested) {
        return renewThroughOverride(renewalContext).thenApply(r -> errorHandler.handleValidationResult(r, RENEWAL_VALIDATION_ERROR, renewalContext));
    }
    ZonedDateTime systemTime = ClockUtil.getZonedDateTime();
    final ClosedLibraryStrategyService strategyService = ClosedLibraryStrategyService.using(clients, systemTime, true);
    return regularRenew(renewalContext, errorHandler, systemTime).after(strategyService::applyClosedLibraryDueDateManagement);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) ClosedLibraryStrategyService(org.folio.circulation.domain.policy.library.ClosedLibraryStrategyService)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)2 ClosedLibraryStrategyService (org.folio.circulation.domain.policy.library.ClosedLibraryStrategyService)2 HttpClient (io.vertx.core.http.HttpClient)1 JsonObject (io.vertx.core.json.JsonObject)1 Router (io.vertx.ext.web.Router)1 RoutingContext (io.vertx.ext.web.RoutingContext)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 CHECKED_OUT (org.folio.circulation.domain.ItemStatus.CHECKED_OUT)1 Loan (org.folio.circulation.domain.Loan)1 CHECKED_OUT_THROUGH_OVERRIDE (org.folio.circulation.domain.LoanAction.CHECKED_OUT_THROUGH_OVERRIDE)1 LoanAndRelatedRecords (org.folio.circulation.domain.LoanAndRelatedRecords)1 LoanRepresentation (org.folio.circulation.domain.LoanRepresentation)1 LoanService (org.folio.circulation.domain.LoanService)1 RequestQueue (org.folio.circulation.domain.RequestQueue)1 UpdateRequestQueue (org.folio.circulation.domain.UpdateRequestQueue)1 LoanScheduledNoticeService (org.folio.circulation.domain.notice.schedule.LoanScheduledNoticeService)1 PatronActionSessionService (org.folio.circulation.domain.notice.session.PatronActionSessionService)1 LoanPolicy (org.folio.circulation.domain.policy.LoanPolicy)1 CheckOutByBarcodeRequest (org.folio.circulation.domain.representations.CheckOutByBarcodeRequest)1