use of com.axelor.apps.message.db.EmailAddress in project axelor-open-suite by axelor.
the class AppraisalServiceImpl method send.
@Transactional(rollbackOn = { Exception.class })
@Override
public void send(Appraisal appraisal) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, IOException, MessagingException {
Employee employee = appraisal.getEmployee();
User user = employee.getUser();
if (user != null) {
mailFollowerRepo.follow(appraisal, user);
}
Template template = templateRepo.all().filter("self.metaModel.fullName = ?1", Appraisal.class.getName()).fetchOne();
EmailAddress email = null;
if (employee.getContactPartner() != null) {
email = employee.getContactPartner().getEmailAddress();
}
if (template != null && email != null) {
Message message = templateMessageService.generateMessage(appraisal, template);
message.addToEmailAddressSetItem(email);
messageService.sendByEmail(message);
}
appraisal.setStatusSelect(AppraisalRepository.STATUS_SENT);
appraisalRepo.save(appraisal);
}
use of com.axelor.apps.message.db.EmailAddress in project axelor-open-suite by axelor.
the class PartnerServiceImpl method createPartner.
public Partner createPartner(String name, String firstName, String fixedPhone, String mobilePhone, EmailAddress emailAddress, Currency currency, Address deliveryAddress, Address mainInvoicingAddress, boolean createContact) {
Partner partner = new Partner();
partner.setName(name);
partner.setFirstName(firstName);
partner.setPartnerTypeSelect(PartnerRepository.PARTNER_TYPE_COMPANY);
partner.setIsProspect(true);
partner.setFixedPhone(fixedPhone);
partner.setMobilePhone(mobilePhone);
partner.setEmailAddress(emailAddress);
partner.setCurrency(currency);
this.setPartnerFullName(partner);
if (createContact) {
Partner contact = this.createContact(partner, name, firstName, fixedPhone, mobilePhone, emailAddress != null ? new EmailAddress(emailAddress.getAddress()) : null, mainInvoicingAddress);
partner.addContactPartnerSetItem(contact);
}
if (deliveryAddress == mainInvoicingAddress) {
addPartnerAddress(partner, mainInvoicingAddress, true, true, true);
} else {
addPartnerAddress(partner, deliveryAddress, true, false, true);
addPartnerAddress(partner, mainInvoicingAddress, true, true, false);
}
return partner;
}
use of com.axelor.apps.message.db.EmailAddress in project axelor-open-suite by axelor.
the class ConvertLeadWizardService method createEmailAddress.
public EmailAddress createEmailAddress(String address, Lead lead, Partner partner) {
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress(address);
emailAddress.setLead(lead);
emailAddress.setPartner(partner);
return emailAddress;
}
use of com.axelor.apps.message.db.EmailAddress in project axelor-open-suite by axelor.
the class OpportunityServiceImpl method createClientFromLead.
@Override
@Transactional(rollbackOn = { Exception.class })
public Partner createClientFromLead(Opportunity opportunity) throws AxelorException {
Lead lead = opportunity.getLead();
if (lead == null) {
throw new AxelorException(opportunity, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.LEAD_PARTNER));
}
String name = lead.getFullName();
Address address = null;
if (lead.getPrimaryAddress() != null) {
// avoids printing 'null'
String addressL6 = lead.getPrimaryPostalCode() == null ? "" : lead.getPrimaryPostalCode() + " ";
addressL6 += lead.getPrimaryCity() == null ? "" : lead.getPrimaryCity().getName();
address = addressService.createAddress(null, null, lead.getPrimaryAddress(), null, addressL6, lead.getPrimaryCountry());
address.setFullName(addressService.computeFullName(address));
}
EmailAddress email = null;
if (lead.getEmailAddress() != null) {
email = new EmailAddress(lead.getEmailAddress().getAddress());
}
Partner partner = Beans.get(PartnerService.class).createPartner(name, null, lead.getFixedPhone(), lead.getMobilePhone(), email, opportunity.getCurrency(), address, address, true);
opportunity.setPartner(partner);
opportunityRepo.save(opportunity);
return partner;
}
use of com.axelor.apps.message.db.EmailAddress in project axelor-open-suite by axelor.
the class DMSFileServiceImpl method sendEmail.
@Override
public void sendEmail(DMSFile dmsFile) throws AxelorException, MessagingException {
final EmailAccount emailAccount = mailAccountService.getDefaultSender();
User currentUser = AuthUtils.getUser();
User lockedBy = dmsFile.getLockedBy();
EmailAddress emailAddress = this.getEmailAddress(lockedBy);
String content = null;
String language = currentUser.getLanguage();
if (language != null && language.equals("fr")) {
content = String.format(CONTENT_EN, lockedBy.getFullName(), currentUser.getFullName());
} else {
content = String.format(CONTENT_EN, lockedBy.getFullName(), currentUser.getFullName());
}
List<EmailAddress> toEmailAddressList = new ArrayList<>();
toEmailAddressList.add(emailAddress);
Message message = messageService.createMessage(null, 0, I18n.get(SUBJECT), content, null, null, toEmailAddressList, null, null, null, null, MessageRepository.MEDIA_TYPE_EMAIL, emailAccount, null);
messageService.sendByEmail(message);
}
Aggregations