Search in sources :

Example 1 with UserEntry

use of com.serotonin.m2m2.vo.mailingList.UserEntry 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);
}
Also used : AddressEntry(com.serotonin.m2m2.vo.mailingList.AddressEntry) MailingList(com.serotonin.m2m2.vo.mailingList.MailingList) ShouldNeverHappenException(com.serotonin.ShouldNeverHappenException) UserEntry(com.serotonin.m2m2.vo.mailingList.UserEntry)

Example 2 with UserEntry

use of com.serotonin.m2m2.vo.mailingList.UserEntry 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;
}
Also used : EmailRecipient(com.serotonin.m2m2.vo.mailingList.EmailRecipient) User(com.serotonin.m2m2.vo.User) MailingList(com.serotonin.m2m2.vo.mailingList.MailingList) RecipientListEntryBean(com.serotonin.m2m2.web.dwr.beans.RecipientListEntryBean)

Example 3 with UserEntry

use of com.serotonin.m2m2.vo.mailingList.UserEntry in project ma-core-public by infiniteautomation.

the class RecipientListEntryBean 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);
}
Also used : AddressEntry(com.serotonin.m2m2.vo.mailingList.AddressEntry) MailingList(com.serotonin.m2m2.vo.mailingList.MailingList) ShouldNeverHappenException(com.serotonin.ShouldNeverHappenException) UserEntry(com.serotonin.m2m2.vo.mailingList.UserEntry)

Aggregations

MailingList (com.serotonin.m2m2.vo.mailingList.MailingList)3 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)2 AddressEntry (com.serotonin.m2m2.vo.mailingList.AddressEntry)2 UserEntry (com.serotonin.m2m2.vo.mailingList.UserEntry)2 User (com.serotonin.m2m2.vo.User)1 EmailRecipient (com.serotonin.m2m2.vo.mailingList.EmailRecipient)1 RecipientListEntryBean (com.serotonin.m2m2.web.dwr.beans.RecipientListEntryBean)1