Search in sources :

Example 16 with Template

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

the class MessageServiceCrmImpl method createMessage.

@Transactional(rollbackOn = { Exception.class })
public Message createMessage(Event event) throws AxelorException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
    // Get template depending on event type
    Template template = null;
    switch(event.getTypeSelect()) {
        case EventRepository.TYPE_EVENT:
            template = Beans.get(CrmConfigService.class).getCrmConfig(event.getUser().getActiveCompany()).getEventTemplate();
            break;
        case EventRepository.TYPE_CALL:
            template = Beans.get(CrmConfigService.class).getCrmConfig(event.getUser().getActiveCompany()).getCallTemplate();
            break;
        case EventRepository.TYPE_MEETING:
            template = Beans.get(CrmConfigService.class).getCrmConfig(event.getUser().getActiveCompany()).getMeetingTemplate();
            break;
        case EventRepository.TYPE_TASK:
            template = Beans.get(CrmConfigService.class).getCrmConfig(event.getUser().getActiveCompany()).getTaskTemplate();
            break;
        default:
            break;
    }
    Message message = Beans.get(TemplateMessageService.class).generateMessage(event, template);
    return messageRepository.save(message);
}
Also used : CrmConfigService(com.axelor.apps.crm.service.config.CrmConfigService) Message(com.axelor.apps.message.db.Message) TemplateMessageService(com.axelor.apps.message.service.TemplateMessageService) Template(com.axelor.apps.message.db.Template) Transactional(com.google.inject.persist.Transactional)

Example 17 with Template

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

the class DebtRecoveryActionService method runStandardMessage.

/**
 * Fonction permettant de créer un courrier à destination des tiers pour un contrat standard
 *
 * @param debtRecovery
 * @return
 * @throws AxelorException
 * @throws ClassNotFoundException
 * @throws InstantiationException
 * @throws IllegalAccessException
 * @throws IOException
 */
public Set<Message> runStandardMessage(DebtRecovery debtRecovery) throws AxelorException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
    Set<Message> messages = new HashSet<>();
    DebtRecoveryMethodLine debtRecoveryMethodLine = debtRecovery.getDebtRecoveryMethodLine();
    Set<Template> templateSet = debtRecoveryMethodLine.getMessageTemplateSet();
    DebtRecoveryHistory debtRecoveryHistory = this.getDebtRecoveryHistory(debtRecovery);
    for (Template template : templateSet) {
        messages.add(templateMessageAccountService.generateMessage(debtRecoveryHistory, template));
    }
    return messages;
}
Also used : DebtRecoveryHistory(com.axelor.apps.account.db.DebtRecoveryHistory) IExceptionMessage(com.axelor.apps.account.exception.IExceptionMessage) Message(com.axelor.apps.message.db.Message) DebtRecoveryMethodLine(com.axelor.apps.account.db.DebtRecoveryMethodLine) HashSet(java.util.HashSet) Template(com.axelor.apps.message.db.Template)

Example 18 with Template

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

the class GenerateMessageController method generateMessage.

public void generateMessage(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    Map<?, ?> templateContext = (Map<?, ?>) context.get("_xTemplate");
    Template template = null;
    if (templateContext != null) {
        template = Beans.get(TemplateRepository.class).find(Long.parseLong(templateContext.get("id").toString()));
    }
    Long objectId = Long.parseLong(context.get("_objectId").toString());
    String model = (String) context.get("_templateContextModel");
    String tag = (String) context.get("_tag");
    try {
        response.setView(generateMessage(objectId, model, tag, template));
        response.setCanClose(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) Map(java.util.Map) IOException(java.io.IOException) AxelorException(com.axelor.exception.AxelorException) Template(com.axelor.apps.message.db.Template)

Aggregations

Template (com.axelor.apps.message.db.Template)18 AxelorException (com.axelor.exception.AxelorException)8 Transactional (com.google.inject.persist.Transactional)8 Message (com.axelor.apps.message.db.Message)7 IOException (java.io.IOException)5 Employee (com.axelor.apps.hr.db.Employee)4 HRConfig (com.axelor.apps.hr.db.HRConfig)4 TemplateMessageService (com.axelor.apps.message.service.TemplateMessageService)3 MessagingException (javax.mail.MessagingException)3 Company (com.axelor.apps.base.db.Company)2 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)2 EmailAddress (com.axelor.apps.message.db.EmailAddress)2 User (com.axelor.auth.db.User)2 MetaModel (com.axelor.meta.db.MetaModel)2 HashSet (java.util.HashSet)2 DebtRecoveryHistory (com.axelor.apps.account.db.DebtRecoveryHistory)1 DebtRecoveryMethodLine (com.axelor.apps.account.db.DebtRecoveryMethodLine)1 IExceptionMessage (com.axelor.apps.account.exception.IExceptionMessage)1 EbicsCertificate (com.axelor.apps.bankpayment.db.EbicsCertificate)1 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)1