package com.bankaudit.process.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.OneToMany;
import javax.persistence.Table;


import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

@Entity
@Table(name="audit_plan_hst")
public class AuditPlanHst {
	

	@Id
	@GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY)
	@Column(name="id")
	private Integer id;
	
	@Column(name="version_no")
	private Integer versionNo;
		
	@Column(name="legal_entity_code")
	private Integer legalEntityCode;
	
	@Column(name="audit_type_code")
	private String auditTypeCode;
	
	@Column(name="plan_id")
	private String planId;
	
	@Column(name="planner_unit_code")
	private String plannerUnitCode;
	
	@Column(name="plan_type",nullable=true)
	private String planType;
	
	@Column(name="plan_start_date")
	private Date planStartDate;
	
	@Column(name="plan_end_date")
	private Date planEndDate;
	
	@Column(name="status")
	private String status;
	
	@Column(name="maker")
	private String maker;
	
	@Column(name="maker_timestamp")
	private Date makerTimestamp;
	
	@Column(name="checker")
	private String checker;
	
	@Column(name="checker_timestamp")
	private Date checkerTimestamp;
	
	@Column(name="businessdate_timestamp")
	private Date businessdateTimestamp;
	
	@Column(name="sysdate_timestamp")
	private Date sysdateTimestamp;
	
	@Column(name = "auth_rej_remarks")
	private String authRejRemarks;
	
	
	@LazyCollection(LazyCollectionOption.FALSE)
	 @OneToMany()
	    @JoinColumns({  
	        @JoinColumn(name="plan_auto_id", referencedColumnName="id")
	    })
	private List<AuditScheduleHst> auditScheduleHsts;

	
	public AuditPlanHst() {
	}

	public AuditPlanHst(AuditPlan auditPlan) {
		super();
		this.legalEntityCode = auditPlan.getLegalEntityCode();
		this.authRejRemarks = auditPlan.getAuthRejRemarks();
		this.auditTypeCode = auditPlan.getAuditTypeCode();
		this.planId = auditPlan.getPlanId();
		this.planType = auditPlan.getPlanType();
		this.planStartDate = auditPlan.getPlanStartDate();
		this.planEndDate = auditPlan.getPlanEndDate();
		this.status = auditPlan.getStatus();
		this.maker = auditPlan.getMaker();
		this.makerTimestamp = auditPlan.getMakerTimestamp();
		this.checker = auditPlan.getChecker();
		this.checkerTimestamp = auditPlan.getCheckerTimestamp();
		this.businessdateTimestamp = auditPlan.getBusinessdateTimestamp();
		this.sysdateTimestamp = auditPlan.getSysdateTimestamp();
		
		if(auditPlan.getAuditSchedules()!=null){
			this.auditScheduleHsts = new ArrayList<AuditScheduleHst>();
			for (AuditSchedule auditSchedule : auditPlan.getAuditSchedules()) {
				this.auditScheduleHsts.add(new AuditScheduleHst(auditSchedule));
			}
		}
		
	}

	
	/**
	 * @param id
	 * @param version
	 * @param legalEntityCode
	 * @param auditTypeCode
	 * @param planId
	 * @param planStartDate
	 * @param planEndDate
	 * @param status
	 * @param maker
	 * @param makerTimestamp
	 * @param checker
	 * @param checkerTimestamp
	 * @param businessdateTimestamp
	 * @param sysdateTimestamp
	 */
	public AuditPlanHst(AuditPlanWrk auditPlanWrk) {
		super();
		this.legalEntityCode = auditPlanWrk.getLegalEntityCode();
		this.authRejRemarks = auditPlanWrk.getAuthRejRemarks();
		this.auditTypeCode = auditPlanWrk.getAuditTypeCode();
		this.planId = auditPlanWrk.getPlanId();
		this.planStartDate = auditPlanWrk.getPlanStartDate();
		this.planEndDate = auditPlanWrk.getPlanEndDate();
		this.status = auditPlanWrk.getStatus();
		this.planType=auditPlanWrk.getPlanType();		
		this.maker = auditPlanWrk.getMaker();
		this.makerTimestamp = auditPlanWrk.getMakerTimestamp();
		this.checker = auditPlanWrk.getChecker();
		this.checkerTimestamp = auditPlanWrk.getCheckerTimestamp();
		this.businessdateTimestamp = auditPlanWrk.getBusinessdateTimestamp();
		this.sysdateTimestamp = auditPlanWrk.getSysdateTimestamp();
		if(auditPlanWrk.getAuditScheduleWrks()!=null){
			this.auditScheduleHsts = new ArrayList<AuditScheduleHst>();
			for (AuditScheduleWrk auditScheduleWrk : auditPlanWrk.getAuditScheduleWrks()) {
				this.auditScheduleHsts.add(new AuditScheduleHst(auditScheduleWrk));
			}
		}
	}

	
	
	
	/**
	 * @return the authRejRemarks
	 */
	public String getAuthRejRemarks() {
		return authRejRemarks;
	}

	/**
	 * @param authRejRemarks the authRejRemarks to set
	 */
	public void setAuthRejRemarks(String authRejRemarks) {
		this.authRejRemarks = authRejRemarks;
	}

	/**
	 * @return the auditScheduleHsts
	 */
	public List<AuditScheduleHst> getAuditScheduleHsts() {
		return auditScheduleHsts;
	}

	/**
	 * @param auditScheduleHsts the auditScheduleHsts to set
	 */
	public void setAuditScheduleHsts(List<AuditScheduleHst> auditScheduleHsts) {
		this.auditScheduleHsts = auditScheduleHsts;
	}

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}



	/**
	 * @return the versionNo
	 */
	public Integer getVersionNo() {
		return versionNo;
	}

	/**
	 * @param versionNo the versionNo to set
	 */
	public void setVersionNo(Integer versionNo) {
		this.versionNo = versionNo;
	}

	/**
	 * @return the legalEntityCode
	 */
	public Integer getLegalEntityCode() {
		return legalEntityCode;
	}

	/**
	 * @param legalEntityCode the legalEntityCode to set
	 */
	public void setLegalEntityCode(Integer legalEntityCode) {
		this.legalEntityCode = legalEntityCode;
	}

	/**
	 * @return the auditTypeCode
	 */
	public String getAuditTypeCode() {
		return auditTypeCode;
	}

	/**
	 * @param auditTypeCode the auditTypeCode to set
	 */
	public void setAuditTypeCode(String auditTypeCode) {
		this.auditTypeCode = auditTypeCode;
	}

	/**
	 * @return the planId
	 */
	public String getPlanId() {
		return planId;
	}

	/**
	 * @param planId the planId to set
	 */
	public void setPlanId(String planId) {
		this.planId = planId;
	}

	public String getPlannerUnitCode() {
		return plannerUnitCode;
	}

	public void setPlannerUnitCode(String plannerUnitCode) {
		this.plannerUnitCode = plannerUnitCode;
	}

	public String getPlanType() {
		return planType;
	}

	public void setPlanType(String planType) {
		this.planType = planType;
	}

	/**
	 * @return the planStartDate
	 */
	public Date getPlanStartDate() {
		return planStartDate;
	}

	/**
	 * @param planStartDate the planStartDate to set
	 */
	public void setPlanStartDate(Date planStartDate) {
		this.planStartDate = planStartDate;
	}

	/**
	 * @return the planEndDate
	 */
	public Date getPlanEndDate() {
		return planEndDate;
	}

	/**
	 * @param planEndDate the planEndDate to set
	 */
	public void setPlanEndDate(Date planEndDate) {
		this.planEndDate = planEndDate;
	}

	/**
	 * @return the status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	/**
	 * @return the maker
	 */
	public String getMaker() {
		return maker;
	}

	/**
	 * @param maker the maker to set
	 */
	public void setMaker(String maker) {
		this.maker = maker;
	}

	/**
	 * @return the makerTimestamp
	 */
	public Date getMakerTimestamp() {
		return makerTimestamp;
	}

	/**
	 * @param makerTimestamp the makerTimestamp to set
	 */
	public void setMakerTimestamp(Date makerTimestamp) {
		this.makerTimestamp = makerTimestamp;
	}

	/**
	 * @return the checker
	 */
	public String getChecker() {
		return checker;
	}

	/**
	 * @param checker the checker to set
	 */
	public void setChecker(String checker) {
		this.checker = checker;
	}

	/**
	 * @return the checkerTimestamp
	 */
	public Date getCheckerTimestamp() {
		return checkerTimestamp;
	}

	/**
	 * @param checkerTimestamp the checkerTimestamp to set
	 */
	public void setCheckerTimestamp(Date checkerTimestamp) {
		this.checkerTimestamp = checkerTimestamp;
	}

	/**
	 * @return the businessdateTimestamp
	 */
	public Date getBusinessdateTimestamp() {
		return businessdateTimestamp;
	}

	/**
	 * @param businessdateTimestamp the businessdateTimestamp to set
	 */
	public void setBusinessdateTimestamp(Date businessdateTimestamp) {
		this.businessdateTimestamp = businessdateTimestamp;
	}

	/**
	 * @return the sysdateTimestamp
	 */
	public Date getSysdateTimestamp() {
		return sysdateTimestamp;
	}

	/**
	 * @param sysdateTimestamp the sysdateTimestamp to set
	 */
	public void setSysdateTimestamp(Date sysdateTimestamp) {
		this.sysdateTimestamp = sysdateTimestamp;
	}

	

}
