use of com.infiniteautomation.mango.rest.latest.model.mailingList.EmailRecipientModel 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.infiniteautomation.mango.rest.latest.model.mailingList.EmailRecipientModel 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;
}
Aggregations