package ru.ulstu.activity.conference.service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import java.util.stream.Collectors; @Service public class ConferenceScheduler { private final static boolean IS_DEADLINE_NOTIFICATION_BEFORE_WEEK = true; private final Logger log = LoggerFactory.getLogger(ConferenceScheduler.class); private final ConferenceNotificationService conferenceNotificationService; private final ConferenceService conferenceService; public ConferenceScheduler(ConferenceNotificationService conferenceNotificationService, ConferenceService conferenceService) { this.conferenceNotificationService = conferenceNotificationService; this.conferenceService = conferenceService; } @Scheduled(cron = "0 0 8 * * MON", zone = "Europe/Samara") public void checkDeadlineBeforeWeek() { log.debug("ConferenceScheduler.checkDeadlineBeforeWeek started"); conferenceNotificationService.sendDeadlineNotifications(conferenceService.findAll(0, 100) .getItems().stream().collect(Collectors.toList())); log.debug("ConferenceScheduler.checkDeadlineBeforeWeek finished"); } @Scheduled(cron = "0 0 8 * * *", zone = "Europe/Samara") public void checkNewPing() { log.debug("ConferenceScheduler.checkPing started"); conferenceNotificationService.sendPingNotifications(conferenceService.findAll(0, 100) .getItems().stream().collect(Collectors.toList())); log.debug("ConferenceScheduler.checkPing finished"); } }