package com.bocloud.ims.entity.installation;

import com.alibaba.fastjson.JSONObject;
import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 物理装机任务实体类
 *
 * @author 007
 */
@Table("install_task")
public class InstallTask {

    /**
     * ID
     */
    @PK(value = PKStrategy.AUTO)
    private Long id;
    /**
     * 所属任务名称
     */
    @Column("task_name")
    private String taskName;

    /**
     * 使用镜像的ID
     */
    @Column("image_id")
    private Long imageId;

    /**
     * 装机节点的ID
     * <p>
     * [1,2]
     */
    @Column("nodes")
    private String nodes;

    /**
     * 启动任务用户的ID
     */
    @Column("user_id")
    private Long userId;

    /**
     * 任务状态
     */
    @Column("status")
    private String status;

    /**
     * 任务options
     */
    @Column("options")
    private String options;

    /**
     * 任务result
     */
    @Column("result")
    private String result;

    /**
     * 镜像的类型
     */
    @Column("os_type")
    private String osType;

    /**
     * 镜像的版本
     */
    @Column("os_version")
    private String osVersion;

    /**
     * 任务开始时间
     */
    @Column("gmt_start")
    @JsonSerialize(using = DateSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date gmtStart;

    /**
     * 任务结束时间
     */
    @Column("gmt_finish")
    @JsonSerialize(using = DateSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date gmtFinish;
    /**
     * 用户名、操作人
     */
    @IgnoreAll
    private String userName;

    /**
     * 所属任务名称--别名
     */
    @IgnoreAll
    private String name;

    /**
     * 该任务对应的物理机名称字符串
     */
    @IgnoreAll
    private String targetHostNames;

    /**
     * 镜像名称
     */
    @IgnoreAll
    private String imageName;

    public InstallTask() {
        super();
    }

    public InstallTask(Long imageId, Long userId, String status, Date gmtStart, String options, String nodes) {
        super();
        this.imageId = imageId;
        this.userId = userId;
        this.status = status;
        this.gmtStart = gmtStart;
        this.options = options;
        this.nodes = nodes;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the taskName
     */
    public String getTaskName() {
        return taskName;
    }

    /**
     * @param taskName the taskName to set
     */
    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    /**
     * @return the imageId
     */
    public Long getImageId() {
        return imageId;
    }

    /**
     * @param imageId the imageId to set
     */
    public void setImageId(Long imageId) {
        this.imageId = imageId;
    }

    /**
     * @return the nodes
     */
    public String getNodes() {
        return nodes;
    }

    /**
     * @param nodes the nodes to set
     */
    public void setNodes(String nodes) {
        this.nodes = nodes;
    }

    /**
     * @return the userId
     */
    public Long getUserId() {
        return userId;
    }

    /**
     * @param userId the userId to set
     */
    public void setUserId(Long userId) {
        this.userId = userId;
    }

    /**
     * @return the status
     */
    public String getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /**
     * @return the options
     */
    public String getOptions() {
        return options;
    }

    /**
     * @param options the options to set
     */
    public void setOptions(String options) {
        this.options = options;
    }

    /**
     * @return the result
     */
    public String getResult() {
        return result;
    }

    /**
     * @param result the result to set
     */
    public void setResult(String result) {
        this.result = result;
    }

    /**
     * @return the gmtStart
     */
    public Date getGmtStart() {
        return gmtStart;
    }

    /**
     * @param gmtStart the gmtStart to set
     */
    public void setGmtStart(Date gmtStart) {
        this.gmtStart = gmtStart;
    }

    /**
     * @return the gmtFinish
     */
    public Date getGmtFinish() {
        return gmtFinish;
    }

    /**
     * @param gmtFinish the gmtFinish to set
     */
    public void setGmtFinish(Date gmtFinish) {
        this.gmtFinish = gmtFinish;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTargetHostNames() {
        return targetHostNames;
    }

    public void setTargetHostNames(String targetHostNames) {
        this.targetHostNames = targetHostNames;
    }

    public String getImageName() {
        return imageName;
    }

    public void setImageName(String imageName) {
        this.imageName = imageName;
    }

    public String getOsType() {
        return osType;
    }

    public void setOsType(String osType) {
        this.osType = osType;
    }

    public String getOsVersion() {
        return osVersion;
    }

    public void setOsVersion(String osVersion) {
        this.osVersion = osVersion;
    }

    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
    }

}
