package cn.hmsoft.ltc.model;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.Button;


/**
 * 试卷实体类  paper
 * @author yfz
 *
 */
public class TestPaper {

	private IntegerProperty id;				//编号
	
	private IntegerProperty userId;   //用户id
	
	private StringProperty paperNo;     //试卷编号
	
	private IntegerProperty courseId;//课程ID
	
	private StringProperty courseCode;			//课程代码
	
	private StringProperty courseName;			//课程名称
	
	private IntegerProperty chapterNumber;   //课程总章节数
	
	private IntegerProperty status;			//试卷状态:0:停用 1启用
	
	private StringProperty remark;			//备注
	
	private StringProperty keyChapters;//重点中间-逗号分隔
	
	//protected
	protected StringProperty statusName;			//课程状态:0:停用 1启用
	protected StringProperty paperName; //试卷名称
	
	protected transient Button subjectEditBtn = new Button();
	protected transient Button detailTableBtn = new Button();
	protected transient Button exportPaperBtn = new Button();
	protected transient Button estimatedDifficultyBtn = new Button(); //试卷预估难度统计
	protected transient Button expDtBtn = new Button();//导出细目表
	protected int quesTypeNum;//记录该试卷的 题型数
	
	public TestPaper() {
		this.id = new SimpleIntegerProperty();
		this.paperNo = new SimpleStringProperty();
		this.userId = new SimpleIntegerProperty();
		this.courseId = new SimpleIntegerProperty();
		this.courseCode = new SimpleStringProperty();
		this.courseName = new SimpleStringProperty();
		this.chapterNumber = new SimpleIntegerProperty();
		this.status = new SimpleIntegerProperty();
		this.remark = new SimpleStringProperty();
		this.statusName = new SimpleStringProperty();
		this.paperName = new SimpleStringProperty();
		this.keyChapters = new SimpleStringProperty();
	}
	
	public Integer getId() {
		return id.get();
	}

	public Integer getUserId() {
		return userId.get();
	}

	public String getPaperNo() {
		return paperNo.get();
	}

	public Integer getCourseId() {
		return courseId.get();
	}

	public String getCourseCode() {
		return courseCode.get();
	}

	public String getCourseName() {
		return courseName.get();
	}

	public Integer getStatus() {
		return status.get();
	}

	public String getStatusName() {
		return statusName.get();
	}

	public String getRemark() {
		return remark.get();
	}

	public void setId(Integer id) {
		this.id.set(id);
	}

	public void setUserId(Integer userId) {
		this.userId.set(userId);
	}

	public void setPaperNo(String paperNo) {
		this.paperNo.set(paperNo);
	}

	public void setCourseId(Integer courseId) {
		this.courseId.set(courseId);
	}

	public void setCourseCode(String courseCode) {
		this.courseCode.set(courseCode);
	}

	public void setCourseName(String courseName) {
		this.courseName.set(courseName);
	}

	public void setStatus(Integer status) {
		this.status.set(status);
	}

	public void setStatusName(String statusName) {
		this.statusName.set(statusName);
	}

	public void setRemark(String remark) {
		this.remark.set(remark);
	}

	public String getPaperName() {
		return paperName.get();
	}

	public void setPaperName(String paperName) {
		this.paperName.set(paperName);
	}

	public String toString() {
		return this.paperNo.get() == null ? paperNo.get() : (paperNo.get() +  " | " + this.courseName.get());
	}
	
	public int hashCode() {
	     return new HashCodeBuilder(17, 37).
	       append(this.id.get()).
	       append(this.paperNo.get()).
	       append(this.courseId.get()).
	       toHashCode();
	}
	
	public boolean equals(Object obj) {
		   if (obj == null) { return false; }
		   if (obj == this) { return true; }
		   if (obj.getClass() != getClass()) {
		     return false;
		   }
		   TestPaper oth = (TestPaper) obj;
		   return new EqualsBuilder()
				   		 .append(this.id.get(), oth.id.get())
		                 .append(this.paperNo.get(), oth.paperNo.get())
		                 .append(this.courseId.get(), oth.courseId.get())
		                 .isEquals();
	}

	public Button getSubjectEditBtn() {
		return subjectEditBtn;
	}

	public Button getDetailTableBtn() {
		return detailTableBtn;
	}

	public void setSubjectEditBtn(Button subjectEditBtn) {
		this.subjectEditBtn = subjectEditBtn;
	}

	public void setDetailTableBtn(Button detailTableBtn) {
		this.detailTableBtn = detailTableBtn;
	}

	public Integer getChapterNumber() {
		return chapterNumber.get();
	}

	public void setChapterNumber(Integer chapterNumber) {
		this.chapterNumber.set(chapterNumber);
	}

	public int getQuesTypeNum() {
		return quesTypeNum;
	}

	public void setQuesTypeNum(int quesTypeNum) {
		this.quesTypeNum = quesTypeNum;
	}

	public Button getExportPaperBtn() {
		return exportPaperBtn;
	}

	public void setExportPaperBtn(Button exportPaperBtn) {
		this.exportPaperBtn = exportPaperBtn;
	}
	public String getKeyChapters() {
		return keyChapters.get();
	}

	public void setKeyChapters(String keyChapters) {
		this.keyChapters.set(keyChapters);
	}

	public Button getExpDtBtn() {
		return expDtBtn;
	}

	public void setExpDtBtn(Button expDtBtn) {
		this.expDtBtn = expDtBtn;
	}
	
	public Button getEstimatedDifficultyBtn() {
		return estimatedDifficultyBtn;
	}

	public void setEstimatedDifficultyBtn(Button estimatedDifficultyBtn) {
		this.estimatedDifficultyBtn = estimatedDifficultyBtn;
	}
	
}
