Search in sources :

Example 1 with NoticeConfiguration

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

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

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

the class RequestScheduledNoticeService method scheduleRequestNoticesBasedOnTlrSettings.

private Result<TlrSettingsConfiguration> scheduleRequestNoticesBasedOnTlrSettings(Request request, TlrSettingsConfiguration tlrSettingsConfiguration) {
    UUID expirationTemplateId = tlrSettingsConfiguration.getExpirationPatronNoticeTemplateId();
    if (expirationTemplateId != null) {
        NoticeConfiguration noticeConfiguration = new NoticeConfigurationBuilder().setTemplateId(expirationTemplateId.toString()).setNoticeFormat(NoticeFormat.EMAIL).setNoticeEventType(NoticeEventType.TITLE_LEVEL_REQUEST_EXPIRATION).setTiming(UPON_AT).setRecurring(false).setSendInRealTime(true).build();
        createRequestExpirationScheduledNotice(request, noticeConfiguration, TITLE_LEVEL_REQUEST_EXPIRATION).map(scheduledNoticesRepository::create);
    } else {
        log.info("ExpirationPatronNoticeTemplateId is not present, scheduled notice will not be created");
    }
    return succeeded(tlrSettingsConfiguration);
}
Also used : NoticeConfigurationBuilder(org.folio.circulation.domain.notice.NoticeConfigurationBuilder) NoticeConfiguration(org.folio.circulation.domain.notice.NoticeConfiguration) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)3 NoticeConfiguration (org.folio.circulation.domain.notice.NoticeConfiguration)3 PatronNotice (org.folio.circulation.domain.notice.PatronNotice)2 NoticeLogContext (org.folio.circulation.domain.representations.logs.NoticeLogContext)2 NoticeConfigurationBuilder (org.folio.circulation.domain.notice.NoticeConfigurationBuilder)1