Search in sources :

Example 11 with User

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

the class CirculationCheckInCheckOutLogEventMapper method mapToCheckInLogEventContent.

/**
 * This method returns {@link String} content for check-in log event payload
 * @param checkInContext check-in flow context {@link CheckInContext}
 * @return check-in log event payload
 */
public static String mapToCheckInLogEventContent(CheckInContext checkInContext, User loggedInUser) {
    JsonObject logEventPayload = new JsonObject();
    write(logEventPayload, LOG_EVENT_TYPE.value(), CHECK_IN.value());
    write(logEventPayload, SERVICE_POINT_ID.value(), checkInContext.getCheckInServicePointId());
    populateLoanData(checkInContext, logEventPayload);
    populateItemData(checkInContext, logEventPayload, loggedInUser);
    ofNullable(checkInContext.getCheckInRequest()).flatMap(checkInRequest -> ofNullable(checkInRequest.getClaimedReturnedResolution())).ifPresent(resolution -> write(logEventPayload, CLAIMED_RETURNED_RESOLUTION.value(), resolution.getValue()));
    write(logEventPayload, REQUESTS.value(), getUpdatedRequests(checkInContext));
    return logEventPayload.encode();
}
Also used : UpdatedRequestPair(org.folio.circulation.domain.UpdatedRequestPair) CHECK_IN(org.folio.circulation.domain.representations.logs.LogEventType.CHECK_IN) LoanAction(org.folio.circulation.domain.LoanAction) Optional.ofNullable(java.util.Optional.ofNullable) Loan(org.folio.circulation.domain.Loan) JsonPropertyWriter.write(org.folio.circulation.support.json.JsonPropertyWriter.write) Collectors(java.util.stream.Collectors) CheckInContext(org.folio.circulation.domain.CheckInContext) CHECK_OUT(org.folio.circulation.domain.representations.logs.LogEventType.CHECK_OUT) User(org.folio.circulation.domain.User) CHECK_OUT_THROUGH_OVERRIDE(org.folio.circulation.domain.representations.logs.LogEventType.CHECK_OUT_THROUGH_OVERRIDE) JsonArray(io.vertx.core.json.JsonArray) List(java.util.List) LoanAndRelatedRecords(org.folio.circulation.domain.LoanAndRelatedRecords) LogEventPayloadField(org.folio.circulation.domain.representations.logs.LogEventPayloadField) JsonObject(io.vertx.core.json.JsonObject) JsonObject(io.vertx.core.json.JsonObject)

Example 12 with User

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

the class LoanLogContext method userFromRepresentation.

private static User userFromRepresentation(Loan loan) {
    JsonObject userJson = new JsonObject();
    ofNullable(loan).ifPresent(l -> write(userJson, "id", l.getUserId()));
    return new User(userJson);
}
Also used : User(org.folio.circulation.domain.User) JsonObject(io.vertx.core.json.JsonObject)

Example 13 with User

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

the class RequestNoticeSender method sendRequestAwaitingPickupNotice.

private CompletableFuture<Result<Void>> sendRequestAwaitingPickupNotice(Request request) {
    Item item = request.getItem();
    User user = request.getRequester();
    PatronNoticeEvent noticeEvent = new PatronNoticeEventBuilder().withItem(item).withUser(user).withEventType(NoticeEventType.AVAILABLE).withNoticeContext(createRequestNoticeContext(request)).withNoticeLogContext(NoticeLogContext.from(request)).build();
    return patronNoticeService.acceptNoticeEvent(noticeEvent);
}
Also used : Item(org.folio.circulation.domain.Item) User(org.folio.circulation.domain.User) PatronNoticeEvent(org.folio.circulation.domain.notice.PatronNoticeEvent) PatronNoticeEventBuilder(org.folio.circulation.domain.notice.PatronNoticeEventBuilder)

Aggregations

User (org.folio.circulation.domain.User)13 JsonObject (io.vertx.core.json.JsonObject)7 Test (org.junit.jupiter.api.Test)6 LoanAndRelatedRecords (org.folio.circulation.domain.LoanAndRelatedRecords)5 Loan (org.folio.circulation.domain.Loan)4 ZonedDateTime (java.time.ZonedDateTime)3 List (java.util.List)3 InactiveUserValidator.forUser (org.folio.circulation.domain.validation.InactiveUserValidator.forUser)3 Address (api.support.builders.Address)2 RequestBuilder (api.support.builders.RequestBuilder)2 IndividualResource (api.support.http.IndividualResource)2 ItemResource (api.support.http.ItemResource)2 JsonArray (io.vertx.core.json.JsonArray)2 MethodHandles (java.lang.invoke.MethodHandles)2 UUID (java.util.UUID)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)2 Collectors (java.util.stream.Collectors)2 CheckInContext (org.folio.circulation.domain.CheckInContext)2 Item (org.folio.circulation.domain.Item)2