use of com.infiniteautomation.mango.rest.latest.model.javascript.MangoJavaScriptModel.ScriptContextVariableModel in project ma-modules-public by infiniteautomation.
the class EmailEventHandlerModel method fromVO.
@Override
public void fromVO(EmailEventHandlerVO vo) {
super.fromVO(vo);
this.sendEscalation = vo.isSendEscalation();
this.escalationDelayType = Common.TIME_PERIOD_CODES.getCode(vo.getEscalationDelayType());
this.repeatEscalations = vo.isRepeatEscalations();
this.escalationDelay = vo.getEscalationDelay();
this.sendInactive = vo.isSendInactive();
this.inactiveOverride = vo.isInactiveOverride();
this.includeSystemInfo = vo.isIncludeSystemInfo();
this.includePointValueCount = vo.getIncludePointValueCount() == 0 ? null : vo.getIncludePointValueCount();
this.includeLogfile = vo.isIncludeLogfile();
this.customTemplate = vo.getCustomTemplate();
this.script = vo.getScript();
if (vo.getScriptRoles() != null) {
this.scriptPermissions = new HashSet<>();
for (Role role : vo.getScriptRoles().getRoles()) {
this.scriptPermissions.add(role.getXid());
}
}
if (vo.getAdditionalContext() != null) {
this.scriptContext = new ArrayList<>();
for (IntStringPair var : vo.getAdditionalContext()) {
String xid = DataPointDao.getInstance().getXidById(var.getKey());
if (xid != null) {
this.scriptContext.add(new ScriptContextVariableModel(xid, var.getValue()));
}
}
}
this.subject = EmailEventHandlerVO.SUBJECT_INCLUDE_CODES.getCode(vo.getSubject());
}
use of com.infiniteautomation.mango.rest.latest.model.javascript.MangoJavaScriptModel.ScriptContextVariableModel in project ma-modules-public by infiniteautomation.
the class SetPointEventHandlerModel method fromVO.
@Override
public void fromVO(SetPointEventHandlerVO vo) {
super.fromVO(vo);
DataPointVO target = DataPointDao.getInstance().get(vo.getTargetPointId());
this.activeAction = SetPointEventHandlerVO.SET_ACTION_CODES.getCode(vo.getActiveAction());
if (target != null) {
this.targetPointXid = target.getXid();
if (vo.getActiveAction() == SetPointEventHandlerVO.SET_ACTION_STATIC_VALUE) {
DataValue value = DataValue.stringToValue(vo.getActiveValueToSet(), target.getPointLocator().getDataType());
this.activeValueToSet = value.getObjectValue();
}
if (vo.getInactiveAction() == SetPointEventHandlerVO.SET_ACTION_STATIC_VALUE) {
DataValue value = DataValue.stringToValue(vo.getInactiveValueToSet(), target.getPointLocator().getDataType());
this.inactiveValueToSet = value.getObjectValue();
}
}
if (vo.getActiveAction() == SetPointEventHandlerVO.SET_ACTION_POINT_VALUE)
this.activePointXid = DataPointDao.getInstance().getXidById(vo.getActivePointId());
if (vo.getInactiveAction() == SetPointEventHandlerVO.SET_ACTION_POINT_VALUE)
this.inactivePointXid = DataPointDao.getInstance().getXidById(vo.getInactivePointId());
this.inactiveAction = SetPointEventHandlerVO.SET_ACTION_CODES.getCode(vo.getInactiveAction());
this.activeScript = vo.getActiveScript();
this.inactiveScript = vo.getInactiveScript();
if (vo.getScriptRoles() != null) {
this.scriptPermissions = new HashSet<>();
for (Role role : vo.getScriptRoles().getRoles()) {
this.scriptPermissions.add(role.getXid());
}
}
if (vo.getAdditionalContext() != null) {
this.scriptContext = new ArrayList<>();
for (IntStringPair var : vo.getAdditionalContext()) {
String xid = DataPointDao.getInstance().getXidById(var.getKey());
if (xid != null) {
this.scriptContext.add(new ScriptContextVariableModel(xid, var.getValue()));
}
}
}
}
use of com.infiniteautomation.mango.rest.latest.model.javascript.MangoJavaScriptModel.ScriptContextVariableModel in project ma-modules-public by infiniteautomation.
the class SetPointEventHandlerModel method readInto.
@Override
public void readInto(SetPointEventHandlerVO vo) {
super.readInto(vo);
Integer targetId = DataPointDao.getInstance().getIdByXid(targetPointXid);
if (targetId != null)
vo.setTargetPointId(targetId);
vo.setActiveAction(SetPointEventHandlerVO.SET_ACTION_CODES.getId(activeAction));
if (activeValueToSet != null)
vo.setActiveValueToSet(activeValueToSet.toString());
if (activePointXid != null) {
Integer activePointId = DataPointDao.getInstance().getIdByXid(activePointXid);
if (activePointId != null)
vo.setActivePointId(activePointId);
}
vo.setActiveScript(activeScript);
vo.setInactiveAction(SetPointEventHandlerVO.SET_ACTION_CODES.getId(inactiveAction));
if (inactiveValueToSet != null)
vo.setInactiveValueToSet(inactiveValueToSet.toString());
if (inactivePointXid != null) {
Integer inactivePointId = DataPointDao.getInstance().getIdByXid(inactivePointXid);
if (inactivePointId != null)
vo.setInactivePointId(inactivePointId);
}
vo.setInactiveScript(inactiveScript);
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);
}
}
use of com.infiniteautomation.mango.rest.latest.model.javascript.MangoJavaScriptModel.ScriptContextVariableModel 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));
}
Aggregations