Search in sources :

Example 26 with AlarmLevels

use of com.serotonin.m2m2.rt.event.AlarmLevels in project ma-core-public by infiniteautomation.

the class EventInstanceService method getUnacknowledgedSummary.

/**
 */
public List<UserEventLevelSummary> getUnacknowledgedSummary() {
    PermissionHolder user = Common.getUser();
    this.permissionService.ensurePermission(user, eventsViewPermission.getPermission());
    Map<AlarmLevels, UserEventLevelSummary> summaries = new EnumMap<>(AlarmLevels.class);
    for (AlarmLevels level : AlarmLevels.values()) {
        if (level == AlarmLevels.IGNORE) {
            continue;
        }
        int count = dao.countUnacknowledgedAlarms(level, user);
        EventInstanceVO latest = dao.getLatestUnacknowledgedAlarm(level, user);
        summaries.put(level, new UserEventLevelSummary(level, count, latest));
    }
    return new ArrayList<>(summaries.values());
}
Also used : EventInstanceVO(com.serotonin.m2m2.vo.event.EventInstanceVO) ArrayList(java.util.ArrayList) PermissionHolder(com.serotonin.m2m2.vo.permission.PermissionHolder) UserEventLevelSummary(com.serotonin.m2m2.rt.event.UserEventLevelSummary) EnumMap(java.util.EnumMap) AlarmLevels(com.serotonin.m2m2.rt.event.AlarmLevels)

Example 27 with AlarmLevels

use of com.serotonin.m2m2.rt.event.AlarmLevels in project ma-core-public by infiniteautomation.

the class AuditEventType method registerEventType.

private static void registerEventType(String subtype, String key) {
    TYPE_NAMES.addElement(subtype);
    AlarmLevels level = AlarmLevels.fromValue(SystemSettingsDao.getInstance().getIntValue(AUDIT_SETTINGS_PREFIX + subtype));
    EVENT_TYPES.put(subtype, new EventTypeVO(new AuditEventType(subtype, 0, 0), new TranslatableMessage(key), level));
}
Also used : EventTypeVO(com.serotonin.m2m2.vo.event.EventTypeVO) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) AlarmLevels(com.serotonin.m2m2.rt.event.AlarmLevels)

Example 28 with AlarmLevels

use of com.serotonin.m2m2.rt.event.AlarmLevels in project ma-core-public by infiniteautomation.

the class SystemEventType method registerEventType.

private static void registerEventType(String subtype, String key) {
    TYPE_NAMES.addElement(subtype);
    AlarmLevels level = AlarmLevels.fromValue(SystemSettingsDao.getInstance().getIntValue(SYSTEM_SETTINGS_PREFIX + subtype));
    EVENT_TYPES.put(subtype, new EventTypeVO(new SystemEventType(subtype, 0, null), new TranslatableMessage(key), level));
}
Also used : EventTypeVO(com.serotonin.m2m2.vo.event.EventTypeVO) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) AlarmLevels(com.serotonin.m2m2.rt.event.AlarmLevels)

Example 29 with AlarmLevels

use of com.serotonin.m2m2.rt.event.AlarmLevels in project ma-core-public by MangoAutomation.

the class DataSourceVO method jsonWrite.

@Override
public void jsonWrite(ObjectWriter writer) throws IOException, JsonException {
    super.jsonWrite(writer);
    // Write the type
    writer.writeEntry("type", this.definition.getDataSourceTypeName());
    ExportCodes eventCodes = getEventCodes();
    if (eventCodes != null && eventCodes.size() > 0) {
        Map<String, String> alarmCodeLevels = new HashMap<>();
        for (int i = 0; i < eventCodes.size(); i++) {
            int eventId = eventCodes.getId(i);
            AlarmLevels level = getAlarmLevel(eventId, AlarmLevels.URGENT);
            alarmCodeLevels.put(eventCodes.getCode(eventId), level.name());
        }
        writer.writeEntry("alarmLevels", alarmCodeLevels);
    }
    writer.writeEntry("purgeType", Common.TIME_PERIOD_CODES.getCode(purgeType));
}
Also used : ExportCodes(com.serotonin.m2m2.util.ExportCodes) HashMap(java.util.HashMap) AlarmLevels(com.serotonin.m2m2.rt.event.AlarmLevels)

Example 30 with AlarmLevels

use of com.serotonin.m2m2.rt.event.AlarmLevels in project ma-core-public by MangoAutomation.

the class DataSourceVO method setAlarmLevel.

/**
 * Set an alarm level based on the sub-type of the data source event type
 * which MUST (and already is) one of the codes in getEventCodes()
 */
public void setAlarmLevel(String subType, AlarmLevels level) throws ValidationException {
    ExportCodes codes = getEventCodes();
    int eventId = codes.getId(subType);
    if (eventId == -1) {
        ProcessResult result = new ProcessResult();
        result.addContextualMessage("alarmLevel", "emport.error.eventCode", subType, codes.getCodeList());
        throw new ValidationException(result);
    }
    alarmLevels.put(eventId, level);
}
Also used : ExportCodes(com.serotonin.m2m2.util.ExportCodes) ValidationException(com.infiniteautomation.mango.util.exception.ValidationException) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult)

Aggregations

AlarmLevels (com.serotonin.m2m2.rt.event.AlarmLevels)19 ExportCodes (com.serotonin.m2m2.util.ExportCodes)14 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)11 ArrayList (java.util.ArrayList)11 EventInstance (com.serotonin.m2m2.rt.event.EventInstance)9 PermissionHolder (com.serotonin.m2m2.vo.permission.PermissionHolder)8 UserEventLevelSummary (com.serotonin.m2m2.rt.event.UserEventLevelSummary)7 HashMap (java.util.HashMap)7 EventTypeVO (com.serotonin.m2m2.vo.event.EventTypeVO)6 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)5 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)5 User (com.serotonin.m2m2.vo.User)5 ValidationException (com.infiniteautomation.mango.util.exception.ValidationException)4 SystemEventType (com.serotonin.m2m2.rt.event.type.SystemEventType)4 EnumMap (java.util.EnumMap)4 Test (org.junit.Test)4 JsonObject (com.serotonin.json.type.JsonObject)3 UserEventListener (com.serotonin.m2m2.rt.event.UserEventListener)3 Collections (java.util.Collections)3 HashSet (java.util.HashSet)3