use of com.serotonin.m2m2.vo.mailingList.EmailRecipient in project ma-core-public by infiniteautomation.
the class MailingListsDwr method getMailingList.
@DwrPermission(admin = true)
public MailingList getMailingList(int id) {
if (id == Common.NEW_ID) {
MailingList ml = new MailingList();
ml.setId(Common.NEW_ID);
ml.setXid(MailingListDao.instance.generateUniqueXid());
ml.setEntries(new LinkedList<EmailRecipient>());
return ml;
}
return MailingListDao.instance.getMailingList(id);
}
use of com.serotonin.m2m2.vo.mailingList.EmailRecipient 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);
}
use of com.serotonin.m2m2.vo.mailingList.EmailRecipient in project ma-core-public by infiniteautomation.
the class MailingListDao method saveRelationalData.
void saveRelationalData(final MailingList ml) {
// Save the inactive intervals.
ejt.update("delete from mailingListInactive where mailingListId=?", new Object[] { ml.getId() });
// Save what is in the mailing list object.
final List<Integer> intervalIds = new ArrayList<Integer>(ml.getInactiveIntervals());
ejt.batchUpdate(MAILING_LIST_INACTIVE_INSERT, new BatchPreparedStatementSetter() {
public int getBatchSize() {
return intervalIds.size();
}
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setInt(1, ml.getId());
ps.setInt(2, intervalIds.get(i));
}
});
// Delete existing entries
ejt.update("delete from mailingListMembers where mailingListId=?", new Object[] { ml.getId() });
// Save what is in the mailing list object.
final List<EmailRecipient> entries = ml.getEntries();
ejt.batchUpdate(MAILING_LIST_ENTRY_INSERT, new BatchPreparedStatementSetter() {
public int getBatchSize() {
return entries.size();
}
public void setValues(PreparedStatement ps, int i) throws SQLException {
EmailRecipient e = entries.get(i);
ps.setInt(1, ml.getId());
ps.setInt(2, e.getRecipientType());
ps.setInt(3, e.getReferenceId());
ps.setString(4, e.getReferenceAddress());
}
});
}
Aggregations