Search in sources :

Example 26 with Message

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

the class MessageServiceImpl method attachMetaFiles.

@Override
@Transactional
public void attachMetaFiles(Message message, Set<MetaFile> metaFiles) {
    Preconditions.checkNotNull(message.getId());
    if (metaFiles == null || metaFiles.isEmpty()) {
        return;
    }
    log.debug("Add metafiles to object {}:{}", Message.class.getName(), message.getId());
    for (MetaFile metaFile : metaFiles) {
        Beans.get(MetaFiles.class).attach(metaFile, metaFile.getFileName(), message);
    }
}
Also used : MetaFiles(com.axelor.meta.MetaFiles) Message(com.axelor.apps.message.db.Message) IExceptionMessage(com.axelor.apps.message.exception.IExceptionMessage) MetaFile(com.axelor.meta.db.MetaFile) Transactional(com.google.inject.persist.Transactional)

Example 27 with Message

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

the class MessageController method print.

public void print(ActionRequest request, ActionResponse response) throws AxelorException {
    Message message = request.getContext().asType(Message.class);
    String messageIds = "";
    @SuppressWarnings("unchecked") List<Integer> lstSelectedMessages = (List<Integer>) request.getContext().get("_ids");
    if (lstSelectedMessages != null) {
        for (Integer it : lstSelectedMessages) {
            messageIds += it.toString() + ",";
        }
    }
    if (!messageIds.equals("")) {
        messageIds = messageIds.substring(0, messageIds.length() - 1);
        message = Beans.get(MessageRepository.class).find(new Long(lstSelectedMessages.get(0)));
    } else if (message.getId() != null) {
        messageIds = message.getId().toString();
    }
    if (!messageIds.equals("")) {
        String language = ReportSettings.getPrintingLocale(null);
        String title = " ";
        if (message.getSubject() != null) {
            title += lstSelectedMessages == null ? "Message " + message.getSubject() : "Messages";
        }
        String fileLink = ReportFactory.createReport(IReport.MESSAGE_PDF, title + "-${date}").addParam("Locale", language).addParam("MessageId", messageIds).addParam("Timezone", null).addFormat(ReportSettings.FORMAT_XLS).generate().getFileLink();
        logger.debug("Printing " + title);
        response.setView(ActionView.define(title).add("html", fileLink).map());
    } else {
        response.setFlash(I18n.get(IExceptionMessage.MESSAGE_2));
    }
}
Also used : Message(com.axelor.apps.message.db.Message) IExceptionMessage(com.axelor.apps.base.exceptions.IExceptionMessage) List(java.util.List)

Example 28 with Message

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

the class PartnerController method findContactMails.

public void findContactMails(ActionRequest request, ActionResponse response) {
    Partner partner = request.getContext().asType(Partner.class);
    List<Long> idList = Beans.get(PartnerService.class).findContactMails(partner);
    List<Message> emailsList = new ArrayList<Message>();
    for (Long id : idList) {
        Message message = Beans.get(MessageRepository.class).find(id);
        if (!emailsList.contains(message)) {
            emailsList.add(message);
        }
    }
    response.setValue("$emailsList", emailsList);
}
Also used : Message(com.axelor.apps.message.db.Message) IExceptionMessage(com.axelor.apps.base.exceptions.IExceptionMessage) ArrayList(java.util.ArrayList) MessageRepository(com.axelor.apps.message.db.repo.MessageRepository) PartnerService(com.axelor.apps.base.service.PartnerService) Partner(com.axelor.apps.base.db.Partner)

Example 29 with Message

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

the class PartnerController method findPartnerMails.

public void findPartnerMails(ActionRequest request, ActionResponse response) {
    Partner partner = request.getContext().asType(Partner.class);
    List<Long> idList = Beans.get(PartnerService.class).findPartnerMails(partner);
    List<Message> emailsList = new ArrayList<Message>();
    for (Long id : idList) {
        Message message = Beans.get(MessageRepository.class).find(id);
        if (!emailsList.contains(message)) {
            emailsList.add(message);
        }
    }
    response.setValue("$emailsList", emailsList);
}
Also used : Message(com.axelor.apps.message.db.Message) IExceptionMessage(com.axelor.apps.base.exceptions.IExceptionMessage) ArrayList(java.util.ArrayList) MessageRepository(com.axelor.apps.message.db.repo.MessageRepository) PartnerService(com.axelor.apps.base.service.PartnerService) Partner(com.axelor.apps.base.db.Partner)

Example 30 with Message

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

the class LeaveController method cancel.

public void cancel(ActionRequest request, ActionResponse response) {
    try {
        LeaveRequest leave = request.getContext().asType(LeaveRequest.class);
        leave = Beans.get(LeaveRequestRepository.class).find(leave.getId());
        LeaveService leaveService = Beans.get(LeaveService.class);
        leaveService.cancel(leave);
        Message message = leaveService.sendCancellationEmail(leave);
        if (message != null && message.getStatusSelect() == MessageRepository.STATUS_SENT) {
            response.setFlash(String.format(I18n.get("Email sent to %s"), Beans.get(MessageServiceBaseImpl.class).getToRecipients(message)));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    } finally {
        response.setReload(true);
    }
}
Also used : IExceptionMessage(com.axelor.apps.hr.exception.IExceptionMessage) Message(com.axelor.apps.message.db.Message) LeaveService(com.axelor.apps.hr.service.leave.LeaveService) MessageServiceBaseImpl(com.axelor.apps.base.service.message.MessageServiceBaseImpl) LeaveRequest(com.axelor.apps.hr.db.LeaveRequest) AxelorException(com.axelor.exception.AxelorException)

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