package com.bankaudit.model;

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

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

@Entity
@Table(name="risk_score_audit_grp")
public class RiskScoreAuditGrp implements Serializable  {

/*	Table: risk_score_audit_grp
	-------------------------------

	Column Information
	----------------------

	Field                   Type          Collation          Null    Key     Default            Extra                        Privileges                       Comment  
	----------------------  ------------  -----------------  ------  ------  -----------------  ---------------------------  -------------------------------  ---------
	legal_entity_code       int(2)        (NULL)             NO      PRI     (NULL)                                          select,insert,update,references           
	audit_type_code         varchar(20)   latin1_swedish_ci  NO      PRI     (NULL)                                          select,insert,update,references           
	audit_group_code        varchar(20)   latin1_swedish_ci  NO      PRI     (NULL)                                          select,insert,update,references           
	weightage               int(2)        (NULL)             NO              (NULL)                                          select,insert,update,references           
	auth_rej_remarks        varchar(200)  latin1_swedish_ci  YES             (NULL)                                          select,insert,update,references           
	entity_status           varchar(20)   latin1_swedish_ci  YES             (NULL)                                          select,insert,update,references           
	status                  varchar(20)   latin1_swedish_ci  YES             (NULL)                                          select,insert,update,references           
	maker                   varchar(20)   latin1_swedish_ci  NO              (NULL)                                          select,insert,update,references           
	maker_timestamp         timestamp     (NULL)             NO              CURRENT_TIMESTAMP  on update CURRENT_TIMESTAMP  select,insert,update,references           
	checker                 varchar(20)   latin1_swedish_ci  YES             (NULL)                                          select,insert,update,references           
	checker_timestamp       timestamp     (NULL)             YES             (NULL)                                          select,insert,update,references           
	businessdate_timestamp  timestamp     (NULL)             YES             (NULL)                                          select,insert,update,references           
	sysdate_timestamp       timestamp     (NULL)             YES   */
	
	@Id
	@Column(name="legal_entity_code")
	private Integer legalEntityCode;
	
	@Id
	@Column(name="audit_type_code")
	private String auditTypeCode;

	@Id
	@Column(name="audit_group_code")
	private String auditGroupCode;

	
	@Column(name="weightage")
	private Integer weightage;
	
	@Column(name="auth_rej_remarks")
	private String authRejRemarks;
	
	@Column(name="entity_status")
	private String entityStatus;
	
	@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;
	
	 @OneToMany(fetch=FetchType.EAGER)
	    @JoinColumns({ 
	        @JoinColumn(name = "legal_entity_code", referencedColumnName = "legal_entity_code"), 
	        @JoinColumn(name = "audit_type_code", referencedColumnName = "audit_type_code"), 
	        @JoinColumn(name = "audit_group_code", referencedColumnName = "audit_group_code")
	    })
	transient private List<RiskScoreAuditSubgrp> riskScoreAuditSubgrps;

	 
	 public RiskScoreAuditGrp() {
	}
	
		/**
		 * @param legalEntityCode
		 * @param auditTypeCode
		 * @param auditGroupCode
		 * @param weightage
		 * @param status
		 * @param maker
		 * @param makerTimestamp
		 * @param checker
		 * @param checkerTimestamp
		 * @param businessdateTimestamp
		 * @param sysdateTimestamp
		 * @param riskScoreAuditSubgrps
		 */
		public RiskScoreAuditGrp(Object[] obj) {
			super();

			if (obj[0] != null) {
				this.legalEntityCode = Integer.valueOf(obj[0].toString());
			}
			if (obj[1] != null) {
				this.auditTypeCode = (String) obj[1];
			}
			if (obj[2] != null) {
				this.auditGroupCode = (String) obj[2];
			}
			if (obj[3] != null) {
				this.weightage = Integer.valueOf(obj[3].toString());
			}
			if (obj[4] != null) {
				this.status = (String) obj[4];
			}
			if (obj[5] != null) {
				this.maker = (String) obj[5];
			}
			if (obj[6] != null) {
				this.makerTimestamp = (Date) obj[6];
			}
			if (obj[7] != null) {
				this.checker = (String) obj[7];
			}
			if (obj[8] != null) {
				this.checkerTimestamp = (Date) obj[8];
			}
			if (obj[9] != null) {
				this.businessdateTimestamp = (Date) obj[9];
			}
			if (obj[10] != null) {
				this.sysdateTimestamp = (Date) obj[10];
			}
			if (obj[13] != null) {
				this.entityStatus = obj[13].toString();
			}
		}
	
	/**
	 * @return the authRejRemarks
	 */
	public String getAuthRejRemarks() {
		return authRejRemarks;
	}



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



	/**
	 * @return the entityStatus
	 */
	public String getEntityStatus() {
		return entityStatus;
	}



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



	/**
	 * @return the riskScoreAuditSubgrps
	 */
	public List<RiskScoreAuditSubgrp> getRiskScoreAuditSubgrps() {
		return riskScoreAuditSubgrps;
	}

	/**
	 * @param riskScoreAuditSubgrps the riskScoreAuditSubgrps to set
	 */
	public void setRiskScoreAuditSubgrps(List<RiskScoreAuditSubgrp> riskScoreAuditSubgrps) {
		this.riskScoreAuditSubgrps = riskScoreAuditSubgrps;
	}

	/**
	 * @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 auditGroupCode
	 */
	public String getAuditGroupCode() {
		return auditGroupCode;
	}

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

	/**
	 * @return the weightage
	 */
	public Integer getWeightage() {
		return weightage;
	}

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

	/**
	 * @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;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((auditGroupCode == null) ? 0 : auditGroupCode.hashCode());
		result = prime * result + ((auditTypeCode == null) ? 0 : auditTypeCode.hashCode());
		result = prime * result + ((legalEntityCode == null) ? 0 : legalEntityCode.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof RiskScoreAuditGrp)) {
			return false;
		}
		RiskScoreAuditGrp other = (RiskScoreAuditGrp) obj;
		if (auditGroupCode == null) {
			if (other.auditGroupCode != null) {
				return false;
			}
		} else if (!auditGroupCode.equals(other.auditGroupCode)) {
			return false;
		}
		if (auditTypeCode == null) {
			if (other.auditTypeCode != null) {
				return false;
			}
		} else if (!auditTypeCode.equals(other.auditTypeCode)) {
			return false;
		}
		if (legalEntityCode == null) {
			if (other.legalEntityCode != null) {
				return false;
			}
		} else if (!legalEntityCode.equals(other.legalEntityCode)) {
			return false;
		}
		return true;
	}
	
	

}
