use of org.obiba.mica.micaConfig.domain.DataAccessConfig 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.obiba.mica.micaConfig.domain.DataAccessConfig in project mica2 by obiba.
the class DataAccessEntityService method sendConditionallyApprovedEmail.
protected void sendConditionallyApprovedEmail(T request) {
DataAccessConfig dataAccessConfig = dataAccessConfigService.getOrCreateConfig();
if (dataAccessConfig.isNotifyConditionallyApproved()) {
Map<String, String> ctx = getNotificationEmailContext(request);
String prefix = getTemplatePrefix(ctx);
mailService.sendEmailToUsers(mailService.getSubject(dataAccessConfig.getConditionallyApprovedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), prefix + "ConditionallyApprovedApplicantEmail", ctx, request.getApplicant());
}
}
use of org.obiba.mica.micaConfig.domain.DataAccessConfig in project mica2 by obiba.
the class DataAccessEntityService method sendReviewedNotificationEmail.
protected void sendReviewedNotificationEmail(T request) {
DataAccessConfig dataAccessConfig = dataAccessConfigService.getOrCreateConfig();
if (dataAccessConfig.isNotifyReviewed() && dataAccessConfig.isWithReview()) {
Map<String, String> ctx = getNotificationEmailContext(request);
String prefix = getTemplatePrefix(ctx);
mailService.sendEmailToUsers(mailService.getSubject(dataAccessConfig.getReviewedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), prefix + "ReviewedApplicantEmail", ctx, request.getApplicant());
}
}
use of org.obiba.mica.micaConfig.domain.DataAccessConfig in project mica2 by obiba.
the class DataAccessEntityService method sendRejectedNotificationEmail.
protected void sendRejectedNotificationEmail(T request) {
DataAccessConfig dataAccessConfig = dataAccessConfigService.getOrCreateConfig();
if (dataAccessConfig.isNotifyRejected()) {
Map<String, String> ctx = getNotificationEmailContext(request);
String prefix = getTemplatePrefix(ctx);
mailService.sendEmailToUsers(mailService.getSubject(dataAccessConfig.getRejectedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), prefix + "RejectedApplicantEmail", ctx, request.getApplicant());
}
}
use of org.obiba.mica.micaConfig.domain.DataAccessConfig in project mica2 by obiba.
the class DataAccessEntityService method sendApprovedNotificationEmail.
protected void sendApprovedNotificationEmail(T request) {
DataAccessConfig dataAccessConfig = dataAccessConfigService.getOrCreateConfig();
if (dataAccessConfig.isNotifyApproved()) {
Map<String, String> ctx = getNotificationEmailContext(request);
String prefix = getTemplatePrefix(ctx);
mailService.sendEmailToUsers(mailService.getSubject(dataAccessConfig.getApprovedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), prefix + "ApprovedApplicantEmail", ctx, request.getApplicant());
}
}
Aggregations