use of com.serotonin.m2m2.vo.mailingList.MailingListRecipient in project ma-modules-public by infiniteautomation.
the class EmailEventHandlerModel method readInto.
@Override
public void readInto(EmailEventHandlerVO vo) {
super.readInto(vo);
if (activeRecipients != null) {
List<MailingListRecipient> beans = new ArrayList<>();
for (EmailRecipientModel model : activeRecipients) beans.add(model.fromModel());
vo.setActiveRecipients(beans);
}
vo.setSendEscalation(sendEscalation);
vo.setRepeatEscalations(repeatEscalations);
vo.setEscalationDelayType(Common.TIME_PERIOD_CODES.getId(escalationDelayType));
vo.setEscalationDelay(escalationDelay);
if (escalationRecipients != null) {
List<MailingListRecipient> beans = new ArrayList<>();
for (EmailRecipientModel model : escalationRecipients) beans.add(model.fromModel());
vo.setEscalationRecipients(beans);
}
vo.setSendInactive(sendInactive);
vo.setInactiveOverride(inactiveOverride);
if (inactiveRecipients != null) {
List<MailingListRecipient> beans = new ArrayList<>();
for (EmailRecipientModel model : inactiveRecipients) beans.add(model.fromModel());
vo.setInactiveRecipients(beans);
}
vo.setIncludeSystemInfo(includeSystemInfo);
if (includePointValueCount != null)
vo.setIncludePointValueCount(includePointValueCount);
vo.setIncludeLogfile(includeLogfile);
vo.setCustomTemplate(customTemplate);
vo.setScript(script);
PermissionService service = Common.getBean(PermissionService.class);
vo.setScriptRoles(new ScriptPermissions(service.explodeLegacyPermissionGroupsToRoles(scriptPermissions)));
if (scriptContext != null) {
List<IntStringPair> additionalContext = new ArrayList<>();
for (ScriptContextVariableModel var : scriptContext) {
Integer id = DataPointDao.getInstance().getIdByXid(var.getXid());
if (id != null) {
additionalContext.add(new IntStringPair(id, var.getVariableName()));
} else {
additionalContext.add(new IntStringPair(Common.NEW_ID, var.getVariableName()));
}
}
vo.setAdditionalContext(additionalContext);
}
vo.setSubject(EmailEventHandlerVO.SUBJECT_INCLUDE_CODES.getId(subject));
}
use of com.serotonin.m2m2.vo.mailingList.MailingListRecipient in project ma-modules-public by infiniteautomation.
the class EmailEventHandlerModelMapping method mapHandler.
@Override
public EmailEventHandlerModel mapHandler(EmailEventHandlerVO vo, PermissionHolder user, RestModelMapper mapper) {
EmailEventHandlerModel model = new EmailEventHandlerModel(vo);
if (vo.getActiveRecipients() != null) {
List<EmailRecipientModel> activeRecipients = new ArrayList<>();
model.setActiveRecipients(activeRecipients);
for (MailingListRecipient bean : vo.getActiveRecipients()) {
activeRecipients.add(mapper.map(bean, EmailRecipientModel.class, user));
}
}
if (vo.getEscalationRecipients() != null) {
List<EmailRecipientModel> escalationRecipients = new ArrayList<>();
model.setEscalationRecipients(escalationRecipients);
for (MailingListRecipient bean : vo.getEscalationRecipients()) {
escalationRecipients.add(mapper.map(bean, EmailRecipientModel.class, user));
}
}
if (vo.getInactiveRecipients() != null) {
List<EmailRecipientModel> inactiveRecipients = new ArrayList<>();
model.setInactiveRecipients(inactiveRecipients);
for (MailingListRecipient bean : vo.getInactiveRecipients()) {
inactiveRecipients.add(mapper.map(bean, EmailRecipientModel.class, user));
}
}
return model;
}
use of com.serotonin.m2m2.vo.mailingList.MailingListRecipient in project ma-core-public by infiniteautomation.
the class MailingListServiceTest method assertVoEqual.
@Override
void assertVoEqual(MailingList expected, MailingList actual) {
assertEquals(expected.getId(), actual.getId());
assertEquals(expected.getReceiveAlarmEmails(), actual.getReceiveAlarmEmails());
assertEquals(expected.getEntries().size(), actual.getEntries().size());
for (int i = 0; i < expected.getEntries().size(); i++) {
MailingListRecipient expectedRecipient = expected.getEntries().get(i);
MailingListRecipient actualRecipient = actual.getEntries().get(i);
switch(expectedRecipient.getRecipientType()) {
case ADDRESS:
case PHONE_NUMBER:
assertEquals(expectedRecipient.getReferenceAddress(), actualRecipient.getReferenceAddress());
break;
case USER:
case USER_PHONE_NUMBER:
case MAILING_LIST:
assertEquals(expectedRecipient.getReferenceId(), actualRecipient.getReferenceId());
break;
default:
fail("unknown recipient type");
}
}
assertPermission(expected.getReadPermission(), actual.getReadPermission());
assertPermission(expected.getEditPermission(), actual.getEditPermission());
}
use of com.serotonin.m2m2.vo.mailingList.MailingListRecipient in project ma-core-public by infiniteautomation.
the class MailingListServiceTest method newVO.
@Override
MailingList newVO(User owner) {
MailingList vo = new MailingList();
vo.setXid(MailingListDao.getInstance().generateUniqueXid());
vo.setName("MailingList");
vo.setReceiveAlarmEmails(AlarmLevels.NONE);
List<MailingListRecipient> entries = new ArrayList<>();
AddressEntry entry = new AddressEntry();
entry.setAddress("entry1@example.com");
entries.add(entry);
vo.setEntries(entries);
return vo;
}
use of com.serotonin.m2m2.vo.mailingList.MailingListRecipient in project ma-core-public by infiniteautomation.
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;
}
Aggregations