package com.hmsoft.model;

import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.LongProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.CheckBox;

/**
 * 
 * @author zq
 *
 */
public class CoursePlan implements Serializable {

	private static final long serialVersionUID = 5308384112992831269L;
	
	private IntegerProperty coursePlanId;
	private StringProperty courseCode;
	private StringProperty courseName;
	private StringProperty outlineName;//教材大纲
	private StringProperty bookName;//教材名称
	private StringProperty bianZhu;//编著
	private StringProperty press;//出版社
	private StringProperty publications;//版次
	private StringProperty cengci;//层次
	private LongProperty schoolId;//命题办指定的学校ID
	private StringProperty schoolName;//ָ命题办指定的学校名称
	private StringProperty schSelectIds;//选择该课程的学校IDs
	private StringProperty schSelectNames;//选择该课程的学校名称
	private IntegerProperty confirmStatus;//确认状态是在课程上面，同一个批次状态下每个学校都不一样可能，前面最终发布、征集中、已导入都是公用批次的状态
	private transient StringProperty zjStatusDesc;//征集状态(征集中，最终发布),学校端只显示,不传输
	private transient CheckBox chkBox = new CheckBox();
	
	public CoursePlan() {
		this.zjStatusDesc = new SimpleStringProperty();
		this.coursePlanId = new SimpleIntegerProperty();
		this.courseCode = new SimpleStringProperty();
		this.courseName = new SimpleStringProperty();
		this.outlineName = new SimpleStringProperty();
		this.bookName = new SimpleStringProperty();
		this.bianZhu = new SimpleStringProperty();
		this.press = new SimpleStringProperty();
		this.publications = new SimpleStringProperty();
		this.cengci = new SimpleStringProperty();
		this.schoolId = new SimpleLongProperty();
		this.schoolName = new SimpleStringProperty();
		this.schSelectIds = new SimpleStringProperty();
		this.schSelectNames = new SimpleStringProperty();
		this.confirmStatus = new SimpleIntegerProperty();
	}
	
	public Integer getCoursePlanId() {
		return coursePlanId.get();
	}
	public void setCoursePlanId(Integer coursePlanId) {
		this.coursePlanId.set(coursePlanId);
	}
	public String getCourseCode() {
		return courseCode.get();
	}
	public void setCourseCode(String courseCode) {
		this.courseCode.set(courseCode);
	}
	public String getCourseName() {
		return courseName.get();
	}
	public void setCourseName(String courseName) {
		this.courseName.set(courseName);
	}
	public String getOutlineName() {
		return outlineName.get();
	}
	public void setOutlineName(String outlineName) {
		this.outlineName.set(outlineName);
	}
	public String getBookName() {
		return bookName.get();
	}
	public void setBookName(String bookName) {
		this.bookName.set(bookName);
	}
	public String getBianZhu() {
		return bianZhu.get();
	}
	public void setBianZhu(String bianZhu) {
		this.bianZhu.set(bianZhu);
	}
	public String getPress() {
		return press.get();
	}
	public void setPress(String press) {
		this.press.set(press);
	}
	public String getPublications() {
		return publications.get();
	}
	public void setPublications(String publications) {
		this.publications.set(publications);
	}
	
	public String getCengci() {
		return cengci.get();
	}

	public void setCengci(String cengci) {
		this.cengci.set(cengci);
	}

	public Long getSchoolId() {
		return schoolId.get();
	}
	
	public void setSchoolId(Long schoolId) {
		this.schoolId.set(schoolId);
	}
	
	public String getSchoolName() {
		return schoolName.get();
	}
	
	public void setSchoolName(String schoolName) {
		this.schoolName.set(schoolName);
	}

	public String getSchSelectIds() {
		return schSelectIds.get();
	}
	public String getSchSelectNames() {
		return schSelectNames.get();
	}
	public void setSchSelectIds(String schSelectIds) {
		this.schSelectIds.set(schSelectIds);
	}
	public void setSchSelectNames(String schSelectNames) {
		this.schSelectNames.set(schSelectNames);
	}
	
	public String getZjStatusDesc() {
		return zjStatusDesc.get();
	}

	public void setZjStatusDesc(String zjStatusDesc) {
		this.zjStatusDesc.set(zjStatusDesc);;
	}
	public CheckBox getChkBox() {
		return chkBox;
	}
	public void setChkBox(CheckBox chkBox) {
		this.chkBox = chkBox;
	}

	public Integer getConfirmStatus() {
		return confirmStatus.get();
	}

	public void setConfirmStatus(Integer confirmStatus) {
		this.confirmStatus.set(confirmStatus);
	}

	
	public String toString() {
		return new StringBuilder()
				.append(coursePlanId.get()).append(" | ")
				.append(courseCode.get()).append(" | ")
				.append(courseName.get()).append(" | ")
				.append(outlineName.get()).append(" | ")
				.append(bookName.get()).append(" | ")
				.append(bianZhu.get()).append(" | ")
				.append(press.get()).append(" | ")
				.append(publications.get()).append(" | ")
				.append(cengci.get()).append(" | ")
				.toString();
	}
	
	public int hashCode() {
	     return new HashCodeBuilder(17, 37).
	       append(this.coursePlanId.get()).
	       append(this.courseCode.get()).
	       append(this.courseName.get()).
	       append(this.outlineName.get()).
	       append(this.bookName.get()).
	       append(this.bianZhu.get()).
	       append(this.press.get()).
	       append(this.publications.get()).
	       append(this.cengci.get()).
//	       append(this.schoolId.get()).
//	       append(this.schoolName.get()).
	       toHashCode();
	}
	
	public boolean equals(Object obj) {
		   if (obj == null) { return false; }
		   if (obj == this) { return true; }
		   if (obj.getClass() != getClass()) {
		     return false;
		   }
		   CoursePlan oth = (CoursePlan) obj;
		   return new EqualsBuilder()
		                 .append(this.coursePlanId.get(), oth.coursePlanId.get())
		                 .append(this.courseCode.get(), oth.courseCode.get())
		                 .append(this.courseName.get(), oth.courseName.get())
		                 .append(this.outlineName.get(), oth.outlineName.get())
		                 .append(this.bookName.get(), oth.bookName.get())
		                 .append(this.bianZhu.get(), oth.bianZhu.get())
		                 .append(this.press.get(), oth.press.get())
		                 .append(this.publications.get(), oth.publications.get())
		                 .append(this.cengci.get(), oth.cengci.get())
//		                 .append(this.schoolId.get(), oth.schoolId.get())
//		                 .append(this.schoolName.get(), oth.schoolName.get())
		                 .isEquals();
	}
	
	public static void main(String[] args) {
		CoursePlan plan = new CoursePlan();
		plan.setCoursePlanId(2);
		plan.setBianZhu("111");
		plan.setBookName("222");
		plan.setCourseCode("002778");
		plan.setCourseName("333");
		plan.setOutlineName("444");
		plan.setPress("555");
		plan.setPublications("66");
		plan.setSchoolId(13L);
		plan.setSchoolName("77");
		
		CoursePlan plan2 = new CoursePlan();
		plan2.setCoursePlanId(2);
		plan2.setBianZhu("222333");
		plan2.setBookName("4455");
		plan2.setCourseCode("002778");
		plan2.setCourseName("666777");
		plan2.setOutlineName("333444");
		plan2.setPress("ee33");
		plan2.setPublications("332");
		plan2.setSchoolId(12L);
		plan2.setSchoolName("23");
		
		System.err.println(plan.equals(plan2));
	}
}
