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