package cn.com.qmth.stmms.ms.core.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 评卷工作
 * Created by zhengmin on 2016/9/21.
 */
@Entity
public class Work implements Serializable{


    private static final long serialVersionUID = -5020635029000695707L;

    @Id
    @GeneratedValue
    private Long id;

    private String name;

    /**
     * 当前工作
     */
    private boolean active;

    private Long organizationId;

    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = "workId")
    @OrderBy("code")
    private List<Level> levels = new ArrayList<>();

    @OneToMany(cascade = CascadeType.REMOVE)
    @JoinColumn(name = "workId")
    @Where(clause = "enable = true")
    private List<MarkSubject> subjects = new ArrayList<>();

    @Temporal(value = TemporalType.DATE)
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createdOn;

    //是否可以修改档位信息中除了阈值以外其它数据
    @Transient
    private Boolean modifyOtherVal;

    public Work(String name) {
        this.name = name;
        this.createdOn = new Date();
    }

    public Work() {
        this.createdOn = new Date();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

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

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }


    public List<Level> getLevels() {
        return levels;
    }

    public void setLevels(List<Level> levels) {
        this.levels = levels;
    }

    public List<MarkSubject> getSubjects() {
        return subjects;
    }

    public void setSubjects(List<MarkSubject> subjects) {
        this.subjects = subjects;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public Long getOrganizationId() {
        return organizationId;
    }

    public void setOrganizationId(Long organizationId) {
        this.organizationId = organizationId;
    }

    public Boolean getModifyOtherVal() {
        return modifyOtherVal;
    }

    public void setModifyOtherVal(Boolean modifyOtherVal) {
        this.modifyOtherVal = modifyOtherVal;
    }
}
