use of com.serotonin.m2m2.rt.event.type.EventType in project ma-modules-public by infiniteautomation.
the class EventTypeV2RestController method getAllPublisherEventTypes.
private void getAllPublisherEventTypes(List<EventTypeModel> types, User user, Integer publisherId, Integer publisherEventId) {
List<PublisherVO<?>> publishers = PublisherDao.instance.getAll();
final boolean admin = Permissions.hasAdmin(user);
for (PublisherVO<?> pvo : publishers) if (publisherId == null || publisherId.intValue() == pvo.getId())
for (EventTypeVO pet : pvo.getEventTypes()) if (publisherEventId == null || publisherEventId.intValue() == pet.getTypeRef2()) {
EventType et = pet.createEventType();
if (admin || Permissions.hasEventTypePermission(user, et))
types.add(et.asModel());
}
}
use of com.serotonin.m2m2.rt.event.type.EventType in project ma-core-public by infiniteautomation.
the class EventHandlersDwr method saveSetPointEventHandler.
@DwrPermission(user = true)
public ProcessResult saveSetPointEventHandler(String eventType, String eventSubtype, int eventTypeRef1, int eventTypeRef2, int handlerId, String xid, String alias, boolean disabled, int targetPointId, int activeAction, String activeValueToSet, int activePointId, String activeScript, int inactiveAction, String inactiveValueToSet, int inactivePointId, String inactiveScript, List<IntStringPair> additionalContext, ScriptPermissions scriptPermissions) {
SetPointEventHandlerVO handler = new SetPointEventHandlerVO();
handler.setDefinition(ModuleRegistry.getEventHandlerDefinition(SetPointEventHandlerDefinition.TYPE_NAME));
handler.setTargetPointId(targetPointId);
handler.setActiveAction(activeAction);
handler.setActiveValueToSet(activeValueToSet);
handler.setActivePointId(activePointId);
handler.setActiveScript(activeScript);
handler.setInactiveAction(inactiveAction);
handler.setInactiveValueToSet(inactiveValueToSet);
handler.setInactivePointId(inactivePointId);
handler.setInactiveScript(inactiveScript);
handler.setAdditionalContext(additionalContext);
handler.setScriptPermissions(scriptPermissions);
return save(eventType, eventSubtype, eventTypeRef1, eventTypeRef2, handler, handlerId, xid, alias, disabled);
}
use of com.serotonin.m2m2.rt.event.type.EventType in project ma-core-public by infiniteautomation.
the class EventHandlersDwr method saveEmailEventHandler.
@DwrPermission(user = true)
public ProcessResult saveEmailEventHandler(String eventType, String eventSubtype, int eventTypeRef1, int eventTypeRef2, int handlerId, String xid, String alias, boolean disabled, List<RecipientListEntryBean> activeRecipients, String customTemplate, boolean sendEscalation, boolean repeatEscalations, int escalationDelayType, int escalationDelay, List<RecipientListEntryBean> escalationRecipients, boolean sendInactive, boolean inactiveOverride, List<RecipientListEntryBean> inactiveRecipients, boolean includeSystemInfo, int includePointValueCount, boolean includeLogfile, List<IntStringPair> additionalContext, ScriptPermissions permissions, String script) {
EmailEventHandlerVO handler = new EmailEventHandlerVO();
handler.setDefinition(ModuleRegistry.getEventHandlerDefinition(EmailEventHandlerDefinition.TYPE_NAME));
handler.setActiveRecipients(activeRecipients);
handler.setCustomTemplate(customTemplate);
handler.setSendEscalation(sendEscalation);
handler.setRepeatEscalations(repeatEscalations);
handler.setEscalationDelayType(escalationDelayType);
handler.setEscalationDelay(escalationDelay);
handler.setEscalationRecipients(escalationRecipients);
handler.setSendInactive(sendInactive);
handler.setInactiveOverride(inactiveOverride);
handler.setInactiveRecipients(inactiveRecipients);
handler.setIncludeSystemInfo(includeSystemInfo);
handler.setIncludePointValueCount(includePointValueCount);
handler.setIncludeLogfile(includeLogfile);
handler.setAdditionalContext(additionalContext);
handler.setScriptPermissions(permissions);
handler.setScript(script);
return save(eventType, eventSubtype, eventTypeRef1, eventTypeRef2, handler, handlerId, xid, alias, disabled);
}
use of com.serotonin.m2m2.rt.event.type.EventType in project ma-core-public by infiniteautomation.
the class EventHandlersDwr method save.
private ProcessResult save(String eventType, String eventSubtype, int eventTypeRef1, int eventTypeRef2, AbstractEventHandlerVO<?> vo, int handlerId, String xid, String alias, boolean disabled) {
EventTypeVO type = new EventTypeVO(eventType, eventSubtype, eventTypeRef1, eventTypeRef2);
Permissions.ensureEventTypePermission(Common.getHttpUser(), type);
vo.setId(handlerId);
vo.setXid(StringUtils.isBlank(xid) ? EventHandlerDao.instance.generateUniqueXid() : xid);
vo.setAlias(alias);
vo.setDisabled(disabled);
ProcessResult response = new ProcessResult();
vo.validate(response);
if (!response.getHasMessages()) {
EventHandlerDao.instance.saveEventHandler(type, vo);
response.addData("handler", vo);
}
return response;
}
use of com.serotonin.m2m2.rt.event.type.EventType in project ma-core-public by infiniteautomation.
the class EventHandlersDwr method deleteEventHandler.
@DwrPermission(user = true)
public void deleteEventHandler(int handlerId) {
User user = Common.getHttpUser();
List<EventType> eventTypes = EventHandlerDao.instance.getEventTypesForHandler(handlerId);
for (EventType et : eventTypes) Permissions.ensureEventTypePermission(user, et);
EventHandlerDao.instance.deleteEventHandler(handlerId);
}
Aggregations