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));
}
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());
}
}
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());
}
}
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);
}
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;
}
Aggregations