package cn.hmsoft.ltc.model;

import java.util.List;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import cn.hmsoft.ltc.model.QuestionType;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.Button;


/**
 * 课程实体类
 * @author yfz
 *
 */
public class Course {

	private IntegerProperty id;				//编号
	
	private StringProperty code;			//课程代码
	
	private StringProperty codeHubei;		//课程省编代码
	
	private StringProperty name;			//课程名称
	
	private DoubleProperty score;			//课程学分
	
	private IntegerProperty type;			//课程类型:0：省考 1：统考
	
	private IntegerProperty status;			//课程状态:0:停用 1启用
	
	private StringProperty statusName;			//课程状态:0:停用 1启用
	
	private IntegerProperty openEdit;		//是否开放编辑，如果为1，表示录入员可以强制修改此课程的所有试题
	
	private StringProperty remark;			//备注
	
	private IntegerProperty chapterNumber;   //课程总章节数
	
	private StringProperty updateDate;	//最后更新时间
	
	private List<QuestionType> quesTypeList;	//对应的题型列表
	
	private SkelCfg skelCfg;	//对应的细目表配置数据
	
	private StringProperty guid;
	
	private StringProperty strName; 
	
	private StringProperty teachBook;
	
	private StringProperty teachOutline;
	
	private StringProperty schoolName;
	
	private StringProperty batchNumber;  //批次号
	
	private transient Button operBtn = new Button(); //管理题型按钮
	
	private transient Button operUpdateBtn = new Button(); //修改章节按钮
	
	private StringProperty editor;    //【编者】
	
	private StringProperty edition;   //【版次】
	
	private StringProperty press;     //【出版社】字段
	
	private IntegerProperty verificationTextbook;  //【教材是否校验】 0:未校验，1：校验
	
	private StringProperty verificationTextbookName;  //【教材是否校验】 0:未校验，1：校验
	
	public Course() {
		this.id = new SimpleIntegerProperty();
		this.code = new SimpleStringProperty();
		this.codeHubei = new SimpleStringProperty();
		this.name = new SimpleStringProperty();
		this.score = new SimpleDoubleProperty();
		this.type = new SimpleIntegerProperty();
		this.status = new SimpleIntegerProperty();
		this.statusName = new SimpleStringProperty();
		this.openEdit = new SimpleIntegerProperty();
		this.remark = new SimpleStringProperty();
		this.chapterNumber = new SimpleIntegerProperty();
		this.updateDate = new SimpleStringProperty();	
		this.strName = new SimpleStringProperty();
		
		this.teachBook = new SimpleStringProperty();
		this.teachOutline = new SimpleStringProperty();
		this.schoolName =  new SimpleStringProperty();
		this.batchNumber = new SimpleStringProperty();
		
		this.editor = new SimpleStringProperty();
		this.edition = new SimpleStringProperty();
		this.press = new SimpleStringProperty();
		this.verificationTextbook  = new SimpleIntegerProperty();
		this.verificationTextbookName  = new SimpleStringProperty();
	}
	
	public Course(Integer id,String code,String codeHubei,String name,Double score,
			Integer type,Integer status,String statusName,Integer openEdit,String remark,
			Integer chapterNumber,String updateDate,String batchNumber,String editor,String edition,
			String press,Integer verificationTextbook,String verificationTextbookName) {
		this.id = new SimpleIntegerProperty(id);
		this.code = new SimpleStringProperty(code);
		this.codeHubei = new SimpleStringProperty(codeHubei);
		this.name = new SimpleStringProperty(name);
		this.score = new SimpleDoubleProperty(score);
		this.type = new SimpleIntegerProperty(type);
		this.status = new SimpleIntegerProperty(status);
		this.statusName = new SimpleStringProperty(statusName);
		this.openEdit = new SimpleIntegerProperty(openEdit);
		this.remark = new SimpleStringProperty(remark);
		this.chapterNumber = new SimpleIntegerProperty(chapterNumber);
		this.updateDate = new SimpleStringProperty(updateDate);		
		this.batchNumber = new SimpleStringProperty(batchNumber);
		
		this.editor = new SimpleStringProperty(editor);
		this.edition = new SimpleStringProperty(edition);
		this.press = new SimpleStringProperty(press);
		this.verificationTextbook = new SimpleIntegerProperty(verificationTextbook);
		this.verificationTextbookName = new SimpleStringProperty(verificationTextbookName);
	}

	public Integer getId() {
		return id.get();
	}

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

	public String getCode() {
		return code.get();
	}

	public void setCode(String code) {
		this.code.set(code);
	}

	public String getCodeHubei() {
		return codeHubei.get();
	}

	public void setCodeHubei(String codeHubei) {
		this.codeHubei.set(codeHubei);
	}

	public String getName() {
		return name.get();
	}

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

	public Double getScore() {
		return score.get();
	}

	public void setScore(Double score) {
		this.score.set(score);
	}

	public Integer getType() {
		return type.get();
	}

	public void setType(Integer type) {
		this.type.set(type);
	}

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

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

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

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

	public Integer getOpenEdit() {
		return openEdit.get();
	}

	public void setOpenEdit(Integer openEdit) {
		this.openEdit.set(openEdit);
	}

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

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

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

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

	public String getUpdateDate() {
		return updateDate.get();
	}

	public void setUpdateDate(String updateDate) {
		this.updateDate.set(updateDate);
	}

	public List<QuestionType> getQuesTypeList() {
		return quesTypeList;
	}

	public void setQuesTypeList(List<QuestionType> quesTypeList) {
		this.quesTypeList = quesTypeList;
	}

	public SkelCfg getSkelCfg() {
		return skelCfg;
	}

	public void setSkelCfg(SkelCfg skelCfg) {
		this.skelCfg = skelCfg;
	}

	public String getGuid() {
		return guid.get();
	}

	public void setGuid(String guid) {
		this.guid.set(guid);
	}

	public String getStrName() {
		return strName.get();
	}

	public void setStrName(String strName) {
		this.strName.set(strName);
	}

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

	public String getTeachBook() {
		return teachBook.get();
	}

	public String getTeachOutline() {
		return teachOutline.get();
	}

	public void setTeachBook(String teachBook) {
		this.teachBook.set(teachBook);
	}

	public void setTeachOutline(String teachOutline) {
		this.teachOutline.set(teachOutline);
	}

	public String getSchoolName() {
		return schoolName.get();
	}

	public void setSchoolName(String schoolName) {
		this.schoolName.set(schoolName);
	}
	
	public String getBatchNumber() {
		return batchNumber.get();
	}

	public void setBatchNumber(String batchNumber) {
		this.batchNumber.set(batchNumber);
	}

	public Button getOperBtn() {
		return operBtn;
	}

	public void setOperBtn(Button operBtn) {
		this.operBtn = operBtn;
	}
	
	public Button getOperUpdateBtn() {
		return operUpdateBtn;
	}

	public void setOperUpdateBtn(Button operUpdateBtn) {
		this.operUpdateBtn = operUpdateBtn;
	}
	
	public void setEditor(String editor) {
		this.editor.set(editor);
	}

	public String getEditor() {
		return editor.get();
	}
	
	public void setEdition(String edition) {
		this.edition.set(edition);
	}

	public String getEdition() {
		return edition.get();
	}
	
	public void setPress(String press) {
		this.press.set(press);
	}

	public String getPress() {
		return press.get();
	}
	
	public Integer getVerificationTextbook() {
		return verificationTextbook.get();
	}
	
	public void setVerificationTextbook(Integer verificationTextbook) {
		this.verificationTextbook.set(verificationTextbook);
	}

	public String getVerificationTextbookName() {
		return verificationTextbookName.get();
	}
	
	public void setVerificationTextbookName(String verificationTextbookName) {
		this.verificationTextbookName.set(verificationTextbookName);
	}

	
	
}
