Search in sources :

Example 1 with MoveRequestProcessAdapter

use of org.folio.circulation.domain.MoveRequestProcessAdapter in project mod-circulation by folio-org.

the class RequestCollectionResource method move.

void move(RoutingContext routingContext) {
    final var context = new WebContext(routingContext);
    final var clients = Clients.create(context, client);
    final var representation = routingContext.getBodyAsJson();
    final var id = getRequestId(routingContext);
    final var itemRepository = new ItemRepository(clients);
    final var userRepository = new UserRepository(clients);
    final var loanRepository = new LoanRepository(clients, itemRepository, userRepository);
    final var requestRepository = RequestRepository.using(clients, itemRepository, userRepository, loanRepository);
    final var requestQueueRepository = new RequestQueueRepository(requestRepository);
    final var loanPolicyRepository = new LoanPolicyRepository(clients);
    final var configurationRepository = new ConfigurationRepository(clients);
    final var updateUponRequest = new UpdateUponRequest(new UpdateItem(itemRepository), new UpdateLoan(clients, loanRepository, loanPolicyRepository), UpdateRequestQueue.using(clients, requestRepository, requestQueueRepository));
    final var moveRequestProcessAdapter = new MoveRequestProcessAdapter(itemRepository, loanRepository, requestRepository);
    final var eventPublisher = new EventPublisher(routingContext);
    final var moveRequestService = new MoveRequestService(requestRepository, new RequestPolicyRepository(clients), updateUponRequest, moveRequestProcessAdapter, new RequestLoanValidator(new ItemByInstanceIdFinder(clients.holdingsStorage(), itemRepository), loanRepository), RequestNoticeSender.using(clients), configurationRepository, eventPublisher, requestQueueRepository);
    fromFutureResult(requestRepository.getById(id)).map(RequestAndRelatedRecords::new).map(request -> asMove(request, representation)).flatMapFuture(move -> moveRequestService.moveRequest(move, move.getOriginalRequest())).onSuccess(records -> eventPublisher.publishDueDateChangedEvent(records, loanRepository)).map(RequestAndRelatedRecords::getRequest).map(new RequestRepresentation()::extendedRepresentation).map(JsonHttpResponse::ok).onComplete(context::write, context::write);
}
Also used : UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) UpdateRequestQueue(org.folio.circulation.domain.UpdateRequestQueue) RequestScheduledNoticeService(org.folio.circulation.domain.notice.schedule.RequestScheduledNoticeService) CreateRequestService(org.folio.circulation.domain.CreateRequestService) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository) ConfigurationRepository(org.folio.circulation.infrastructure.storage.ConfigurationRepository) MappingFunctions.when(org.folio.circulation.support.results.MappingFunctions.when) RequestQueueRepository(org.folio.circulation.infrastructure.storage.requests.RequestQueueRepository) LoanPolicyRepository(org.folio.circulation.infrastructure.storage.loans.LoanPolicyRepository) Router(io.vertx.ext.web.Router) ValidationErrorFailure.singleValidationError(org.folio.circulation.support.ValidationErrorFailure.singleValidationError) UpdateItem(org.folio.circulation.domain.UpdateItem) RoutingContext(io.vertx.ext.web.RoutingContext) JsonPropertyWriter.write(org.folio.circulation.support.json.JsonPropertyWriter.write) ServicePointRepository(org.folio.circulation.infrastructure.storage.ServicePointRepository) JsonObject(io.vertx.core.json.JsonObject) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) RequestRepresentation(org.folio.circulation.domain.RequestRepresentation) RequestBlockValidators.regularRequestBlockValidators(org.folio.circulation.resources.RequestBlockValidators.regularRequestBlockValidators) AsynchronousResult.fromFutureResult(org.folio.circulation.support.results.AsynchronousResult.fromFutureResult) RequestLoanValidator(org.folio.circulation.domain.validation.RequestLoanValidator) RequestPolicyRepository(org.folio.circulation.infrastructure.storage.requests.RequestPolicyRepository) UpdateRequestService(org.folio.circulation.domain.UpdateRequestService) BlockOverrides(org.folio.circulation.domain.override.BlockOverrides) EventPublisher(org.folio.circulation.services.EventPublisher) PROXY_USER_ID(org.folio.circulation.domain.representations.RequestProperties.PROXY_USER_ID) ServicePointPickupLocationValidator(org.folio.circulation.domain.validation.ServicePointPickupLocationValidator) TITLE(org.folio.circulation.domain.RequestLevel.TITLE) InstanceRepository(org.folio.circulation.infrastructure.storage.inventory.InstanceRepository) CreateRequestRepositories(org.folio.circulation.domain.CreateRequestRepositories) RequestRepository(org.folio.circulation.infrastructure.storage.requests.RequestRepository) NoContentResponse(org.folio.circulation.support.http.server.NoContentResponse) HttpClient(io.vertx.core.http.HttpClient) Clients(org.folio.circulation.support.Clients) ClosedRequestValidator(org.folio.circulation.domain.validation.ClosedRequestValidator) WebContext(org.folio.circulation.support.http.server.WebContext) Request(org.folio.circulation.domain.Request) FailFastErrorHandler(org.folio.circulation.resources.handlers.error.FailFastErrorHandler) MoveRequestProcessAdapter(org.folio.circulation.domain.MoveRequestProcessAdapter) JsonHttpResponse(org.folio.circulation.support.http.server.JsonHttpResponse) UpdateUponRequest(org.folio.circulation.domain.UpdateUponRequest) RequestAndRelatedRecords(org.folio.circulation.domain.RequestAndRelatedRecords) OkapiPermissions(org.folio.circulation.support.http.OkapiPermissions) MoveRequestService(org.folio.circulation.domain.MoveRequestService) OverridingErrorHandler(org.folio.circulation.resources.handlers.error.OverridingErrorHandler) RequestType(org.folio.circulation.domain.RequestType) MultipleRecords(org.folio.circulation.domain.MultipleRecords) ItemByInstanceIdFinder(org.folio.circulation.storage.ItemByInstanceIdFinder) MappingFunctions.toFixedValue(org.folio.circulation.support.results.MappingFunctions.toFixedValue) UpdateLoan(org.folio.circulation.domain.UpdateLoan) ProxyRelationshipValidator(org.folio.circulation.domain.validation.ProxyRelationshipValidator) WebContext(org.folio.circulation.support.http.server.WebContext) EventPublisher(org.folio.circulation.services.EventPublisher) RequestRepresentation(org.folio.circulation.domain.RequestRepresentation) MoveRequestService(org.folio.circulation.domain.MoveRequestService) ItemByInstanceIdFinder(org.folio.circulation.storage.ItemByInstanceIdFinder) RequestPolicyRepository(org.folio.circulation.infrastructure.storage.requests.RequestPolicyRepository) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) RequestLoanValidator(org.folio.circulation.domain.validation.RequestLoanValidator) UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) UpdateLoan(org.folio.circulation.domain.UpdateLoan) UpdateItem(org.folio.circulation.domain.UpdateItem) MoveRequestProcessAdapter(org.folio.circulation.domain.MoveRequestProcessAdapter) LoanPolicyRepository(org.folio.circulation.infrastructure.storage.loans.LoanPolicyRepository) ConfigurationRepository(org.folio.circulation.infrastructure.storage.ConfigurationRepository) RequestQueueRepository(org.folio.circulation.infrastructure.storage.requests.RequestQueueRepository) UpdateUponRequest(org.folio.circulation.domain.UpdateUponRequest)

Aggregations

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 CreateRequestRepositories (org.folio.circulation.domain.CreateRequestRepositories)1 CreateRequestService (org.folio.circulation.domain.CreateRequestService)1 MoveRequestProcessAdapter (org.folio.circulation.domain.MoveRequestProcessAdapter)1 MoveRequestService (org.folio.circulation.domain.MoveRequestService)1 MultipleRecords (org.folio.circulation.domain.MultipleRecords)1 Request (org.folio.circulation.domain.Request)1 RequestAndRelatedRecords (org.folio.circulation.domain.RequestAndRelatedRecords)1 TITLE (org.folio.circulation.domain.RequestLevel.TITLE)1 RequestRepresentation (org.folio.circulation.domain.RequestRepresentation)1 RequestType (org.folio.circulation.domain.RequestType)1 UpdateItem (org.folio.circulation.domain.UpdateItem)1 UpdateLoan (org.folio.circulation.domain.UpdateLoan)1 UpdateRequestQueue (org.folio.circulation.domain.UpdateRequestQueue)1 UpdateRequestService (org.folio.circulation.domain.UpdateRequestService)1 UpdateUponRequest (org.folio.circulation.domain.UpdateUponRequest)1 RequestScheduledNoticeService (org.folio.circulation.domain.notice.schedule.RequestScheduledNoticeService)1