package com.bankaudit.model;

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

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * @author amit.patel
 *
 */
@Entity
@Table(name = "user")
@IdClass(UserId.class)
public class User implements Serializable {

/*	Table: user
	-------------------

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

	Field                   Type          Collation          Null    Key     Default            Extra   Privileges                       Comment  
	----------------------  ------------  -----------------  ------  ------  -----------------  ------  -------------------------------  ---------
	legal_entity_code       int(2)        (NULL)             NO      PRI     (NULL)                     select,insert,update,references           
	user_id                 varchar(20)   latin1_swedish_ci  NO      PRI     (NULL)                     select,insert,update,references           
	unit_code               varchar(20)   latin1_swedish_ci  NO              (NULL)                     select,insert,update,references           
	email_id                varchar(254)  latin1_swedish_ci  NO              (NULL)                     select,insert,update,references           
	password                varchar(200)  latin1_swedish_ci  NO              (NULL)                     select,insert,update,references           
	created_date            timestamp     (NULL)             NO              CURRENT_TIMESTAMP          select,insert,update,references           
	current_login           timestamp     (NULL)             YES             (NULL)                     select,insert,update,references           
	last_login              timestamp     (NULL)             YES             (NULL)                     select,insert,update,references           
	unsuccessful_attempts   int(2)        (NULL)             YES             (NULL)                     select,insert,update,references           
	gender                  varchar(1)    latin1_swedish_ci  NO              (NULL)                     select,insert,update,references           
	salutation              varchar(5)    latin1_swedish_ci  NO              (NULL)                     select,insert,update,references           
	first_name              varchar(50)   latin1_swedish_ci  NO              (NULL)                     select,insert,update,references           
	middle_name             varchar(50)   latin1_swedish_ci  YES             (NULL)                     select,insert,update,references           
	last_name               varchar(50)   latin1_swedish_ci  YES             (NULL)                     select,insert,update,references           
	short_name              varchar(50)   latin1_swedish_ci  YES             (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(50)   latin1_swedish_ci  YES             (NULL)                     select,insert,update,references           
	pincode                 int(6)        (NULL)             YES             (NULL)                     select,insert,update,references           
	district                varchar(20)   latin1_swedish_ci  YES             (NULL)                     select,insert,update,references           
	state                   varchar(20)   latin1_swedish_ci  YES             (NULL)                     select,insert,update,references           
	country                 varchar(3)    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           
	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  NO              (NULL)                     select,insert,update,references           
	maker                   varchar(20)   latin1_swedish_ci  NO              (NULL)                     select,insert,update,references           
	maker_timestamp         timestamp     (NULL)             NO              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             (NULL)                     select,insert,update,references           
*/
	
	@Id
	@Column(name="legal_entity_code")
	private Integer legalEntityCode;

	@Id
	@Column(name="user_id")
	private String userId;
	
	
	@Column(name="unit_code")
	private String unitCode;
	
	@Column(name="email_id")
	private String emailId;
	
	@Column(name="password")
	private String password;
	
	@Column(name="created_date")
	private Date createdDate;
	
	@Column(name="current_login")
	private Date currentLogin;
	
	@Column(name="last_login")
	private Date lastLogin;
	
	@Column(name="unsuccessful_attempts")
	private Integer unsuccessfulAttempts;
	
	@Column(name="type_of_user")
	private String typeOfUser;
	
	@Column(name="gender")
	private String gender;
	
	@Column(name="salutation")
	private String salutation;
	
	@Column(name="first_name")
	private String firstName;
	
	@Column(name="middle_name")
	private String middleName;
	
	@Column(name="last_name")
	private String lastName;
	
	@Column(name="short_name")
	private String shortName;
	
	@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="landline1")
	private String landline1;
	
	@Column(name="landline2")
	private String landline2;
	
	@Column(name="mobile1")
	private String mobile1;

	@Column(name="mobile2")
	private String mobile2;
	
	@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;
	
	@Column(name="grade")
	private String grade;
	
	@Column(name="designation")
	private String designation;
	
	@Column(name="department")
	private String department;
	

	private transient List<MaintEntityAuditSubgroupMapping> maintEntityAuditSubgroupMappings;
	
	private transient String userRoles;
	
	
	
	/*@ManyToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
    @JoinTable(name="user_role_mapping",
    
    joinColumns={
    
    		@JoinColumn(name="user_id"),
    		@JoinColumn(name="legal_entity_code")
    }
    ,
    inverseJoinColumns={
    		@JoinColumn(name="user_role_id"),
    		@JoinColumn(name="legal_entity_code")
    })  
	private Set<MaintUsergroupRoles> maintUsergroupRoles;*/
	
	/**
	 * @return the authRejRemarks
	 */
	public String getAuthRejRemarks() {
		return authRejRemarks;
	}

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

	public User() {
	}

	public User(User user) {
		super();
		this.legalEntityCode = user.legalEntityCode;
		this.userId = user.userId;
		this.unitCode = user.unitCode;
		this.emailId = user.emailId;
		this.password = user.password;
		this.createdDate = user.createdDate;
		this.currentLogin = user.currentLogin;
		this.lastLogin = user.lastLogin;
		this.unsuccessfulAttempts = user.unsuccessfulAttempts;
		this.gender = user.gender;
		this.salutation = user.salutation;
		this.firstName = user.firstName;
		this.middleName = user.middleName;
		this.lastName = user.lastName;
		this.shortName = user.shortName;
		this.address1 = user.address1;
		this.address2 = user.address2;
		this.address3 = user.address3;
		this.city = user.city;
		this.pincode = user.pincode;
		this.district = user.district;
		this.state = user.state;
		this.country = user.country;
		this.landline1 = user.landline1;
		this.landline2 = user.landline2;
		this.mobile1 = user.mobile1;
		this.mobile2 = user.mobile2;
		this.entityStatus = user.entityStatus;
		this.status = user.status;
		this.maker = user.maker;
		this.makerTimestamp = user.makerTimestamp;
		this.checker = user.checker;
		this.checkerTimestamp = user.checkerTimestamp;
		this.businessdateTimestamp = user.businessdateTimestamp;
		this.sysdateTimestamp = user.sysdateTimestamp;
		this.grade=user.grade;
		this.designation=user.designation;
		this.department=user.department;
		/*this.maintUsergroupRoles=user.maintUsergroupRoles;*/
	}


	public User(String userId,  String password) {
		super();
		
		this.userId = userId;
		this.password=password;
		
	}

	

/**
	 * @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 maintUsergroupRoles
	 *//*
	public Set<MaintUsergroupRoles> getMaintUsergroupRoles() {
		return maintUsergroupRoles;
	}

	*//**
	 * @param maintUsergroupRoles the maintUsergroupRoles to set
	 *//*
	public void setMaintUsergroupRoles(Set<MaintUsergroupRoles> maintUsergroupRoles) {
		this.maintUsergroupRoles = maintUsergroupRoles;
	}
*/
	/**
	 * @return the legalEntityCode
	 */
	public Integer getLegalEntityCode() {
		return legalEntityCode;
	}

	


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



	/**
	 * @return the userId
	 */
	public String getUserId() {
		return userId;
	}



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



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



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



	/**
	 * @return the emailId
	 */
	public String getEmailId() {
		return emailId;
	}



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



	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}



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



	/**
	 * @return the createdDate
	 */
	public Date getCreatedDate() {
		return createdDate;
	}



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



	/**
	 * @return the currentLogin
	 */
	public Date getCurrentLogin() {
		return currentLogin;
	}



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



	/**
	 * @return the lastLogin
	 */
	public Date getLastLogin() {
		return lastLogin;
	}



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



	/**
	 * @return the unsuccessfulAttempts
	 */
	public Integer getUnsuccessfulAttempts() {
		return unsuccessfulAttempts;
	}



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

	public String getTypeOfUser() {
		return typeOfUser;
	}

	public void setTypeOfUser(String typeOfUser) {
		this.typeOfUser = typeOfUser;
	}

	/**
	 * @return the gender
	 */
	public String getGender() {
		return gender;
	}



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



	/**
	 * @return the salutation
	 */
	public String getSalutation() {
		return salutation;
	}



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



	/**
	 * @return the firstName
	 */
	public String getFirstName() {
		return firstName;
	}



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



	/**
	 * @return the middleName
	 */
	public String getMiddleName() {
		return middleName;
	}



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



	/**
	 * @return the lastName
	 */
	public String getLastName() {
		return lastName;
	}



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



	/**
	 * @return the shortName
	 */
	public String getShortName() {
		return shortName;
	}



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



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



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



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

	public String getUserRoles() {
		return userRoles;
	}

	public void setUserRoles(String userRoles) {
		this.userRoles = userRoles;
	}

	public String getGrade() {
		return grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

	public String getDesignation() {
		return designation;
	}

	public void setDesignation(String designation) {
		this.designation = designation;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	@Override
	public String toString() { 
		return "User [legalEntityCode=" + legalEntityCode + ", userId=" + userId + ", unitCode=" + unitCode
				+ ", emailId=" + emailId + ", password=" + password + ", createdDate=" + createdDate + ", currentLogin="
				+ currentLogin + ", lastLogin=" + lastLogin + ", unsuccessfulAttempts=" + unsuccessfulAttempts
				+ ", gender=" + gender + ", salutation=" + salutation + ", firstName=" + firstName + ", middleName="
				+ middleName + ", lastName=" + lastName + ", shortName=" + shortName + ", address1=" + address1
				+ ", address2=" + address2 + ", address3=" + address3 + ", city=" + city + ", pincode=" + pincode
				+ ", district=" + district + ", state=" + state + ", country=" + country + ", landline1=" + landline1
				+ ", landline2=" + landline2 + ", mobile1=" + mobile1 + ", mobile2=" + mobile2 + ", authRejRemarks="
				+ authRejRemarks + ", entityStatus=" + entityStatus + ", status=" + status + ", maker=" + maker
				+ ", makerTimestamp=" + makerTimestamp + ", checker=" + checker + ", checkerTimestamp="
				+ checkerTimestamp + ", businessdateTimestamp=" + businessdateTimestamp + ", sysdateTimestamp="
				+ sysdateTimestamp + "]";
	}


	





	
}
