use of com.serotonin.m2m2.vo.event.EventTypeVO in project ma-core-public by infiniteautomation.
the class EventHandlersDwr method getInitData.
@DwrPermission(user = true)
public Map<String, Object> getInitData() {
User user = Common.getHttpUser();
Permissions.ensureDataSourcePermission(user);
Map<String, Object> model = new HashMap<>();
// Get the data sources.
List<DataSourceVO<?>> dss = DataSourceDao.instance.getDataSources();
// Create a lookup of data sources to quickly determine data point permissions.
Map<Integer, DataSourceVO<?>> dslu = new HashMap<>();
for (DataSourceVO<?> ds : dss) dslu.put(ds.getId(), ds);
// Get the data points
List<DataPointBean> allPoints = new ArrayList<>();
List<EventSourceBean> dataPoints = new ArrayList<>();
List<DataPointVO> dps = DataPointDao.instance.getDataPoints(DataPointExtendedNameComparator.instance, true);
final boolean admin = Permissions.hasAdmin(user);
for (DataPointVO dp : dps) {
if (!admin && !Permissions.hasDataSourcePermission(user, dslu.get(dp.getDataSourceId())))
continue;
allPoints.add(new DataPointBean(dp));
if (dp.getEventDetectors().size() > 0) {
EventSourceBean source = new EventSourceBean();
source.setId(dp.getId());
source.setName(dp.getExtendedName());
for (AbstractPointEventDetectorVO<?> ped : dp.getEventDetectors()) {
EventTypeVO dpet = ped.getEventType();
dpet.setHandlers(EventHandlerDao.instance.getEventHandlers(dpet));
source.getEventTypes().add(dpet);
}
dataPoints.add(source);
}
}
// Get the data sources
List<EventSourceBean> dataSources = new ArrayList<>();
for (DataSourceVO<?> ds : dss) {
if (!admin && !Permissions.hasDataSourcePermission(user, ds))
continue;
if (ds.getEventTypes().size() > 0) {
EventSourceBean source = new EventSourceBean();
source.setId(ds.getId());
source.setName(ds.getName());
for (EventTypeVO dset : ds.getEventTypes()) {
dset.setHandlers(EventHandlerDao.instance.getEventHandlers(dset));
source.getEventTypes().add(dset);
}
dataSources.add(source);
}
}
Map<String, Map<String, Object>> userEventTypes = new LinkedHashMap<>();
model.put("userEventTypes", userEventTypes);
for (EventTypeDefinition def : ModuleRegistry.getDefinitions(EventTypeDefinition.class)) {
if (!def.getHandlersRequireAdmin()) {
List<EventTypeVO> vos = def.getEventTypeVOs();
for (EventTypeVO vo : vos) vo.setHandlers(EventHandlerDao.instance.getEventHandlers(vo));
Map<String, Object> info = new HashMap<>();
info.put("vos", vos);
info.put("iconPath", def.getIconPath());
info.put("description", translate(def.getDescriptionKey()));
userEventTypes.put(def.getTypeName(), info);
}
}
if (admin) {
// Get the publishers
List<EventSourceBean> publishers = new ArrayList<>();
for (PublisherVO<? extends PublishedPointVO> p : PublisherDao.instance.getPublishers(new PublisherDao.PublisherNameComparator())) {
if (p.getEventTypes().size() > 0) {
EventSourceBean source = new EventSourceBean();
source.setId(p.getId());
source.setName(p.getName());
for (EventTypeVO pet : p.getEventTypes()) {
pet.setHandlers(EventHandlerDao.instance.getEventHandlers(pet));
source.getEventTypes().add(pet);
}
publishers.add(source);
}
}
model.put(SchemaDefinition.PUBLISHERS_TABLE, publishers);
// Get the system events
List<EventTypeVO> systemEvents = new ArrayList<>();
for (EventTypeVO sets : SystemEventType.EVENT_TYPES) {
sets.setHandlers(EventHandlerDao.instance.getEventHandlers(sets));
systemEvents.add(sets);
}
model.put("systemEvents", systemEvents);
// Get the audit events
List<EventTypeVO> auditEvents = new ArrayList<>();
for (EventTypeVO aets : AuditEventType.EVENT_TYPES) {
aets.setHandlers(EventHandlerDao.instance.getEventHandlers(aets));
auditEvents.add(aets);
}
model.put("auditEvents", auditEvents);
Map<String, Map<String, Object>> adminEventTypes = new LinkedHashMap<>();
model.put("adminEventTypes", adminEventTypes);
for (EventTypeDefinition def : ModuleRegistry.getDefinitions(EventTypeDefinition.class)) {
if (def.getHandlersRequireAdmin()) {
List<EventTypeVO> vos = def.getEventTypeVOs();
for (EventTypeVO vo : vos) vo.setHandlers(EventHandlerDao.instance.getEventHandlers(vo));
Map<String, Object> info = new HashMap<>();
info.put("vos", vos);
info.put("iconPath", def.getIconPath());
info.put("description", translate(def.getDescriptionKey()));
adminEventTypes.put(def.getTypeName(), info);
}
}
}
model.put("userNewScriptPermissions", new ScriptPermissions(user));
// Get the mailing lists.
model.put(SchemaDefinition.MAILING_LISTS_TABLE, MailingListDao.instance.getMailingLists());
// Get the users.
model.put(SchemaDefinition.USERS_TABLE, UserDao.instance.getUsers());
model.put("allPoints", allPoints);
model.put(SchemaDefinition.DATAPOINTS_TABLE, dataPoints);
model.put(SchemaDefinition.DATASOURCES_TABLE, dataSources);
return model;
}
use of com.serotonin.m2m2.vo.event.EventTypeVO in project ma-core-public by infiniteautomation.
the class PublisherVO method getEventTypes.
public List<EventTypeVO> getEventTypes() {
List<EventTypeVO> eventTypes = new ArrayList<>();
eventTypes.add(new EventTypeVO(EventType.EventTypeNames.PUBLISHER, null, getId(), PublisherRT.POINT_DISABLED_EVENT, new TranslatableMessage("event.pb.pointMissing"), getAlarmLevel(PublisherRT.POINT_DISABLED_EVENT, AlarmLevels.URGENT)));
eventTypes.add(new EventTypeVO(EventType.EventTypeNames.PUBLISHER, null, getId(), PublisherRT.QUEUE_SIZE_WARNING_EVENT, new TranslatableMessage("event.pb.queueSize"), getAlarmLevel(PublisherRT.QUEUE_SIZE_WARNING_EVENT, AlarmLevels.URGENT)));
getEventTypesImpl(eventTypes);
return eventTypes;
}
use of com.serotonin.m2m2.vo.event.EventTypeVO in project ma-core-public by infiniteautomation.
the class SystemEventType method returnToNormal.
public static void returnToNormal(SystemEventType type, long time) {
EventTypeVO vo = getEventType(type.getSystemEventType());
Common.eventManager.returnToNormal(type, time, vo.getAlarmLevel());
}
use of com.serotonin.m2m2.vo.event.EventTypeVO in project ma-core-public by infiniteautomation.
the class SystemEventType method raiseEvent.
public static void raiseEvent(SystemEventType type, long time, boolean rtn, TranslatableMessage message) {
EventTypeVO vo = getEventType(type.getSystemEventType());
if (vo == null) {
LOG.warn("Unkown event type null");
return;
}
int alarmLevel = vo.getAlarmLevel();
Common.eventManager.raiseEvent(type, time, rtn, alarmLevel, message, null);
}
use of com.serotonin.m2m2.vo.event.EventTypeVO in project ma-core-public by infiniteautomation.
the class SystemEventTypeSettingsListenerDefinition 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(SystemEventType.SYSTEM_SETTINGS_PREFIX);
EventTypeVO et = SystemEventType.getEventType(parts[1]);
et.setAlarmLevel(Integer.parseInt(newValue));
}
Aggregations