Search in sources :

Example 6 with EventTypeVO

use of com.serotonin.m2m2.vo.event.EventTypeVO in project ma-core-public by infiniteautomation.

the class AuditEventTypeSettingsListenerDefinition method SystemSettingsSaved.

/* (non-Javadoc)
	 * @see com.serotonin.m2m2.vo.systemSettings.SystemSettingsListener#SystemSettingsSaved(java.lang.String, java.lang.String, java.lang.String)
	 */
@Override
public void SystemSettingsSaved(String key, String oldValue, String newValue) {
    String[] parts = key.split(AuditEventType.AUDIT_SETTINGS_PREFIX);
    EventTypeVO et = AuditEventType.getEventType(parts[1]);
    et.setAlarmLevel(Integer.parseInt(newValue));
}
Also used : EventTypeVO(com.serotonin.m2m2.vo.event.EventTypeVO)

Example 7 with EventTypeVO

use of com.serotonin.m2m2.vo.event.EventTypeVO in project ma-modules-public by infiniteautomation.

the class EventTypeV2RestController method getAllDataSourceEventTypes.

private void getAllDataSourceEventTypes(List<EventTypeModel> types, User user, Integer dataSourceId, Integer dataSourceEventId) {
    List<DataSourceVO<?>> dataSources = DataSourceDao.instance.getAll();
    final boolean admin = Permissions.hasAdmin(user);
    for (DataSourceVO<?> dsvo : dataSources) if (dataSourceId == null || dataSourceId.intValue() == dsvo.getId())
        for (EventTypeVO dset : (List<EventTypeVO>) dsvo.getEventTypes()) if (dataSourceEventId == null || dataSourceEventId.intValue() == dset.getTypeRef2()) {
            EventType et = dset.createEventType();
            if (admin || Permissions.hasEventTypePermission(user, et))
                types.add(et.asModel());
        }
}
Also used : DataSourceVO(com.serotonin.m2m2.vo.dataSource.DataSourceVO) AuditEventType(com.serotonin.m2m2.rt.event.type.AuditEventType) EventType(com.serotonin.m2m2.rt.event.type.EventType) SystemEventType(com.serotonin.m2m2.rt.event.type.SystemEventType) ArrayList(java.util.ArrayList) List(java.util.List) EventTypeVO(com.serotonin.m2m2.vo.event.EventTypeVO)

Example 8 with EventTypeVO

use of com.serotonin.m2m2.vo.event.EventTypeVO 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 9 with EventTypeVO

use of com.serotonin.m2m2.vo.event.EventTypeVO in project ma-modules-public by infiniteautomation.

the class AuditRestController method listEventTypes.

@ApiOperation(value = "List all Audit Event Types in the system", notes = "Admin access only", response = String.class, responseContainer = "Array")
@RequestMapping(method = RequestMethod.GET, value = "list-event-types")
public ResponseEntity<List<EventTypeInfo>> listEventTypes(@AuthenticationPrincipal User user, HttpServletRequest request) {
    if (!user.isAdmin())
        throw new AccessDeniedException(user.getUsername() + " not admin, permission denied.");
    List<EventTypeInfo> types = new ArrayList<>(AuditEventType.EVENT_TYPES.size());
    for (EventTypeVO vo : AuditEventType.EVENT_TYPES) {
        EventTypeInfo info = new EventTypeInfo();
        info.type = vo.getType();
        info.subtype = vo.getSubtype();
        info.description = vo.getDescription();
        info.alarmLevel = AlarmLevels.CODES.getCode(vo.getAlarmLevel());
        types.add(info);
    }
    return ResponseEntity.ok(types);
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) ArrayList(java.util.ArrayList) EventTypeVO(com.serotonin.m2m2.vo.event.EventTypeVO) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with EventTypeVO

use of com.serotonin.m2m2.vo.event.EventTypeVO 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)

Aggregations

EventTypeVO (com.serotonin.m2m2.vo.event.EventTypeVO)12 ArrayList (java.util.ArrayList)4 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)3 AuditEventType (com.serotonin.m2m2.rt.event.type.AuditEventType)2 EventType (com.serotonin.m2m2.rt.event.type.EventType)2 SystemEventType (com.serotonin.m2m2.rt.event.type.SystemEventType)2 DataSourceVO (com.serotonin.m2m2.vo.dataSource.DataSourceVO)2 PublisherDao (com.serotonin.m2m2.db.dao.PublisherDao)1 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)1 EventTypeDefinition (com.serotonin.m2m2.module.EventTypeDefinition)1 ScriptPermissions (com.serotonin.m2m2.rt.script.ScriptPermissions)1 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)1 User (com.serotonin.m2m2.vo.User)1 PublisherVO (com.serotonin.m2m2.vo.publish.PublisherVO)1 DataPointBean (com.serotonin.m2m2.web.dwr.beans.DataPointBean)1 EventSourceBean (com.serotonin.m2m2.web.dwr.beans.EventSourceBean)1 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)1 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1