package com.ssj.bean.kmt.kmt.domain;

import com.ssj.bean.common.framework.core.domain.BaseEntity;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

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


@Entity
@Table(name = "kmt_plan_template")
public class KmtPlanTemplate extends BaseEntity{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String teacherId;
	
	private String name;
	
	private Integer type;
	
	private String timeInterval;
	
	private Integer state;
	
	private Date createTime;
	
	private List<KmtPlanDetail>  planDetails;

	public String getTeacherId() {
		return teacherId;
	}

	public void setTeacherId(String teacherId) {
		this.teacherId = teacherId;
	}

	public String getName() {
		return name;
	}

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

	public Integer getType() {
		return type;
	}

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

	public String getTimeInterval() {
		return timeInterval;
	}

	public void setTimeInterval(String timeInterval) {
		this.timeInterval = timeInterval;
	}

	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@OneToMany(cascade = { CascadeType.REFRESH}, fetch=FetchType.EAGER)
	@JoinColumn(name="planTemplateId",updatable =false,insertable =false)
	@OrderColumn(name="num")
	@Fetch(FetchMode.SELECT)
	public List<KmtPlanDetail> getPlanDetails() {
		if(planDetails!=null){
		List<KmtPlanDetail> tmp=new ArrayList<KmtPlanDetail>();
			for (KmtPlanDetail kmtPlanDetail : planDetails) {
				if(kmtPlanDetail!=null){
					tmp.add(kmtPlanDetail);
				}
			}
			this.planDetails=tmp;
		}
		return planDetails;
	}

	public void setPlanDetails(List<KmtPlanDetail> planDetails) {
		this.planDetails = planDetails;
	}

	
}
