package com.xxl.job.admin.core.model;

import java.util.Date;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.alibaba.fastjson.JSONObject;
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
import com.xxl.job.admin.core.scheduler.MisfireStrategyEnum;
import com.xxl.job.core.constant.CommonConstant;
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
import com.xxl.job.core.glue.GlueTypeEnum;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * xxl-job info
 *
 * @author xuxueli  2016-1-12 18:25:49
 */
@Getter
@Setter
@ToString
public class XxlJobInfoValid {
	
	private Integer id;				// 主键ID
	
	@NotNull(message = "执行器ID，不可为空")
	private Integer jobGroup;		// 执行器主键ID
	
	@NotBlank(message = "任务描述，不可为空")
	private String jobDesc;
	
	@NotBlank(message = "负责人，不可为空")
	private String author;		// 负责人
	
	private String alarmEmail;	// 报警邮件

	@NotBlank(message = "调度类型，不可为空")
	private String scheduleType;			// 调度类型
	
	@NotBlank(message = "调度配置，不可为空")
	private String scheduleConf;			// 调度配置，值含义取决于调度类型
	
	private String misfireStrategy = MisfireStrategyEnum.DO_NOTHING.name();			// 调度过期策略

	private String executorRouteStrategy = ExecutorRouteStrategyEnum.ROUND.name();	// 执行器路由策略
	private String executorHandler = CommonConstant.COMMON_TIME_RULE_JOB;		    // 执行器，任务Handler名称
	
	@NotNull(message = "任务参数，不可为空")
	private JSONObject executorParam;		    // 执行器，任务参数
	
	private String executorBlockStrategy = ExecutorBlockStrategyEnum.SERIAL_EXECUTION.name();	// 阻塞处理策略
	
	@Size(min = 0, message = "任务执行超时时间，不可小于0")
	private int executorTimeout = 0;     		// 任务执行超时时间，单位秒
	
	@Size(min = 0, message = "失败重试次数，不可小于0")
	private int executorFailRetryCount = 0;		// 失败重试次数
	
	private String glueType = GlueTypeEnum.BEAN.name();		// GLUE类型	#com.xxl.job.core.glue.GlueTypeEnum
	private String glueSource;		// GLUE源代码
	private String glueRemark;		// GLUE备注
	private Date glueUpdatetime;	// GLUE更新时间

	private String childJobId;		// 子任务ID，多个逗号分隔

	private String addressList;		//执行器地址
	
	/** 旧接口兼容字段 */
	private String jobCron;
	
	private String callBackUrl;

}
