use of com.axelor.apps.message.db.Template in project axelor-open-suite by axelor.
the class BatchEbicsCertificate method process.
@Override
protected void process() {
Template template = templateRepo.find(bankPaymentBatch.getTemplate().getId());
List<EbicsUser> users = Beans.get(EbicsUserRepository.class).all().filter("self.a005Certificate != null OR self.e002Certificate != null OR self.x002Certificate != null").fetch();
Set<EbicsCertificate> certificatesSet = new HashSet<>();
LocalDate today = Beans.get(AppBaseService.class).getTodayDate(bankPaymentBatch.getCompany());
LocalDate commingDay = today.plusDays(bankPaymentBatch.getDaysNbr());
for (EbicsUser user : users) {
if (user.getA005Certificate() != null && user.getA005Certificate().getValidTo().isBefore(commingDay)) {
certificatesSet.add(user.getA005Certificate());
}
if (user.getE002Certificate() != null && user.getE002Certificate().getValidTo().isBefore(commingDay)) {
certificatesSet.add(user.getE002Certificate());
}
if (user.getX002Certificate() != null && user.getX002Certificate().getValidTo().isBefore(commingDay)) {
certificatesSet.add(user.getX002Certificate());
}
}
certificatesSet.addAll(Beans.get(EbicsCertificateRepository.class).all().filter("self.ebicsBank != null AND self.validTo <= ?1", commingDay).fetch());
for (EbicsCertificate certificate : certificatesSet) {
certificate.addBatchSetItem(batchRepo.find(batch.getId()));
try {
templateMessageService.generateMessage(certificate, template);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | AxelorException | IOException e) {
e.printStackTrace();
}
}
}
use of com.axelor.apps.message.db.Template in project axelor-open-suite by axelor.
the class UserServiceImpl method processChangedPassword.
@Override
@Transactional(rollbackOn = { Exception.class })
public void processChangedPassword(User user) throws ClassNotFoundException, InstantiationException, IllegalAccessException, MessagingException, IOException, AxelorException, JSONException {
Preconditions.checkNotNull(user, I18n.get("User cannot be null."));
try {
if (!user.getSendEmailUponPasswordChange()) {
return;
}
if (user.equals(AuthUtils.getUser())) {
logger.debug("User {} changed own password.", user.getCode());
return;
}
AppBase appBase = Beans.get(AppBaseService.class).getAppBase();
Template template = appBase.getPasswordChangedTemplate();
if (template == null) {
throw new AxelorException(appBase, TraceBackRepository.CATEGORY_NO_VALUE, I18n.get("Template for changed password is missing."));
}
TemplateMessageService templateMessageService = Beans.get(TemplateMessageService.class);
templateMessageService.generateAndSendMessage(user, template);
} finally {
user.setTransientPassword(null);
}
}
use of com.axelor.apps.message.db.Template in project axelor-open-suite by axelor.
the class TimesheetReportServiceImpl method sendReminders.
@Transactional
public List<Message> sendReminders(TimesheetReport timesheetReport) throws AxelorException {
Template reminderTemplate = Beans.get(AppHumanResourceService.class).getAppTimesheet().getTimesheetReminderTemplate();
if (reminderTemplate == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_NO_VALUE, I18n.get(IExceptionMessage.EMPLOYEE_TIMESHEET_REMINDER_TEMPLATE));
}
List<TimesheetReminder> timesheetReminders = getTimesheetReminderList(timesheetReport);
return sendEmailMessage(timesheetReminders, reminderTemplate);
}
use of com.axelor.apps.message.db.Template in project axelor-open-suite by axelor.
the class TimesheetServiceImpl method sendConfirmationEmail.
@Override
@Transactional(rollbackOn = { Exception.class })
public Message sendConfirmationEmail(Timesheet timesheet) throws AxelorException, ClassNotFoundException, InstantiationException, IllegalAccessException, MessagingException, IOException, JSONException {
HRConfig hrConfig = hrConfigService.getHRConfig(timesheet.getCompany());
Template template = hrConfig.getSentTimesheetTemplate();
if (hrConfig.getTimesheetMailNotification() && template != null) {
return templateMessageService.generateAndSendMessage(timesheet, template);
}
return null;
}
use of com.axelor.apps.message.db.Template in project axelor-open-suite by axelor.
the class TimesheetServiceImpl method sendValidationEmail.
@Override
@Transactional(rollbackOn = { Exception.class })
public Message sendValidationEmail(Timesheet timesheet) throws AxelorException, ClassNotFoundException, InstantiationException, IllegalAccessException, MessagingException, IOException, JSONException {
HRConfig hrConfig = hrConfigService.getHRConfig(timesheet.getCompany());
Template template = hrConfig.getValidatedTimesheetTemplate();
if (hrConfig.getTimesheetMailNotification() && template != null) {
return templateMessageService.generateAndSendMessage(timesheet, template);
}
return null;
}
Aggregations