use of com.serotonin.m2m2.vo.mailingList.EmailRecipient in project ma-modules-public by infiniteautomation.
the class M2MRecipientListEntryBean method createEmailRecipient.
public EmailRecipient createEmailRecipient() {
switch(recipientType) {
case EmailRecipient.TYPE_MAILING_LIST:
MailingList ml = new MailingList();
ml.setId(referenceId);
return ml;
case EmailRecipient.TYPE_USER:
UserEntry u = new UserEntry();
u.setUserId(referenceId);
return u;
case EmailRecipient.TYPE_ADDRESS:
AddressEntry a = new AddressEntry();
a.setAddress(referenceAddress);
return a;
}
throw new ShouldNeverHappenException("Unknown email recipient type: " + recipientType);
}
use of com.serotonin.m2m2.vo.mailingList.EmailRecipient in project ma-core-public by infiniteautomation.
the class EmailRecipientModel method createBean.
/**
* Create a bean from a model
* @param model
* @return
*/
public static RecipientListEntryBean createBean(EmailRecipientModel<?> model) {
EmailRecipient r = model.getData();
RecipientListEntryBean bean = new RecipientListEntryBean();
bean.setRecipientType(r.getRecipientType());
switch(r.getRecipientType()) {
case EmailRecipient.TYPE_ADDRESS:
bean.setReferenceAddress(r.getReferenceAddress());
break;
case EmailRecipient.TYPE_MAILING_LIST:
// This only comes back with an XID from the page
MailingList list = MailingListDao.instance.getMailingList(((MailingList) r).getXid());
if (list != null)
bean.setReferenceId(list.getId());
break;
case EmailRecipient.TYPE_USER:
User u = UserDao.instance.getUser(((UserEntry) r).getUserId());
if (u != null)
bean.setReferenceId(u.getId());
break;
}
return bean;
}
use of com.serotonin.m2m2.vo.mailingList.EmailRecipient in project ma-core-public by infiniteautomation.
the class MailingListsDwr method createMailingList.
//
// /
// / Private helper methods
// /
//
private MailingList createMailingList(int id, String xid, String name, int receiveAlarmEmails, List<RecipientListEntryBean> entryBeans) {
// Convert the incoming information into more useful types.
MailingList ml = new MailingList();
ml.setId(id);
ml.setXid(xid);
ml.setName(name);
ml.setReceiveAlarmEmails(receiveAlarmEmails);
List<EmailRecipient> entries = new ArrayList<EmailRecipient>(entryBeans.size());
for (RecipientListEntryBean bean : entryBeans) entries.add(bean.createEmailRecipient());
ml.setEntries(entries);
return ml;
}
use of com.serotonin.m2m2.vo.mailingList.EmailRecipient in project ma-core-public by infiniteautomation.
the class MailingListDao method getRecipientAddresses.
public Set<String> getRecipientAddresses(List<RecipientListEntryBean> beans, DateTime sendTime) {
List<EmailRecipient> entries = new ArrayList<EmailRecipient>(beans.size());
for (RecipientListEntryBean bean : beans) entries.add(bean.createEmailRecipient());
populateEntrySubclasses(entries);
Set<String> addresses = new HashSet<String>();
for (EmailRecipient entry : entries) entry.appendAddresses(addresses, sendTime);
return addresses;
}
use of com.serotonin.m2m2.vo.mailingList.EmailRecipient in project ma-core-public by infiniteautomation.
the class MailingListDao method generateRecipientAddresses.
/**
* Generate the recipient addresses
* @param entries
* @param sendTime
* @return
*/
public Set<String> generateRecipientAddresses(List<EmailRecipient> entries, DateTime sendTime) {
populateEntrySubclasses(entries);
Set<String> addresses = new HashSet<String>();
for (EmailRecipient entry : entries) entry.appendAddresses(addresses, sendTime);
return addresses;
}
Aggregations