Search in sources :

Example 1 with DataSourceEventType

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

the class EventInstanceDao method createEventType.

static EventType createEventType(ResultSet rs, int offset) throws SQLException {
    String typeName = rs.getString(offset);
    String subtypeName = rs.getString(offset + 1);
    EventType type;
    if (typeName.equals(EventType.EventTypeNames.DATA_POINT))
        type = new DataPointEventType(rs.getInt(offset + 2), rs.getInt(offset + 3));
    else if (typeName.equals(EventType.EventTypeNames.DATA_SOURCE))
        type = new DataSourceEventType(rs.getInt(offset + 2), rs.getInt(offset + 3));
    else if (typeName.equals(EventType.EventTypeNames.SYSTEM))
        type = new SystemEventType(subtypeName, rs.getInt(offset + 2));
    else if (typeName.equals(EventType.EventTypeNames.PUBLISHER))
        type = new PublisherEventType(rs.getInt(offset + 2), rs.getInt(offset + 3));
    else if (typeName.equals(EventType.EventTypeNames.AUDIT))
        throw new ShouldNeverHappenException("AUDIT events should not exist here. Consider running the SQL: DELETE FROM events WHERE typeName='AUDIT';");
    else {
        EventTypeDefinition def = ModuleRegistry.getEventTypeDefinition(typeName);
        if (def == null) {
            // Create Missing Event Type
            type = new MissingEventType(typeName, null, rs.getInt(offset + 2), rs.getInt(offset + 3));
        } else {
            type = def.createEventType(subtypeName, rs.getInt(offset + 2), rs.getInt(offset + 3));
            if (type == null) {
                // Create Missing Event type
                type = new MissingEventType(typeName, subtypeName, rs.getInt(offset + 2), rs.getInt(offset + 3));
            }
        }
    }
    return type;
}
Also used : DataSourceEventType(com.serotonin.m2m2.rt.event.type.DataSourceEventType) SystemEventType(com.serotonin.m2m2.rt.event.type.SystemEventType) MissingEventType(com.serotonin.m2m2.rt.event.type.MissingEventType) DataSourceEventType(com.serotonin.m2m2.rt.event.type.DataSourceEventType) EventType(com.serotonin.m2m2.rt.event.type.EventType) SystemEventType(com.serotonin.m2m2.rt.event.type.SystemEventType) DataPointEventType(com.serotonin.m2m2.rt.event.type.DataPointEventType) PublisherEventType(com.serotonin.m2m2.rt.event.type.PublisherEventType) MissingEventType(com.serotonin.m2m2.rt.event.type.MissingEventType) PublisherEventType(com.serotonin.m2m2.rt.event.type.PublisherEventType) ShouldNeverHappenException(com.serotonin.ShouldNeverHappenException) DataPointEventType(com.serotonin.m2m2.rt.event.type.DataPointEventType) EventTypeDefinition(com.serotonin.m2m2.module.EventTypeDefinition)

Example 2 with DataSourceEventType

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

the class DataSourceRT method raiseEvent.

/**
 * @param eventId
 * @param time
 * @param rtn - Can this event return to normal
 * @param message
 */
protected void raiseEvent(int eventId, long time, boolean rtn, TranslatableMessage message) {
    message = new TranslatableMessage("event.ds", vo.getName(), message);
    DataSourceEventType type = getEventType(eventId);
    Map<String, Object> context = new HashMap<String, Object>();
    context.put("dataSource", vo);
    Common.eventManager.raiseEvent(type, time, rtn, type.getAlarmLevel(), message, context);
}
Also used : DataSourceEventType(com.serotonin.m2m2.rt.event.type.DataSourceEventType) HashMap(java.util.HashMap) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage)

Example 3 with DataSourceEventType

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

the class DataSourceRT method returnToNormal.

protected void returnToNormal(int eventId, long time) {
    DataSourceEventType type = getEventType(eventId);
    Common.eventManager.returnToNormal(type, time, type.getAlarmLevel());
}
Also used : DataSourceEventType(com.serotonin.m2m2.rt.event.type.DataSourceEventType)

Example 4 with DataSourceEventType

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

the class EventDao method createEventType.

/**
 * Get an event type from a result set
 *
 * eventTypeName = offset
 * eventSubtypeName = offset + 1
 * eventTypeRef1 = offset + 2
 * eventTypeRef2 = offset + 3
 *
 * @param rs
 * @param offset
 * @return
 * @throws SQLException
 */
public static EventType createEventType(ResultSet rs, int offset) throws SQLException {
    String typeName = rs.getString(offset);
    String subtypeName = rs.getString(offset + 1);
    EventType type;
    if (typeName.equals(EventType.EventTypeNames.DATA_POINT))
        type = new DataPointEventType(rs.getInt(offset + 2), rs.getInt(offset + 3));
    else if (typeName.equals(EventType.EventTypeNames.DATA_SOURCE))
        type = new DataSourceEventType(rs.getInt(offset + 2), rs.getInt(offset + 3));
    else if (typeName.equals(EventType.EventTypeNames.SYSTEM))
        type = new SystemEventType(subtypeName, rs.getInt(offset + 2));
    else if (typeName.equals(EventType.EventTypeNames.PUBLISHER))
        type = new PublisherEventType(rs.getInt(offset + 2), rs.getInt(offset + 3));
    else if (typeName.equals(EventType.EventTypeNames.AUDIT))
        // TODO allow tracking the various types of audit events...
        type = new AuditEventType(subtypeName, -1, rs.getInt(offset + 3));
    else {
        EventTypeDefinition def = ModuleRegistry.getEventTypeDefinition(typeName);
        if (def == null) {
            // Create Missing Event Type
            type = new MissingEventType(typeName, null, rs.getInt(offset + 2), rs.getInt(offset + 3));
        } else {
            type = def.createEventType(subtypeName, rs.getInt(offset + 2), rs.getInt(offset + 3));
            if (type == null) {
                // Create Missing Event type
                type = new MissingEventType(typeName, subtypeName, rs.getInt(offset + 2), rs.getInt(offset + 3));
            }
        }
    }
    return type;
}
Also used : DataSourceEventType(com.serotonin.m2m2.rt.event.type.DataSourceEventType) SystemEventType(com.serotonin.m2m2.rt.event.type.SystemEventType) AuditEventType(com.serotonin.m2m2.rt.event.type.AuditEventType) AuditEventType(com.serotonin.m2m2.rt.event.type.AuditEventType) MissingEventType(com.serotonin.m2m2.rt.event.type.MissingEventType) DataSourceEventType(com.serotonin.m2m2.rt.event.type.DataSourceEventType) EventType(com.serotonin.m2m2.rt.event.type.EventType) SystemEventType(com.serotonin.m2m2.rt.event.type.SystemEventType) DataPointEventType(com.serotonin.m2m2.rt.event.type.DataPointEventType) PublisherEventType(com.serotonin.m2m2.rt.event.type.PublisherEventType) MissingEventType(com.serotonin.m2m2.rt.event.type.MissingEventType) PublisherEventType(com.serotonin.m2m2.rt.event.type.PublisherEventType) DataPointEventType(com.serotonin.m2m2.rt.event.type.DataPointEventType) EventTypeDefinition(com.serotonin.m2m2.module.EventTypeDefinition)

Aggregations

DataSourceEventType (com.serotonin.m2m2.rt.event.type.DataSourceEventType)4 EventTypeDefinition (com.serotonin.m2m2.module.EventTypeDefinition)2 DataPointEventType (com.serotonin.m2m2.rt.event.type.DataPointEventType)2 EventType (com.serotonin.m2m2.rt.event.type.EventType)2 MissingEventType (com.serotonin.m2m2.rt.event.type.MissingEventType)2 PublisherEventType (com.serotonin.m2m2.rt.event.type.PublisherEventType)2 SystemEventType (com.serotonin.m2m2.rt.event.type.SystemEventType)2 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)1 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)1 AuditEventType (com.serotonin.m2m2.rt.event.type.AuditEventType)1 HashMap (java.util.HashMap)1