Search in sources :

Example 16 with Message

use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.

the class ActionEmailBuilderService method sendEmail.

@CallMethod
public ActionResponse sendEmail(Long objectId, String model, String tag, Long templateId, int sendOption) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, IOException, MessagingException {
    Template template = templateRepo.find(templateId);
    Message message = templateMessageService.generateMessage(objectId, model, tag, template);
    ActionResponse response = new ActionResponse();
    if (sendOption == 0) {
        messageService.sendByEmail(message);
    } else {
        response.setView(ActionView.define(I18n.get(IExceptionMessage.MESSAGE_3)).model(Message.class.getName()).add("form", "message-form").param("forceEdit", "true").context("_showRecord", message.getId().toString()).map());
    }
    return response;
}
Also used : Message(com.axelor.apps.message.db.Message) IExceptionMessage(com.axelor.apps.message.exception.IExceptionMessage) ActionResponse(com.axelor.rpc.ActionResponse) Template(com.axelor.apps.message.db.Template) CallMethod(com.axelor.meta.CallMethod)

Example 17 with Message

use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.

the class BatchTimesheetReminder method sendReminderUsingEmployees.

protected void sendReminderUsingEmployees(Template template) throws AxelorException, MessagingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
    for (Employee employee : getEmployeesWithoutRecentTimesheet(Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null)).stream().filter(Objects::nonNull).collect(Collectors.toList())) {
        Message message = templateMessageService.generateMessage(employee, template);
        messageService.sendByEmail(message);
        incrementDone();
    }
}
Also used : Employee(com.axelor.apps.hr.db.Employee) IExceptionMessage(com.axelor.apps.hr.exception.IExceptionMessage) Message(com.axelor.apps.message.db.Message)

Example 18 with Message

use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.

the class BatchTimesheetReminder method sendReminderUsingTimesheets.

protected void sendReminderUsingTimesheets(Template template) throws AxelorException, MessagingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
    for (Employee employee : getEmployeesWithoutRecentTimesheet(Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null)).stream().filter(Objects::nonNull).collect(Collectors.toList())) {
        if (employee == null || EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
            continue;
        }
        Timesheet timeSheet = getRecentEmployeeTimesheet(employee);
        if (timeSheet != null) {
            Message message = templateMessageService.generateMessage(timeSheet, template);
            messageService.sendByEmail(message);
        } else {
            throw new AxelorException(Timesheet.class, TraceBackRepository.CATEGORY_NO_VALUE, I18n.get(IExceptionMessage.NO_TIMESHEET_FOUND_FOR_EMPLOYEE), employee.getName());
        }
        incrementDone();
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) Employee(com.axelor.apps.hr.db.Employee) IExceptionMessage(com.axelor.apps.hr.exception.IExceptionMessage) Message(com.axelor.apps.message.db.Message) Timesheet(com.axelor.apps.hr.db.Timesheet)

Example 19 with Message

use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.

the class MessageController method printMessage.

/**
 * Method that generate message as a pdf
 *
 * @param request
 * @param response
 * @return
 * @throws BirtException
 * @throws IOException
 */
public void printMessage(ActionRequest request, ActionResponse response) throws AxelorException {
    Message message = request.getContext().asType(Message.class);
    message = Beans.get(MessageRepository.class).find(message.getId());
    String pdfPath = Beans.get(MessageService.class).printMessage(message);
    if (pdfPath != null) {
        response.setView(ActionView.define("Message " + message.getSubject()).add("html", pdfPath).map());
    } else
        response.setFlash(I18n.get(IExceptionMessage.MESSAGE_1));
}
Also used : Message(com.axelor.apps.message.db.Message) IExceptionMessage(com.axelor.apps.base.exceptions.IExceptionMessage) MessageService(com.axelor.apps.message.service.MessageService)

Example 20 with Message

use of com.axelor.apps.message.db.Message in project axelor-open-suite by axelor.

the class MailAccountServiceTalentImpl method createMessage.

@Transactional(rollbackOn = { Exception.class })
@Override
public Message createMessage(EmailAccount mailAccount, MailParser parser, Date date) throws MessagingException {
    Message message = super.createMessage(mailAccount, parser, date);
    AppRecruitment appRecruitment = appRecruitmentRepo.all().fetchOne();
    if (appRecruitment != null && appRecruitment.getApp().getActive() && message.getMailAccount() != null && message.getMailAccount().getServerTypeSelect() > 1) {
        String lastEmailId = appRecruitment.getLastEmailId();
        if (lastEmailId == null || message.getId() > Long.parseLong(lastEmailId)) {
            jobPositionService.createJobApplication(message);
        }
    }
    return message;
}
Also used : Message(com.axelor.apps.message.db.Message) AppRecruitment(com.axelor.apps.base.db.AppRecruitment) Transactional(com.google.inject.persist.Transactional)

Aggregations

Message (com.axelor.apps.message.db.Message)54 AxelorException (com.axelor.exception.AxelorException)25 MessageServiceBaseImpl (com.axelor.apps.base.service.message.MessageServiceBaseImpl)16 IExceptionMessage (com.axelor.apps.message.exception.IExceptionMessage)14 Transactional (com.google.inject.persist.Transactional)13 IExceptionMessage (com.axelor.apps.hr.exception.IExceptionMessage)11 Template (com.axelor.apps.message.db.Template)7 Timesheet (com.axelor.apps.hr.db.Timesheet)6 ArrayList (java.util.ArrayList)6 Employee (com.axelor.apps.hr.db.Employee)5 EmailAddress (com.axelor.apps.message.db.EmailAddress)5 IExceptionMessage (com.axelor.apps.base.exceptions.IExceptionMessage)4 Expense (com.axelor.apps.hr.db.Expense)4 ExtraHours (com.axelor.apps.hr.db.ExtraHours)4 LeaveRequest (com.axelor.apps.hr.db.LeaveRequest)4 ExpenseService (com.axelor.apps.hr.service.expense.ExpenseService)4 ExtraHoursService (com.axelor.apps.hr.service.extra.hours.ExtraHoursService)4 LeaveService (com.axelor.apps.hr.service.leave.LeaveService)4 TimesheetService (com.axelor.apps.hr.service.timesheet.TimesheetService)4 User (com.axelor.auth.db.User)4