Search in sources :

Example 1 with NoticeLogContext

use of org.folio.circulation.domain.representations.logs.NoticeLogContext in project mod-circulation by folio-org.

the class TitleLevelRequestNoticeSender method applyTlrCancellationNotice.

private CompletableFuture<Result<Void>> applyTlrCancellationNotice(TlrSettingsConfiguration tlrSettings, PatronNoticeEvent patronNoticeEvent) {
    UUID cancellationTemplateId = tlrSettings.getCancellationPatronNoticeTemplateId();
    if (cancellationTemplateId != null) {
        NoticeLogContext noticeLogContext = new NoticeLogContext().withTriggeringEvent(patronNoticeEvent.getEventType().getRepresentation()).withTemplateId(cancellationTemplateId.toString());
        NoticeConfiguration noticeConfiguration = buildTlrNoticeConfiguration(patronNoticeEvent, cancellationTemplateId);
        PatronNotice patronNotice = new PatronNotice(patronNoticeEvent.getUser().getId(), patronNoticeEvent.getNoticeContext(), noticeConfiguration);
        return patronNoticeService.sendNotice(patronNotice, noticeLogContext);
    }
    return ofAsync(() -> null);
}
Also used : NoticeLogContext(org.folio.circulation.domain.representations.logs.NoticeLogContext) NoticeConfiguration(org.folio.circulation.domain.notice.NoticeConfiguration) UUID(java.util.UUID) PatronNotice(org.folio.circulation.domain.notice.PatronNotice)

Example 2 with NoticeLogContext

use of org.folio.circulation.domain.representations.logs.NoticeLogContext in project mod-circulation by folio-org.

the class TitleLevelRequestNoticeSender method applyTlrConfirmationNotice.

private CompletableFuture<Result<Void>> applyTlrConfirmationNotice(TlrSettingsConfiguration tlrSettings, PatronNoticeEvent patronNoticeEvent) {
    UUID confirmationTemplateId = tlrSettings.getConfirmationPatronNoticeTemplateId();
    if (confirmationTemplateId != null) {
        NoticeLogContext noticeLogContext = new NoticeLogContext().withTriggeringEvent(patronNoticeEvent.getEventType().getRepresentation()).withTemplateId(confirmationTemplateId.toString());
        NoticeConfiguration noticeConfiguration = buildTlrNoticeConfiguration(patronNoticeEvent, confirmationTemplateId);
        PatronNotice patronNotice = new PatronNotice(patronNoticeEvent.getUser().getId(), patronNoticeEvent.getNoticeContext(), noticeConfiguration);
        return patronNoticeService.sendNotice(patronNotice, noticeLogContext);
    }
    return ofAsync(() -> null);
}
Also used : NoticeLogContext(org.folio.circulation.domain.representations.logs.NoticeLogContext) NoticeConfiguration(org.folio.circulation.domain.notice.NoticeConfiguration) UUID(java.util.UUID) PatronNotice(org.folio.circulation.domain.notice.PatronNotice)

Example 3 with NoticeLogContext

use of org.folio.circulation.domain.representations.logs.NoticeLogContext in project mod-circulation by folio-org.

the class FeeFineScheduledNoticeHandler method buildNoticeLogContext.

@Override
protected NoticeLogContext buildNoticeLogContext(ScheduledNoticeContext context) {
    Loan loan = context.getLoan();
    ScheduledNotice notice = context.getNotice();
    NoticeLogContextItem logContextItem = NoticeLogContextItem.from(loan).withTemplateId(notice.getConfiguration().getTemplateId()).withTriggeringEvent(notice.getTriggeringEvent().getRepresentation()).withNoticePolicyId(context.getPatronNoticePolicyId());
    return new NoticeLogContext().withUser(loan.getUser()).withAccountId(context.getAccount().getId()).withItems(singletonList(logContextItem));
}
Also used : NoticeLogContextItem(org.folio.circulation.domain.representations.logs.NoticeLogContextItem) NoticeLogContext(org.folio.circulation.domain.representations.logs.NoticeLogContext) Loan(org.folio.circulation.domain.Loan)

Example 4 with NoticeLogContext

use of org.folio.circulation.domain.representations.logs.NoticeLogContext in project mod-circulation by folio-org.

the class RequestScheduledNoticeHandler method buildNoticeLogContext.

@Override
protected NoticeLogContext buildNoticeLogContext(ScheduledNoticeContext context) {
    ScheduledNotice notice = context.getNotice();
    Request request = context.getRequest();
    NoticeLogContextItem logContextItem = NoticeLogContextItem.from(request).withTemplateId(notice.getConfiguration().getTemplateId()).withTriggeringEvent(notice.getTriggeringEvent().getRepresentation()).withNoticePolicyId(context.getPatronNoticePolicyId());
    return new NoticeLogContext().withUser(request.getRequester()).withRequestId(request.getId()).withItems(singletonList(logContextItem));
}
Also used : NoticeLogContextItem(org.folio.circulation.domain.representations.logs.NoticeLogContextItem) NoticeLogContext(org.folio.circulation.domain.representations.logs.NoticeLogContext) Request(org.folio.circulation.domain.Request)

Example 5 with NoticeLogContext

use of org.folio.circulation.domain.representations.logs.NoticeLogContext in project mod-circulation by folio-org.

the class LoanNoticeSender method publishNoticeErrorEvent.

private Result<Loan> publishNoticeErrorEvent(HttpFailure failure, Loan loan, NoticeEventType eventType) {
    if (loan == null) {
        log.error("Failed to send {} notice and circulation log event: loan is null", eventType);
    } else {
        NoticeLogContext noticeLogContext = NoticeLogContext.from(loan).withTriggeringEvent(eventType.getRepresentation());
        eventPublisher.publishNoticeErrorLogEvent(noticeLogContext, failure);
    }
    return failed(failure);
}
Also used : NoticeLogContext(org.folio.circulation.domain.representations.logs.NoticeLogContext)

Aggregations

NoticeLogContext (org.folio.circulation.domain.representations.logs.NoticeLogContext)5 UUID (java.util.UUID)2 NoticeConfiguration (org.folio.circulation.domain.notice.NoticeConfiguration)2 PatronNotice (org.folio.circulation.domain.notice.PatronNotice)2 NoticeLogContextItem (org.folio.circulation.domain.representations.logs.NoticeLogContextItem)2 Loan (org.folio.circulation.domain.Loan)1 Request (org.folio.circulation.domain.Request)1