use of org.springframework.scheduling.annotation.Scheduled in project hub-fortify-ssc-integration-service by blackducksoftware.
the class BlackDuckFortifyPhoneHomeJobConfig method execute.
/**
* Schedule the job and add it to the job launcher
*
* @throws Exception
*/
// Run on same schedule as worker
@Scheduled(cron = "${cron.expressions}")
public void execute() throws Exception {
JobParameters jobParams = new JobParametersBuilder().addString("JobID", String.valueOf(System.currentTimeMillis())).toJobParameters();
jobLauncher.run(sendPhoneHomeDataJob(), jobParams);
}
use of org.springframework.scheduling.annotation.Scheduled in project mica2 by obiba.
the class TempFileService method cleanupTempFiles.
@Scheduled(fixedDelay = TEMP_FILE_CLEANUP_INTERVAL)
public void cleanupTempFiles() {
log.debug("Cleaning up tempfiles");
List<TempFile> tempFiles = tempFileRepository.findByCreatedDateLessThan(DateTime.now().minusHours(TEMP_FILE_EXPIRE_TIMEOUT), new PageRequest(0, 100));
tempFiles.forEach(f -> tempFileRepository.delete(f));
}
use of org.springframework.scheduling.annotation.Scheduled in project mica2 by obiba.
the class DocumentSetService method cleanupOldSets.
@Async
@Scheduled(cron = "${sets.cleanup.cron:0 0 * * * ?}")
public void cleanupOldSets() {
MicaConfig config = micaConfigService.getConfig();
documentSetRepository.findAll().forEach(set -> {
int timeToLive = set.hasName() ? config.getSetTimeToLive() : config.getCartTimeToLive();
DateTime deadline = DateTime.now().minusDays(timeToLive);
if (set.getLastModifiedDate().isBefore(deadline) && !set.isLocked()) {
log.debug("Last updated {} - expiration {}", set.getLastModifiedDate(), deadline);
log.info("{} {} has expired, deleting...", (set.hasName() ? "Set" : "Cart"), set.getId());
delete(set);
}
});
}
use of org.springframework.scheduling.annotation.Scheduled in project mica2 by obiba.
the class DataAccessRequestReportNotificationService method remindDataAccessReports.
@Async
@Scheduled(cron = "${dar.reminder.cron:0 0 0 * * ?}")
public void remindDataAccessReports() {
DataAccessConfig dataAccessConfig = dataAccessConfigService.getOrCreateConfig();
if (!dataAccessConfig.isNotifyFinalReport() && !dataAccessConfig.isNotifyIntermediateReport())
return;
int nbOfDaysBeforeReport = dataAccessConfig.getNbOfDaysBeforeReport();
if (nbOfDaysBeforeReport < 0)
return;
LocalDate dateNow = LocalDate.now().minusDays(nbOfDaysBeforeReport);
for (DataAccessRequest dar : dataAccessRequestService.findByStatus(Lists.newArrayList(DataAccessEntityStatus.APPROVED.name()))) {
DataAccessRequestTimeline timeline = getReportsTimeline(dar);
if (timeline.hasEndDate()) {
LocalDate localEndDate = toLocalDate(timeline.getEndDate());
if (dataAccessConfig.isNotifyFinalReport() && dateNow.plusDays(nbOfDaysBeforeReport).equals(localEndDate)) {
// today is the day to notify final report
remindDataAccessFinalReport(dataAccessConfig, dar, timeline.getEndDate(), nbOfDaysBeforeReport);
} else if (dataAccessConfig.isNotifyIntermediateReport() && timeline.hasIntermediateDates()) {
for (Date interDate : timeline.getIntermediateDates()) {
if (dateNow.plusDays(nbOfDaysBeforeReport).equals(toLocalDate(interDate))) {
remindDataAccessIntermediateReport(dataAccessConfig, dar, interDate, nbOfDaysBeforeReport);
break;
}
}
}
} else {
log.warn("No end date found for data access request {}", dar.getId());
}
}
}
use of org.springframework.scheduling.annotation.Scheduled in project webapp by elimu-ai.
the class LetterSoundCorrespondenceUsageCountScheduler method execute.
// At 06:15 every day
@Scheduled(cron = "00 15 06 * * *")
public synchronized void execute() {
logger.info("execute");
logger.info("Calculating usage count for LetterSoundCorrespondences");
// <id, usageCount>
Map<Long, Integer> letterSoundCorrespondenceFrequencyMap = new HashMap<>();
List<Word> words = wordDao.readAll();
logger.info("words.size(): " + words.size());
for (Word word : words) {
logger.info("word.getText(): " + word.getText());
for (LetterSoundCorrespondence letterSoundCorrespondence : word.getLetterSoundCorrespondences()) {
letterSoundCorrespondenceFrequencyMap.put(letterSoundCorrespondence.getId(), letterSoundCorrespondenceFrequencyMap.getOrDefault(letterSoundCorrespondence.getId(), 0) + word.getUsageCount());
}
}
// Update the values previously stored in the database
for (LetterSoundCorrespondence letterSoundCorrespondence : letterSoundCorrespondenceDao.readAll()) {
logger.info("letterSoundCorrespondence.getId(): " + letterSoundCorrespondence.getId());
logger.info("letterSoundCorrespondence Letters: \"" + letterSoundCorrespondence.getLetters().stream().map(Letter::getText).collect(Collectors.joining()) + "\"");
logger.info("letterSoundCorrespondence Sounds: /" + letterSoundCorrespondence.getSounds().stream().map(Sound::getValueIpa).collect(Collectors.joining()) + "/");
logger.info("letterSoundCorrespondence.getUsageCount() (before update): " + letterSoundCorrespondence.getUsageCount());
int newUsageCount = 0;
if (letterSoundCorrespondenceFrequencyMap.containsKey(letterSoundCorrespondence.getId())) {
newUsageCount = letterSoundCorrespondenceFrequencyMap.get(letterSoundCorrespondence.getId());
}
logger.info("newUsageCount: " + newUsageCount);
letterSoundCorrespondence.setUsageCount(newUsageCount);
letterSoundCorrespondenceDao.update(letterSoundCorrespondence);
logger.info("letterSoundCorrespondence.getUsageCount() (after update): " + letterSoundCorrespondence.getUsageCount());
}
logger.info("execute complete");
}
Aggregations