Search in sources :

Example 1 with PatronNoticeEvent

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

the class ItemLevelRequestNoticeSender method sendNoticeOnRequestCreated.

@Override
public Result<RequestAndRelatedRecords> sendNoticeOnRequestCreated(RequestAndRelatedRecords relatedRecords) {
    Request request = relatedRecords.getRequest();
    Item item = request.getItem();
    NoticeEventType eventType = requestTypeToEventMap.getOrDefault(request.getRequestType(), NoticeEventType.UNKNOWN);
    PatronNoticeEvent requestCreatedEvent = createPatronNoticeEvent(request, eventType).withItem(item);
    patronNoticeService.acceptNoticeEvent(requestCreatedEvent);
    Loan loan = request.getLoan();
    if (request.getRequestType() == RequestType.RECALL && loan != null) {
        sendNoticeOnItemRecalledEvent(loan);
        sendLogEvent(loan);
    }
    return Result.succeeded(relatedRecords);
}
Also used : Item(org.folio.circulation.domain.Item) NoticeEventType(org.folio.circulation.domain.notice.NoticeEventType) Loan(org.folio.circulation.domain.Loan) Request(org.folio.circulation.domain.Request) PatronNoticeEvent(org.folio.circulation.domain.notice.PatronNoticeEvent)

Example 2 with PatronNoticeEvent

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

the class TitleLevelRequestNoticeSender method sendNoticeOnRequestCreated.

@Override
public Result<RequestAndRelatedRecords> sendNoticeOnRequestCreated(RequestAndRelatedRecords relatedRecords) {
    Request request = relatedRecords.getRequest();
    TlrSettingsConfiguration tlrSettings = request.getTlrSettingsConfiguration();
    NoticeEventType eventType = requestTypeToEventMap.getOrDefault(request.getRequestType(), NoticeEventType.UNKNOWN);
    if (tlrSettings.isTitleLevelRequestsFeatureEnabled() && tlrSettings.getConfirmationPatronNoticeTemplateId() != null) {
        PatronNoticeEvent requestCreatedEvent = createPatronNoticeEvent(request, eventType);
        applyTlrConfirmationNotice(request.getTlrSettingsConfiguration(), requestCreatedEvent);
    }
    return Result.succeeded(relatedRecords);
}
Also used : NoticeEventType(org.folio.circulation.domain.notice.NoticeEventType) Request(org.folio.circulation.domain.Request) TlrSettingsConfiguration(org.folio.circulation.domain.configuration.TlrSettingsConfiguration) PatronNoticeEvent(org.folio.circulation.domain.notice.PatronNoticeEvent)

Example 3 with PatronNoticeEvent

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

the class ItemLevelRequestNoticeSender method sendNoticeOnRequestCancelled.

@Override
protected Result<Void> sendNoticeOnRequestCancelled(RequestAndRelatedRecords relatedRecords) {
    Request request = relatedRecords.getRequest();
    PatronNoticeEvent requestCancelledEvent = createPatronNoticeEvent(request, NoticeEventType.REQUEST_CANCELLATION).withItem(request.getItem());
    patronNoticeService.acceptNoticeEvent(requestCancelledEvent);
    return Result.succeeded(null);
}
Also used : Request(org.folio.circulation.domain.Request) PatronNoticeEvent(org.folio.circulation.domain.notice.PatronNoticeEvent)

Example 4 with PatronNoticeEvent

use of org.folio.circulation.domain.notice.PatronNoticeEvent 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)

Example 5 with PatronNoticeEvent

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

the class RequestNoticeSender method sendNoticeOnItemRecalledEvent.

protected Result<Void> sendNoticeOnItemRecalledEvent(Loan loan) {
    if (loan.getUser() != null && loan.getItem() != null) {
        PatronNoticeEvent itemRecalledEvent = new PatronNoticeEventBuilder().withItem(loan.getItem()).withUser(loan.getUser()).withEventType(NoticeEventType.ITEM_RECALLED).withNoticeContext(TemplateContextUtil.createLoanNoticeContext(loan)).withNoticeLogContext(NoticeLogContext.from(loan)).build();
        patronNoticeService.acceptNoticeEvent(itemRecalledEvent);
    }
    return Result.succeeded(null);
}
Also used : PatronNoticeEvent(org.folio.circulation.domain.notice.PatronNoticeEvent) PatronNoticeEventBuilder(org.folio.circulation.domain.notice.PatronNoticeEventBuilder)

Aggregations

PatronNoticeEvent (org.folio.circulation.domain.notice.PatronNoticeEvent)6 Request (org.folio.circulation.domain.Request)4 Item (org.folio.circulation.domain.Item)2 NoticeEventType (org.folio.circulation.domain.notice.NoticeEventType)2 PatronNoticeEventBuilder (org.folio.circulation.domain.notice.PatronNoticeEventBuilder)2 Loan (org.folio.circulation.domain.Loan)1 User (org.folio.circulation.domain.User)1 TlrSettingsConfiguration (org.folio.circulation.domain.configuration.TlrSettingsConfiguration)1