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.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonManagedReference;

@Entity
@Table(name = "maint_entity")
public class MaintEntity implements Serializable, Comparable<MaintEntity> {

/*	Table: maint_entity
	-----------------------

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

	Field                     Type          Collation          Null    Key     Default  Extra   Privileges                       Comment  
	------------------------  ------------  -----------------  ------  ------  -------  ------  -------------------------------  ---------
	legal_entity_code         int(2)        (NULL)             NO      PRI     (NULL)           select,insert,update,references           
	level_code                varchar(20)   latin1_swedish_ci  NO              (NULL)           select,insert,update,references           
	parent_unit_code          varchar(20)   latin1_swedish_ci  NO              (NULL)           select,insert,update,references           
	unit_code                 varchar(20)   latin1_swedish_ci  NO      PRI     (NULL)           select,insert,update,references           
	unit_name                 varchar(50)   latin1_swedish_ci  NO              (NULL)           select,insert,update,references           
	address1                  varchar(50)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	address2                  varchar(50)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	address3                  varchar(50)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	city                      varchar(10)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	pincode                   int(6)        (NULL)             YES             (NULL)           select,insert,update,references           
	district                  varchar(10)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	state                     varchar(10)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	country                   varchar(3)    latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	contact_person            varchar(50)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	landline1                 varchar(13)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	landline2                 varchar(13)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	mobile1                   varchar(13)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	mobile2                   varchar(13)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	mailid                    varchar(254)  latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	u_criticality             varchar(20)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	unit_type                 varchar(50)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	classification			  varchar(20)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references
	weekly_holiday            varchar(25)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	fortnightly_holiday       varchar(25)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	unit_open_date            timestamp     (NULL)             YES             (NULL)           select,insert,update,references           
	unit_head_user            varchar(20)   latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	unit_head_inception_date  timestamp     (NULL)             YES             (NULL)           select,insert,update,references           
	auth_rej_remarks          varchar(200)  latin1_swedish_ci  YES             (NULL)           select,insert,update,references           
	status                    varchar(20)   latin1_swedish_ci  NO              (NULL)           select,insert,update,references           
	entity_status             varchar(20)   latin1_swedish_ci  NO              (NULL)           select,insert,update,references           
	maker                     varchar(20)   latin1_swedish_ci  NO              (NULL)           select,insert,update,references           
	maker_timestamp           timestamp     (NULL)             YES             (NULL)           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   */


	@Id
	@Column(name="legal_entity_code")
	private Integer legalEntityCode;
	
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name = "legal_entity_code",insertable=false,updatable=false)
	private MaintLegalEntity maintLegalEntity;
	
	
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumns({
        @JoinColumn(
            name = "legal_entity_code",
            referencedColumnName = "legal_entity_code",insertable=false,updatable=false),
        @JoinColumn(
            name = "level_code",
            referencedColumnName = "level_code",insertable=false,updatable=false)
    })
	private EntityLevelCodeDesc entityLevelCodeDesc;
	
	@Column(name = "level_code")
	private String levelCode;
	
	@Column(name = "parent_unit_code")
	private String parentUnitCode;
	
	@Id
	@Column(name = "unit_code")
    private String unitCode;
	
	@Column(name = "unit_name")
	private String unitName;

	
	@Column(name="address1")
	private String address1;

	@Column(name="address2")
	private String address2;

	@Column(name="address3")
	private String address3;
	
	@Column(name="city")
	private String city;
	
	@Column(name="pincode")
	private Integer pincode;

	@Column(name="district")
	private String district;

	@Column(name="state")
	private String state;

	@Column(name="country")
	private String country;

	@Column(name="contact_person")
	private String contactPerson;

	@Column(name="landline1")
	private String landline1;

	@Column(name="landline2")
	private String landline2;

	@Column(name="mobile1")
	private String mobile1;

	@Column(name="mobile2")
	private String mobile2;

	@Column(name="mailid")
	private String mailid;

	@Column(name="u_criticality")
	private String uCriticality;

	@Column(name="unit_type")
	private String unitType;
	
	@Column(name="classification")
	private String classification;
	
	@Column(name="type_of_entity")
	private String typeOfEntity;

	@Column(name="weekly_holiday")
	private String weeklyHoliday;
	
	@Column(name="fortnightly_holiday")
	private String fortnightlyHoliday;


	@Column(name="unit_open_date")
	private Date unitOpenDate;

	
	@Column(name="unit_head_user")
	private String unitHeadUser;

	
	@Column(name="unit_head_inception_date")
	private Date unitHeadInceptionDate;

	
	@Column(name="auth_rej_remarks")
	private String authRejRemarks;
	
	@Column(name = "status")
	private String status;

	@Column(name = "entity_status")
	private String entityStatus;

	
	@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;
	
	private transient List<MaintEntityAuditSubgroupMapping> maintEntityAuditSubgroupMappings;
	
	

	/**
	 * @return the maintEntityAuditSubgroupMappings
	 */
	public List<MaintEntityAuditSubgroupMapping> getMaintEntityAuditSubgroupMappings() {
		return maintEntityAuditSubgroupMappings;
	}

	/**
	 * @param maintEntityAuditSubgroupMappings the maintEntityAuditSubgroupMappings to set
	 */
	public void setMaintEntityAuditSubgroupMappings(
			List<MaintEntityAuditSubgroupMapping> maintEntityAuditSubgroupMappings) {
		this.maintEntityAuditSubgroupMappings = maintEntityAuditSubgroupMappings;
	}

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

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

	/**
	 * @return the maintLegalEntity
	 */
	public MaintLegalEntity getMaintLegalEntity() {
		return maintLegalEntity;
	}

	/**
	 * @param maintLegalEntity the maintLegalEntity to set
	 */
	public void setMaintLegalEntity(MaintLegalEntity maintLegalEntity) {
		this.maintLegalEntity = maintLegalEntity;
	}

	/**
	 * @return the entityLevelCodeDesc
	 */
	public EntityLevelCodeDesc getEntityLevelCodeDesc() {
		return entityLevelCodeDesc;
	}

	/**
	 * @param entityLevelCodeDesc the entityLevelCodeDesc to set
	 */
	public void setEntityLevelCodeDesc(EntityLevelCodeDesc entityLevelCodeDesc) {
		this.entityLevelCodeDesc = entityLevelCodeDesc;
	}

	/**
	 * @return the levelCode
	 */
	public String getLevelCode() {
		return levelCode;
	}

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

	/**
	 * @return the parentUnitCode
	 */
	public String getParentUnitCode() {
		return parentUnitCode;
	}

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

	/**
	 * @return the unitCode
	 */
	public String getUnitCode() {
		return unitCode;
	}

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

	/**
	 * @return the unitName
	 */
	public String getUnitName() {
		return unitName;
	}

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

	/**
	 * @return the address1
	 */
	public String getAddress1() {
		return address1;
	}

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

	/**
	 * @return the address2
	 */
	public String getAddress2() {
		return address2;
	}

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

	/**
	 * @return the address3
	 */
	public String getAddress3() {
		return address3;
	}

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

	/**
	 * @return the city
	 */
	public String getCity() {
		return city;
	}

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

	/**
	 * @return the pincode
	 */
	public Integer getPincode() {
		return pincode;
	}

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

	/**
	 * @return the district
	 */
	public String getDistrict() {
		return district;
	}

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

	/**
	 * @return the state
	 */
	public String getState() {
		return state;
	}

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

	/**
	 * @return the country
	 */
	public String getCountry() {
		return country;
	}

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

	/**
	 * @return the contactPerson
	 */
	public String getContactPerson() {
		return contactPerson;
	}

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

	/**
	 * @return the landline1
	 */
	public String getLandline1() {
		return landline1;
	}

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

	/**
	 * @return the landline2
	 */
	public String getLandline2() {
		return landline2;
	}

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

	/**
	 * @return the mobile1
	 */
	public String getMobile1() {
		return mobile1;
	}

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

	/**
	 * @return the mobile2
	 */
	public String getMobile2() {
		return mobile2;
	}

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

	/**
	 * @return the mailid
	 */
	public String getMailid() {
		return mailid;
	}

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

	/**
	 * @return the uCriticality
	 */
	public String getuCriticality() {
		return uCriticality;
	}

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

	/**
	 * @return the unitType
	 */
	public String getUnitType() {
		return unitType;
	}

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

	public String getClassification() {
		return classification;
	}

	public void setClassification(String classification) {
		this.classification = classification;
	}

	public String getTypeOfEntity() {
		return typeOfEntity;
	}

	public void setTypeOfEntity(String typeOfEntity) {
		this.typeOfEntity = typeOfEntity;
	}

	/**
	 * @return the weeklyHoliday
	 */
	public String getWeeklyHoliday() {
		return weeklyHoliday;
	}

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

	/**
	 * @return the fortnightlyHoliday
	 */
	public String getFortnightlyHoliday() {
		return fortnightlyHoliday;
	}

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

	/**
	 * @return the unitOpenDate
	 */
	public Date getUnitOpenDate() {
		return unitOpenDate;
	}

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

	/**
	 * @return the unitHeadUser
	 */
	public String getUnitHeadUser() {
		return unitHeadUser;
	}

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

	/**
	 * @return the unitHeadInceptionDate
	 */
	public Date getUnitHeadInceptionDate() {
		return unitHeadInceptionDate;
	}

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

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

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

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

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

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

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

	/**
	 * @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;
	}
	
	public int compareTo(MaintEntity other) {
		if(other!=null && other.levelCode!=null && levelCode!=null) {
			return levelCode.compareTo(other.levelCode);
		}else {
			return 0;
		}
    }
	
}
