use of com.serotonin.m2m2.vo.mailingList.MailingListRecipient in project ma-core-public by MangoAutomation.
the class RecipientListEntryBean method createEmailRecipient.
/**
* Convert to mailing list recipient
*/
public MailingListRecipient createEmailRecipient() {
RecipientListEntryType type = RecipientListEntryType.fromValue(recipientType);
switch(type) {
case ADDRESS:
AddressEntry a = new AddressEntry();
a.setAddress(referenceAddress);
return a;
case MAILING_LIST:
MailingListEntry ml = new MailingListEntry();
ml.setMailingListId(referenceId);
return ml;
case PHONE_NUMBER:
PhoneEntry pe = new PhoneEntry();
pe.setPhone(referenceAddress);
return pe;
case USER:
UserEntry u = new UserEntry();
u.setUserId(referenceId);
return u;
case USER_PHONE_NUMBER:
PhoneEntry p = new PhoneEntry();
p.setPhone(referenceAddress);
return p;
default:
throw new ShouldNeverHappenException("Unknown recipient type: " + recipientType);
}
}
use of com.serotonin.m2m2.vo.mailingList.MailingListRecipient in project ma-core-public by MangoAutomation.
the class EmailHandlerRTTest method testSendActiveInactive.
@Test
public void testSendActiveInactive() {
EmailEventHandlerVO vo = createVO();
vo.setSendInactive(true);
List<MailingListRecipient> activeRecipients = createRecipients();
vo.setActiveRecipients(activeRecipients);
EmailHandlerRT rt = new EmailHandlerRT(vo);
EventInstance evt = createDataPointEventInstance();
rt.eventRaised(evt);
// Ensure there is one scheduled
assertEquals(1, scheduledItems.size());
scheduledItems.clear();
// Make Inactive
evt.returnToNormal(this.timer.currentTimeMillis(), ReturnCause.RETURN_TO_NORMAL);
rt.eventInactive(evt);
assertEquals(1, scheduledItems.size());
}
use of com.serotonin.m2m2.vo.mailingList.MailingListRecipient in project ma-core-public by MangoAutomation.
the class EmailHandlerRTTest method createRecipients.
protected List<MailingListRecipient> createRecipients() {
List<MailingListRecipient> recipients = new ArrayList<>();
AddressEntry address = new AddressEntry();
address.setAddress("test@test.com");
recipients.add(address);
return recipients;
}
use of com.serotonin.m2m2.vo.mailingList.MailingListRecipient in project ma-core-public by MangoAutomation.
the class MailingListService method recursivelyCheckMailingListEntries.
/**
*/
private void recursivelyCheckMailingListEntries(Set<Integer> listIds, MailingList list, String prefix, ProcessResult result) {
for (MailingListRecipient recipient : list.getEntries()) {
switch(recipient.getRecipientType()) {
case MAILING_LIST:
if (!listIds.add(recipient.getReferenceId())) {
// Failed, we already have this list as reference
result.addContextualMessage(prefix, "mailingLists.validate.listCannotContainItself");
return;
} else {
MailingList sublist = dao.get(recipient.getReferenceId());
recursivelyCheckMailingListEntries(listIds, sublist, prefix, result);
}
break;
default:
break;
}
}
}
use of com.serotonin.m2m2.vo.mailingList.MailingListRecipient in project ma-core-public by infiniteautomation.
the class MailingListDao method getRecipientType.
private MailingListRecipient getRecipientType(Record record) {
int intType = record.get(mailingListMembersTable.typeId);
RecipientListEntryType type = RecipientListEntryType.fromValue(intType);
Integer userId = record.get(mailingListMembersTable.userId);
switch(type) {
case ADDRESS:
AddressEntry ae = new AddressEntry();
ae.setAddress(record.get(mailingListMembersTable.address));
return ae;
case MAILING_LIST:
MailingListEntry ml = new MailingListEntry();
ml.setMailingListId(userId != null ? userId : 0);
return ml;
case PHONE_NUMBER:
PhoneEntry pe = new PhoneEntry();
pe.setPhone(record.get(mailingListMembersTable.address));
return pe;
case USER:
case USER_PHONE_NUMBER:
UserEntry ue = new UserEntry();
ue.setUserId(userId != null ? userId : 0);
return ue;
default:
throw new ShouldNeverHappenException("Unknown mailing list entry type: " + intType);
}
}
Aggregations