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);
}
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);
}
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));
}
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));
}
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);
}
Aggregations