use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.
the class GenerateMessageController method generateMessage.
public Map<String, Object> generateMessage(long objectId, String model, String tag, Template template) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, IOException {
LOG.debug("template : {} ", template);
LOG.debug("object id : {} ", objectId);
LOG.debug("model : {} ", model);
LOG.debug("tag : {} ", tag);
Message message = null;
if (template != null) {
message = Beans.get(TemplateMessageService.class).generateMessage(objectId, model, tag, template);
} else {
message = Beans.get(MessageService.class).createMessage(model, Math.toIntExact(objectId), null, null, null, null, null, null, null, null, null, MessageRepository.MEDIA_TYPE_EMAIL, null, null);
}
return ActionView.define(I18n.get(IExceptionMessage.MESSAGE_3)).model(Message.class.getName()).add("form", "message-form").param("forceEdit", "true").context("_showRecord", message.getId().toString()).map();
}
use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.
the class TimesheetController method valid.
/**
* Action called when validating a timesheet. Changing status + Sending mail to Applicant
*
* @param request
* @param response
* @throws AxelorException
*/
public void valid(ActionRequest request, ActionResponse response) throws AxelorException {
try {
Timesheet timesheet = request.getContext().asType(Timesheet.class);
timesheet = Beans.get(TimesheetRepository.class).find(timesheet.getId());
TimesheetService timesheetService = Beans.get(TimesheetService.class);
timesheetService.checkEmptyPeriod(timesheet);
computeTimeSpent(request, response);
Message message = timesheetService.validateAndSendValidationEmail(timesheet);
if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
}
Beans.get(PeriodService.class).checkPeriod(timesheet.getCompany(), timesheet.getToDate(), timesheet.getFromDate());
} catch (Exception e) {
TraceBackService.trace(response, e);
} finally {
response.setReload(true);
}
}
use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.
the class TimesheetReportController method sendTimesheetReminder.
public void sendTimesheetReminder(ActionRequest request, ActionResponse response) throws AxelorException {
TimesheetReport timesheetReport = request.getContext().asType(TimesheetReport.class);
if (ObjectUtils.isEmpty(timesheetReport.getReminderUserSet())) {
return;
}
List<Message> messages = Beans.get(TimesheetReportService.class).sendReminders(timesheetReport);
List<Long> messageIds = new ArrayList<Long>();
messageIds.add(0L);
for (Message message : messages) {
messageIds.add(message.getId());
}
response.setView(ActionView.define(I18n.get("Messages")).model(Message.class.getName()).add("grid", "message-timesheet-reminder-grid").add("form", "message-form").domain("self.id in (:messageIds)").context("messageIds", messageIds).map());
}
use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.
the class CampaignServiceImpl method generateAndSendMessage.
@Transactional(rollbackOn = { Exception.class })
protected void generateAndSendMessage(Campaign campaign, Model model, Template template) throws ClassNotFoundException, InstantiationException, IllegalAccessException, MessagingException, IOException, AxelorException, JSONException {
Message message = templateMessageMarketingService.generateAndSendMessage(model, template);
message.setRelatedTo1Select(Campaign.class.getCanonicalName());
message.setRelatedTo1SelectId(campaign.getId());
}
Aggregations