Search in sources :

Example 51 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class EventHandlersDwr method saveProcessEventHandler.

@DwrPermission(user = true)
public ProcessResult saveProcessEventHandler(String eventType, String eventSubtype, int eventTypeRef1, int eventTypeRef2, int handlerId, String xid, String alias, boolean disabled, String activeProcessCommand, int activeProcessTimeout, String inactiveProcessCommand, int inactiveProcessTimeout) {
    ProcessEventHandlerVO handler = new ProcessEventHandlerVO();
    handler.setDefinition(ModuleRegistry.getEventHandlerDefinition(ProcessEventHandlerDefinition.TYPE_NAME));
    handler.setActiveProcessCommand(activeProcessCommand);
    handler.setActiveProcessTimeout(activeProcessTimeout);
    handler.setInactiveProcessCommand(inactiveProcessCommand);
    handler.setInactiveProcessTimeout(inactiveProcessTimeout);
    return save(eventType, eventSubtype, eventTypeRef1, eventTypeRef2, handler, handlerId, xid, alias, disabled);
}
Also used : ProcessEventHandlerVO(com.serotonin.m2m2.vo.event.ProcessEventHandlerVO) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 52 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class EventInstanceDwr method silenceEvents.

/**
 * Silence all events from the current User Event Query
 * @return
 */
@DwrPermission(user = true)
public ProcessResult silenceEvents() {
    ProcessResult response = new ProcessResult();
    final User user = Common.getHttpUser();
    if (user != null) {
        final EventDao eventDao = EventDao.instance;
        final ResultSetCounter counter = new ResultSetCounter();
        QueryDefinition queryData = (QueryDefinition) user.getAttribute("eventInstanceExportDefinition");
        DojoQueryCallback<EventInstanceVO> callback = new DojoQueryCallback<EventInstanceVO>(false) {

            @Override
            public void row(EventInstanceVO vo, int rowIndex) {
                if (!vo.isSilenced()) {
                    // If not silenced then do it.
                    eventDao.toggleSilence(vo.getId(), user.getId());
                    counter.increment();
                }
            }
        };
        EventInstanceDao.instance.exportQuery(queryData.getQuery(), queryData.getSort(), null, null, queryData.isOr(), callback);
        resetLastAlarmLevelChange();
        response.addGenericMessage("events.silencedEvents", counter.getCount());
    } else {
        response.addGenericMessage("events.silencedEvents", 0);
    }
    return response;
}
Also used : User(com.serotonin.m2m2.vo.User) EventInstanceVO(com.serotonin.m2m2.vo.event.EventInstanceVO) EventDao(com.serotonin.m2m2.db.dao.EventDao) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DojoQueryCallback(com.serotonin.m2m2.db.dao.DojoQueryCallback) ResultSetCounter(com.serotonin.m2m2.db.dao.ResultSetCounter) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 53 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class EventInstanceDwr method acknowledgeEvents.

/**
 * Acknowledge all events from the current User Event Query
 * @return
 */
@DwrPermission(user = true)
public ProcessResult acknowledgeEvents() {
    ProcessResult response = new ProcessResult();
    final User user = Common.getHttpUser();
    if (user != null) {
        final long now = Common.timer.currentTimeMillis();
        final ResultSetCounter counter = new ResultSetCounter();
        QueryDefinition queryData = (QueryDefinition) user.getAttribute("eventInstanceExportDefinition");
        DojoQueryCallback<EventInstanceVO> callback = new DojoQueryCallback<EventInstanceVO>(false) {

            @Override
            public void row(EventInstanceVO vo, int rowIndex) {
                if (!vo.isAcknowledged()) {
                    EventInstance event = Common.eventManager.acknowledgeEventById(vo.getId(), now, user, null);
                    if (event != null && event.isAcknowledged()) {
                        counter.increment();
                    }
                }
            }
        };
        EventInstanceDao.instance.exportQuery(queryData.getQuery(), queryData.getSort(), null, null, queryData.isOr(), callback);
        resetLastAlarmLevelChange();
        response.addGenericMessage("events.acknowledgedEvents", counter.getCount());
    } else {
        response.addGenericMessage("events.acknowledgedEvents", 0);
    }
    return response;
}
Also used : EventInstance(com.serotonin.m2m2.rt.event.EventInstance) User(com.serotonin.m2m2.vo.User) EventInstanceVO(com.serotonin.m2m2.vo.event.EventInstanceVO) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DojoQueryCallback(com.serotonin.m2m2.db.dao.DojoQueryCallback) ResultSetCounter(com.serotonin.m2m2.db.dao.ResultSetCounter) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 54 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class EventInstanceDwr method getEventTypeLink.

/**
 * @param divId - Id of div to place the link
 * @param type
 * @param subtype
 * @param ref1
 * @param ref2
 * @return
 */
@DwrPermission(user = true)
public static ProcessResult getEventTypeLink(String divId, String type, String subtype, int ref1, int ref2) {
    ProcessResult result = new ProcessResult();
    result.addData("divId", divId);
    EventTypeDefinition def = ModuleRegistry.getEventTypeDefinition(type);
    if (def != null)
        result.addData("link", def.getEventListLink(subtype, ref1, ref2, Common.getTranslations()));
    return result;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) SystemEventTypeDefinition(com.serotonin.m2m2.module.SystemEventTypeDefinition) AuditEventTypeDefinition(com.serotonin.m2m2.module.AuditEventTypeDefinition) EventTypeDefinition(com.serotonin.m2m2.module.EventTypeDefinition) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 55 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class EventInstanceDwr method getSystemEventTypeLink.

// Utility Methods for help with rendering some strings
/**
 * @param divId - Id of link to place div on return
 * @param subtype
 * @param ref1
 * @param ref2
 * @return
 */
@DwrPermission(user = true)
public static ProcessResult getSystemEventTypeLink(String divId, String subtype, int ref1, int ref2) {
    ProcessResult result = new ProcessResult();
    result.addData("divId", divId);
    SystemEventTypeDefinition def = ModuleRegistry.getSystemEventTypeDefinition(subtype);
    if (def != null)
        result.addData("link", def.getEventListLink(ref1, ref2, Common.getTranslations()));
    return result;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) SystemEventTypeDefinition(com.serotonin.m2m2.module.SystemEventTypeDefinition) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)165 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)132 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)31 User (com.serotonin.m2m2.vo.User)31 ArrayList (java.util.ArrayList)28 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)27 JsonException (com.serotonin.json.JsonException)21 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)20 JsonObject (com.serotonin.json.type.JsonObject)13 HashMap (java.util.HashMap)12 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)11 StringStringPair (com.serotonin.db.pair.StringStringPair)9 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)9 IOException (java.io.IOException)9 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)8 ProcessMessage (com.serotonin.m2m2.i18n.ProcessMessage)8 AbstractVO (com.serotonin.m2m2.vo.AbstractVO)8 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)8 SystemSettingsDao (com.serotonin.m2m2.db.dao.SystemSettingsDao)7 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)7