package cn.axzo.workflow.core.engine.event;

import cn.axzo.workflow.common.model.request.bpmn.BpmnNoticeConf;
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;

import static cn.axzo.workflow.core.engine.event.MessagePushEventType.NOTICE;
import static cn.axzo.workflow.core.engine.event.MessagePushEventType.PENDING;
import static cn.axzo.workflow.core.engine.event.MessagePushEventType.SMS;

/**
 * 推送事件对象构造器
 *
 * @author wangli
 * @since 2023/11/22 14:16
 */
public class MessagePushEventBuilder {

    public static MessagePushEventImpl createEvent(MessagePushEventType type, BpmnTaskDelegateAssigner assigner,
                                            BpmnNoticeConf noticeConf) {
        switch (type) {
            case NOTICE:
                return createNoticeEvent(assigner, noticeConf);
            case PENDING:
                return createPendingEvent(assigner, noticeConf);
            case SMS:
                return createSmsEvent(assigner, noticeConf);
            default:
                throw new WorkflowEngineException("构造消息推送事件对象异常");
        }
    }

    public static MessagePushEventImpl createNoticeEvent(BpmnTaskDelegateAssigner assigner, BpmnNoticeConf noticeConf) {
        MessagePushEventImpl newEvent = new MessagePushEventImpl(NOTICE, assigner, noticeConf);
        return newEvent;
    }

    public static MessagePushEventImpl createPendingEvent(BpmnTaskDelegateAssigner assigner,
                                                          BpmnNoticeConf noticeConf) {
        MessagePushEventImpl newEvent = new MessagePushEventImpl(PENDING, assigner, noticeConf);
        return newEvent;
    }

    public static MessagePushEventImpl createSmsEvent(BpmnTaskDelegateAssigner assigner, BpmnNoticeConf noticeConf) {
        MessagePushEventImpl newEvent = new MessagePushEventImpl(SMS, assigner, noticeConf);
        return newEvent;
    }
}
