Search in sources :

Example 1 with SetPointEventHandlerVO

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

the class EventHandlersDwr method saveSetPointEventHandler.

@DwrPermission(user = true)
public ProcessResult saveSetPointEventHandler(String eventType, String eventSubtype, int eventTypeRef1, int eventTypeRef2, int handlerId, String xid, String alias, boolean disabled, int targetPointId, int activeAction, String activeValueToSet, int activePointId, String activeScript, int inactiveAction, String inactiveValueToSet, int inactivePointId, String inactiveScript, List<IntStringPair> additionalContext, ScriptPermissions scriptPermissions) {
    SetPointEventHandlerVO handler = new SetPointEventHandlerVO();
    handler.setDefinition(ModuleRegistry.getEventHandlerDefinition(SetPointEventHandlerDefinition.TYPE_NAME));
    handler.setTargetPointId(targetPointId);
    handler.setActiveAction(activeAction);
    handler.setActiveValueToSet(activeValueToSet);
    handler.setActivePointId(activePointId);
    handler.setActiveScript(activeScript);
    handler.setInactiveAction(inactiveAction);
    handler.setInactiveValueToSet(inactiveValueToSet);
    handler.setInactivePointId(inactivePointId);
    handler.setInactiveScript(inactiveScript);
    handler.setAdditionalContext(additionalContext);
    handler.setScriptPermissions(scriptPermissions);
    return save(eventType, eventSubtype, eventTypeRef1, eventTypeRef2, handler, handlerId, xid, alias, disabled);
}
Also used : SetPointEventHandlerVO(com.serotonin.m2m2.vo.event.SetPointEventHandlerVO) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 2 with SetPointEventHandlerVO

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

the class Upgrade12 method upgradeEventHandlers.

@SuppressWarnings("deprecation")
private int upgradeEventHandlers(OutputStream os) {
    int upgraded = 0;
    List<EventHandlerVO> handlers = this.ejt.query(EVENT_HANDLER_SELECT, new EventHandlerRowMapper());
    // Convert them and update the database with the new handlers
    for (EventHandlerVO vo : handlers) {
        switch(vo.getHandlerType()) {
            case EventHandlerVO.TYPE_EMAIL:
                EmailEventHandlerVO emailHandler = new EmailEventHandlerVO();
                emailHandler.setId(vo.getId());
                emailHandler.setXid(vo.getXid());
                emailHandler.setName(vo.getAlias());
                emailHandler.setDisabled(vo.isDisabled());
                emailHandler.setDefinition(ModuleRegistry.getEventHandlerDefinition(EmailEventHandlerDefinition.TYPE_NAME));
                emailHandler.setActiveRecipients(vo.getActiveRecipients());
                emailHandler.setSendEscalation(vo.isSendEscalation());
                emailHandler.setEscalationDelayType(vo.getEscalationDelayType());
                emailHandler.setEscalationDelay(vo.getEscalationDelay());
                emailHandler.setEscalationRecipients(vo.getEscalationRecipients());
                emailHandler.setSendInactive(vo.isSendInactive());
                emailHandler.setInactiveOverride(vo.isInactiveOverride());
                emailHandler.setInactiveRecipients(vo.getInactiveRecipients());
                emailHandler.setIncludeSystemInfo(vo.isIncludeSystemInfo());
                emailHandler.setIncludePointValueCount(vo.getIncludePointValueCount());
                emailHandler.setIncludeLogfile(vo.isIncludeLogfile());
                upgradeEventHandler(emailHandler);
                upgraded++;
                break;
            case EventHandlerVO.TYPE_PROCESS:
                ProcessEventHandlerVO processHandler = new ProcessEventHandlerVO();
                processHandler.setId(vo.getId());
                processHandler.setXid(vo.getXid());
                processHandler.setName(vo.getAlias());
                processHandler.setDisabled(vo.isDisabled());
                processHandler.setDefinition(ModuleRegistry.getEventHandlerDefinition(ProcessEventHandlerDefinition.TYPE_NAME));
                processHandler.setActiveProcessCommand(vo.getActiveProcessCommand());
                processHandler.setActiveProcessTimeout(vo.getActiveProcessTimeout());
                processHandler.setInactiveProcessCommand(vo.getInactiveProcessCommand());
                processHandler.setInactiveProcessTimeout(vo.getInactiveProcessTimeout());
                upgradeEventHandler(processHandler);
                upgraded++;
                break;
            case EventHandlerVO.TYPE_SET_POINT:
                SetPointEventHandlerVO setPointHandler = new SetPointEventHandlerVO();
                setPointHandler.setId(vo.getId());
                setPointHandler.setXid(vo.getXid());
                setPointHandler.setName(vo.getAlias());
                setPointHandler.setDisabled(vo.isDisabled());
                setPointHandler.setDefinition(ModuleRegistry.getEventHandlerDefinition(SetPointEventHandlerDefinition.TYPE_NAME));
                setPointHandler.setTargetPointId(vo.getTargetPointId());
                setPointHandler.setActiveAction(vo.getActiveAction());
                setPointHandler.setActiveValueToSet(vo.getActiveValueToSet());
                setPointHandler.setActivePointId(vo.getActivePointId());
                setPointHandler.setInactiveAction(vo.getInactiveAction());
                setPointHandler.setInactiveValueToSet(vo.getInactiveValueToSet());
                setPointHandler.setInactivePointId(vo.getInactivePointId());
                upgradeEventHandler(setPointHandler);
                upgraded++;
                break;
            default:
                LOG.error("Unknown event detector type: " + vo.getHandlerType());
                try {
                    os.write(new String("Unknown event detector type: " + vo.getHandlerType()).getBytes(Common.UTF8_CS));
                } catch (IOException e2) {
                    LOG.error("Unable to write to upgrade log.", e2);
                }
                break;
        }
    }
    return upgraded;
}
Also used : ProcessEventHandlerVO(com.serotonin.m2m2.vo.event.ProcessEventHandlerVO) SetPointEventHandlerVO(com.serotonin.m2m2.vo.event.SetPointEventHandlerVO) SetPointEventHandlerVO(com.serotonin.m2m2.vo.event.SetPointEventHandlerVO) ProcessEventHandlerVO(com.serotonin.m2m2.vo.event.ProcessEventHandlerVO) EventHandlerVO(com.serotonin.m2m2.vo.event.EventHandlerVO) AbstractEventHandlerVO(com.serotonin.m2m2.vo.event.AbstractEventHandlerVO) EmailEventHandlerVO(com.serotonin.m2m2.vo.event.EmailEventHandlerVO) EmailEventHandlerVO(com.serotonin.m2m2.vo.event.EmailEventHandlerVO) IOException(java.io.IOException)

Aggregations

SetPointEventHandlerVO (com.serotonin.m2m2.vo.event.SetPointEventHandlerVO)2 AbstractEventHandlerVO (com.serotonin.m2m2.vo.event.AbstractEventHandlerVO)1 EmailEventHandlerVO (com.serotonin.m2m2.vo.event.EmailEventHandlerVO)1 EventHandlerVO (com.serotonin.m2m2.vo.event.EventHandlerVO)1 ProcessEventHandlerVO (com.serotonin.m2m2.vo.event.ProcessEventHandlerVO)1 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)1 IOException (java.io.IOException)1