Search in sources :

Example 1 with CompoundEventDetectorVO

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

the class CompoundEventDetectorDao method updateCompoundEventDetector.

private void updateCompoundEventDetector(CompoundEventDetectorVO ced) {
    CompoundEventDetectorVO old = getCompoundEventDetector(ced.getId());
    ejt.update(COMPOUND_EVENT_DETECTOR_UPDATE, new Object[] { ced.getXid(), ced.getName(), ced.getAlarmLevel(), boolToChar(ced.isReturnToNormal()), boolToChar(ced.isDisabled()), ced.getCondition(), ced.getId() });
    AuditEventType.raiseChangedEvent(AuditEventType.TYPE_COMPOUND_EVENT_DETECTOR, old, ced);
}
Also used : CompoundEventDetectorVO(com.serotonin.m2m2.vo.event.CompoundEventDetectorVO)

Example 2 with CompoundEventDetectorVO

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

the class CompoundDetectorEventType method getCompoundEventDetectorId.

protected int getCompoundEventDetectorId(JsonObject json, String name) throws JsonException {
    String xid = json.getString(name);
    if (xid == null)
        throw new TranslatableJsonException("emport.error.eventType.missing.reference", name);
    CompoundEventDetectorVO ced = new CompoundEventDetectorDao().getCompoundEventDetector(xid);
    if (ced == null)
        throw new TranslatableJsonException("emport.error.eventType.invalid.reference", name, xid);
    return ced.getId();
}
Also used : CompoundEventDetectorDao(com.serotonin.m2m2.db.dao.CompoundEventDetectorDao) CompoundEventDetectorVO(com.serotonin.m2m2.vo.event.CompoundEventDetectorVO) TranslatableJsonException(com.serotonin.m2m2.i18n.TranslatableJsonException)

Example 3 with CompoundEventDetectorVO

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

the class CompoundEventDetectorDao method deleteCompoundEventDetector.

public void deleteCompoundEventDetector(final int compoundEventDetectorId) {
    final ExtendedJdbcTemplate ejt2 = ejt;
    CompoundEventDetectorVO ced = getCompoundEventDetector(compoundEventDetectorId);
    if (ced != null) {
        getTransactionTemplate().execute(new TransactionCallbackWithoutResult() {

            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                ejt2.update("delete from eventHandlers where eventTypeId=" + EventType.EventTypeNames.COMPOUND + " and eventTypeRef1=?", new Object[] { compoundEventDetectorId });
                ejt2.update("delete from compoundEventDetectors where id=?", new Object[] { compoundEventDetectorId });
            }
        });
        AuditEventType.raiseDeletedEvent(AuditEventType.TYPE_COMPOUND_EVENT_DETECTOR, ced);
    }
}
Also used : ExtendedJdbcTemplate(com.serotonin.db.spring.ExtendedJdbcTemplate) CompoundEventDetectorVO(com.serotonin.m2m2.vo.event.CompoundEventDetectorVO) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult)

Aggregations

CompoundEventDetectorVO (com.serotonin.m2m2.vo.event.CompoundEventDetectorVO)3 ExtendedJdbcTemplate (com.serotonin.db.spring.ExtendedJdbcTemplate)1 CompoundEventDetectorDao (com.serotonin.m2m2.db.dao.CompoundEventDetectorDao)1 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)1