Search in sources :

Example 11 with EventType

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());
        }
}
Also used : AuditEventType(com.serotonin.m2m2.rt.event.type.AuditEventType) EventType(com.serotonin.m2m2.rt.event.type.EventType) SystemEventType(com.serotonin.m2m2.rt.event.type.SystemEventType) PublisherVO(com.serotonin.m2m2.vo.publish.PublisherVO) EventTypeVO(com.serotonin.m2m2.vo.event.EventTypeVO)

Example 12 with EventType

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);
}
Also used : SetPointEventHandlerVO(com.serotonin.m2m2.vo.event.SetPointEventHandlerVO) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 13 with EventType

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);
}
Also used : EmailEventHandlerVO(com.serotonin.m2m2.vo.event.EmailEventHandlerVO) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 14 with EventType

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;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) EventTypeVO(com.serotonin.m2m2.vo.event.EventTypeVO)

Example 15 with EventType

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);
}
Also used : User(com.serotonin.m2m2.vo.User) SystemEventType(com.serotonin.m2m2.rt.event.type.SystemEventType) AuditEventType(com.serotonin.m2m2.rt.event.type.AuditEventType) EventType(com.serotonin.m2m2.rt.event.type.EventType) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

EventType (com.serotonin.m2m2.rt.event.type.EventType)10 SystemEventType (com.serotonin.m2m2.rt.event.type.SystemEventType)9 AuditEventType (com.serotonin.m2m2.rt.event.type.AuditEventType)7 User (com.serotonin.m2m2.vo.User)6 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)6 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)4 EventInstance (com.serotonin.m2m2.rt.event.EventInstance)4 ArrayList (java.util.ArrayList)4 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)3 DataPointEventType (com.serotonin.m2m2.rt.event.type.DataPointEventType)3 DataSourceEventType (com.serotonin.m2m2.rt.event.type.DataSourceEventType)3 MissingEventType (com.serotonin.m2m2.rt.event.type.MissingEventType)3 PublisherEventType (com.serotonin.m2m2.rt.event.type.PublisherEventType)3 EventTypeVO (com.serotonin.m2m2.vo.event.EventTypeVO)3 EventTypeDefinition (com.serotonin.m2m2.module.EventTypeDefinition)2 UserEventListener (com.serotonin.m2m2.rt.event.UserEventListener)2 LongPair (com.serotonin.m2m2.vo.pair.LongPair)2 DateTime (org.joda.time.DateTime)2 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)1 JsonException (com.serotonin.json.JsonException)1