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);
}
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;
}
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);
}
}
Aggregations