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 org.flowable.common.engine.api.FlowableIllegalArgumentException;
import org.flowable.common.engine.api.delegate.event.FlowableEventType;

import java.util.List;

/**
 * 消息推送事件对象实现
 *
 * @author wangli
 * @since 2023/11/22 14:02
 */
public class MessagePushEventImpl implements MessagePushEvent {

    private FlowableEventType type;
    private List<BpmnTaskDelegateAssigner> assigners;
    private BpmnNoticeConf noticeConfig;
    private String processInstanceId;
    private String tenantId;
    private String taskId;

    public MessagePushEventImpl(FlowableEventType type) {
        if (type == null) {
            throw new FlowableIllegalArgumentException("type is null");
        }
        this.type = type;
    }

    /**
     * 使用该对象时需遵守,如果是 task 级的,一定要传 taskId, 其他参数则都是必传
     * <p>
     * 该对象的消费场景会对 taskId 做条件判断
     *
     * @param type
     * @param assigner
     * @param noticeConfig
     * @param processInstanceId
     * @param tenantId
     * @param taskId
     */
    public MessagePushEventImpl(FlowableEventType type, List<BpmnTaskDelegateAssigner> assigners,
                                BpmnNoticeConf noticeConfig, String processInstanceId, String tenantId, String taskId) {
        this.type = type;
        this.assigners = assigners;
        this.noticeConfig = noticeConfig;
        this.processInstanceId = processInstanceId;
        this.tenantId = tenantId;
        this.taskId = taskId;
    }

    @Override
    public FlowableEventType getType() {
        return type;
    }

    public void setType(FlowableEventType type) {
        this.type = type;
    }

    @Override
    public List<BpmnTaskDelegateAssigner> getAssigners() {
        return assigners;
    }

    public void setAssigner(List<BpmnTaskDelegateAssigner> assigners) {
        this.assigners = assigners;
    }

    @Override
    public BpmnNoticeConf getNoticeConfig() {
        return noticeConfig;
    }

    public void setNoticeConfig(BpmnNoticeConf noticeConfig) {
        this.noticeConfig = noticeConfig;
    }

    @Override
    public String getProcessInstanceId() {
        return processInstanceId;
    }

    public void setProcessInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    @Override
    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    @Override
    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    @Override
    public String toString() {
        return getClass() + " - " + type;
    }

}
