Search in sources :

Example 1 with EmailEventHandlerVO

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

the class EventHandlersDwr method saveEmailEventHandler.

@DwrPermission(user = true)
public ProcessResult saveEmailEventHandler(String eventType, String eventSubtype, int eventTypeRef1, int eventTypeRef2, int handlerId, String xid, String alias, boolean disabled, List<RecipientListEntryBean> activeRecipients, String customTemplate, boolean sendEscalation, boolean repeatEscalations, int escalationDelayType, int escalationDelay, List<RecipientListEntryBean> escalationRecipients, boolean sendInactive, boolean inactiveOverride, List<RecipientListEntryBean> inactiveRecipients, boolean includeSystemInfo, int includePointValueCount, boolean includeLogfile, List<IntStringPair> additionalContext, ScriptPermissions permissions, String script) {
    EmailEventHandlerVO handler = new EmailEventHandlerVO();
    handler.setDefinition(ModuleRegistry.getEventHandlerDefinition(EmailEventHandlerDefinition.TYPE_NAME));
    handler.setActiveRecipients(activeRecipients);
    handler.setCustomTemplate(customTemplate);
    handler.setSendEscalation(sendEscalation);
    handler.setRepeatEscalations(repeatEscalations);
    handler.setEscalationDelayType(escalationDelayType);
    handler.setEscalationDelay(escalationDelay);
    handler.setEscalationRecipients(escalationRecipients);
    handler.setSendInactive(sendInactive);
    handler.setInactiveOverride(inactiveOverride);
    handler.setInactiveRecipients(inactiveRecipients);
    handler.setIncludeSystemInfo(includeSystemInfo);
    handler.setIncludePointValueCount(includePointValueCount);
    handler.setIncludeLogfile(includeLogfile);
    handler.setAdditionalContext(additionalContext);
    handler.setScriptPermissions(permissions);
    handler.setScript(script);
    return save(eventType, eventSubtype, eventTypeRef1, eventTypeRef2, handler, handlerId, xid, alias, disabled);
}
Also used : EmailEventHandlerVO(com.serotonin.m2m2.vo.event.EmailEventHandlerVO) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 2 with EmailEventHandlerVO

use of com.serotonin.m2m2.vo.event.EmailEventHandlerVO 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

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