use of org.openmrs.notification.Template in project openmrs-core by openmrs.
the class MessageServiceImpl method prepareMessage.
/**
* Prepare a message based on a template and data used for variable substitution within template.
*
* @param templateName name of the template to be used
* @param data mapping used for variable substitution within template
* @return the prepared Message
*/
@Override
@Transactional(readOnly = true)
public Message prepareMessage(String templateName, Map data) throws MessageException {
try {
Template template = (Template) getTemplatesByName(templateName).get(0);
template.setData(data);
return Context.getMessageService().prepareMessage(template);
} catch (Exception e) {
throw new MessageException("Could not prepare message with template " + templateName, e);
}
}
Aggregations