package com.hmsoft.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

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.ComboBox;

/**
 * 
 * @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(最终征集学校ID)
	private StringProperty schoolName;//ָ命题办指定的学校名称(最终征集学校名称)
	private StringProperty affirmSchooleName;//ָ最终认定学校名称)
	
	private StringProperty schSelectIds;//选择该课程的学校IDs
	private StringProperty schSelectNames;//选择该课程的学校名称
	private StringProperty schSelectTime;//最后一个选择该课程的学校选择时间
	private IntegerProperty confirmStatus;//确认状态是在课程上面，同一个批次状态下每个学校都不一样可能，前面最终发布、征集中、已导入都是公用批次的状态
	//待指定学校列表
	private transient ComboBox<School> comboBox = new ComboBox<School>();
	//记录瞬间校选择该课程的多个学校
	private transient List<School> multiSelectList = new ArrayList<School>(10);
	private transient StringProperty confirmDesc;//学校确认反馈
	
	public CoursePlan() {
		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.schSelectTime = new SimpleStringProperty();
		this.confirmDesc = 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 getAffirmSchooleName() {
		return affirmSchooleName.get();
	}
	
	public void setAffirmSchooleName(String affirmSchooleName) {
		this.affirmSchooleName.set(affirmSchooleName);
	}
	

	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 getSchSelectTime() {
		return schSelectTime.get();
	}

	public void setSchSelectTime(String schSelectTime) {
		this.schSelectTime.set(schSelectTime);;
	}

	public ComboBox<School> getComboBox() {
		return comboBox;
	}

	public void setComboBox(ComboBox<School> comboBox) {
		this.comboBox = comboBox;
	}

	public List<School> getMultiSelectList() {
		return multiSelectList;
	}

	public void setMultiSelectList(List<School> multiSelectList) {
		this.multiSelectList = multiSelectList;
	}


	public String getConfirmDesc() {
		return confirmDesc.get();
	}

	public void setConfirmDesc(String confirmDesc) {
		this.confirmDesc.set(confirmDesc);
	}

	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(" | ")
				.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));
	}
}
