Search in sources :

Example 1 with NoteCreator

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

the class DeclareLostResource method declareItemLostWhenClaimedReturned.

private CompletableFuture<Result<Loan>> declareItemLostWhenClaimedReturned(Loan loan, DeclareItemLostRequest request, Clients clients) {
    final NotesRepository notesRepository = NotesRepository.createUsing(clients);
    final NoteCreator creator = new NoteCreator(notesRepository);
    return ofAsync(() -> declareItemLost(loan, request)).thenCompose(r -> r.after(l -> creator.createGeneralUserNote(loan.getUserId(), "Claimed returned item marked declared lost"))).thenCompose(r -> r.after(note -> completedFuture(succeeded(loan))));
}
Also used : UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) Clients(org.folio.circulation.support.Clients) DeclareItemLostRequest(org.folio.circulation.domain.representations.DeclareItemLostRequest) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) WebContext(org.folio.circulation.support.http.server.WebContext) MappingFunctions.when(org.folio.circulation.support.results.MappingFunctions.when) Router(io.vertx.ext.web.Router) CompletableFuture(java.util.concurrent.CompletableFuture) ValidationErrorFailure.singleValidationError(org.folio.circulation.support.ValidationErrorFailure.singleValidationError) LostItemFeeChargingService(org.folio.circulation.services.LostItemFeeChargingService) RoutingContext(io.vertx.ext.web.RoutingContext) Function(java.util.function.Function) NotesRepository(org.folio.circulation.infrastructure.storage.notes.NotesRepository) LoanValidator(org.folio.circulation.domain.validation.LoanValidator) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) LostItemFeeRefundService(org.folio.circulation.services.LostItemFeeRefundService) NoteCreator(org.folio.circulation.domain.notes.NoteCreator) Result.succeeded(org.folio.circulation.support.results.Result.succeeded) Loan(org.folio.circulation.domain.Loan) MappingFunctions.toFixedValue(org.folio.circulation.support.results.MappingFunctions.toFixedValue) Result(org.folio.circulation.support.results.Result) Result.ofAsync(org.folio.circulation.support.results.Result.ofAsync) EventPublisher(org.folio.circulation.services.EventPublisher) StringUtils.defaultIfBlank(org.apache.commons.lang.StringUtils.defaultIfBlank) CompletionStage(java.util.concurrent.CompletionStage) StoreLoanAndItem(org.folio.circulation.StoreLoanAndItem) NoContentResponse(org.folio.circulation.support.http.server.NoContentResponse) HttpClient(io.vertx.core.http.HttpClient) NotesRepository(org.folio.circulation.infrastructure.storage.notes.NotesRepository) NoteCreator(org.folio.circulation.domain.notes.NoteCreator)

Example 2 with NoteCreator

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

the class DeclareClaimedReturnedItemAsMissingResource method createNote.

private CompletableFuture<Result<Loan>> createNote(Clients clients, Loan loan) {
    final NotesRepository notesRepository = NotesRepository.createUsing(clients);
    final NoteCreator creator = new NoteCreator(notesRepository);
    return creator.createGeneralUserNote(loan.getUserId(), "Claimed returned item marked missing").thenCompose(r -> r.after(note -> completedFuture(succeeded(loan))));
}
Also used : UserRepository(org.folio.circulation.infrastructure.storage.users.UserRepository) Clients(org.folio.circulation.support.Clients) LoanRepository(org.folio.circulation.infrastructure.storage.loans.LoanRepository) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) WebContext(org.folio.circulation.support.http.server.WebContext) Router(io.vertx.ext.web.Router) CompletableFuture(java.util.concurrent.CompletableFuture) ValidationErrorFailure.singleValidationError(org.folio.circulation.support.ValidationErrorFailure.singleValidationError) RoutingContext(io.vertx.ext.web.RoutingContext) NotesRepository(org.folio.circulation.infrastructure.storage.notes.NotesRepository) ChangeItemStatusRequest(org.folio.circulation.domain.representations.ChangeItemStatusRequest) PubSubPublishingService(org.folio.circulation.services.PubSubPublishingService) JsonObject(io.vertx.core.json.JsonObject) ChangeItemStatusService(org.folio.circulation.services.ChangeItemStatusService) Result.failed(org.folio.circulation.support.results.Result.failed) ItemRepository(org.folio.circulation.infrastructure.storage.inventory.ItemRepository) NoteCreator(org.folio.circulation.domain.notes.NoteCreator) Result.succeeded(org.folio.circulation.support.results.Result.succeeded) Loan(org.folio.circulation.domain.Loan) MappingFunctions.toFixedValue(org.folio.circulation.support.results.MappingFunctions.toFixedValue) NotInItemStatusValidator(org.folio.circulation.domain.validation.NotInItemStatusValidator) Result(org.folio.circulation.support.results.Result) EventPublisher(org.folio.circulation.services.EventPublisher) RouteRegistration(org.folio.circulation.support.RouteRegistration) StoreLoanAndItem(org.folio.circulation.StoreLoanAndItem) NoContentResponse(org.folio.circulation.support.http.server.NoContentResponse) HttpClient(io.vertx.core.http.HttpClient) NotesRepository(org.folio.circulation.infrastructure.storage.notes.NotesRepository) NoteCreator(org.folio.circulation.domain.notes.NoteCreator)

Aggregations

HttpClient (io.vertx.core.http.HttpClient)2 Router (io.vertx.ext.web.Router)2 RoutingContext (io.vertx.ext.web.RoutingContext)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)2 StoreLoanAndItem (org.folio.circulation.StoreLoanAndItem)2 Loan (org.folio.circulation.domain.Loan)2 NoteCreator (org.folio.circulation.domain.notes.NoteCreator)2 ItemRepository (org.folio.circulation.infrastructure.storage.inventory.ItemRepository)2 LoanRepository (org.folio.circulation.infrastructure.storage.loans.LoanRepository)2 NotesRepository (org.folio.circulation.infrastructure.storage.notes.NotesRepository)2 UserRepository (org.folio.circulation.infrastructure.storage.users.UserRepository)2 EventPublisher (org.folio.circulation.services.EventPublisher)2 Clients (org.folio.circulation.support.Clients)2 ValidationErrorFailure.singleValidationError (org.folio.circulation.support.ValidationErrorFailure.singleValidationError)2 NoContentResponse (org.folio.circulation.support.http.server.NoContentResponse)2 WebContext (org.folio.circulation.support.http.server.WebContext)2 MappingFunctions.toFixedValue (org.folio.circulation.support.results.MappingFunctions.toFixedValue)2 Result (org.folio.circulation.support.results.Result)2 Result.succeeded (org.folio.circulation.support.results.Result.succeeded)2