package com.pas.model;

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

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * The persistent class for the user_app database table.
 * 
 */
@Entity
@Table(name="user_app")
public class User implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name = "id")
	private Integer id;

	@Temporal(TemporalType.DATE)
	@Column(name="date_approval")
	private Date dateApproval;

	@Temporal(TemporalType.DATE)
	@Column(name="date_last_login")
	private Date dateLastLogin;

	@Temporal(TemporalType.DATE)
	@Column(name="date_registration", nullable=false)
	private Date dateRegistration;

	@Column(name = "email", unique = true, nullable=false, length=150)
	private String email;

	@Column(name = "lastname", nullable=false, length=150)
	private String lastname;

	@Column(name = "name", nullable=false, length=50)
	private String name;

	@Column(name = "password", nullable=false, length=50)
	private String password;

	@Column(name = "username", nullable=false, length=10)
	private String username;

	//bi-directional many-to-one association to AuthExternal
	@OneToMany(mappedBy="user")
	private List<AuthExternal> authExternals;

	//bi-directional many-to-one association to ParkingPlace
	@OneToMany(mappedBy="user")
	private List<ParkingPlace> parkingPlaces;

	//bi-directional many-to-one association to Reserve
	@OneToMany(mappedBy="user")
	private List<Reserve> reserves;

	//bi-directional many-to-one association to UserAppType
	@ManyToOne
	@JoinColumn(name="user_app_type", referencedColumnName="id", nullable=false)
	private UserType userType;

	public User() {
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Date getDateApproval() {
		return this.dateApproval;
	}

	public void setDateApproval(Date dateApproval) {
		this.dateApproval = dateApproval;
	}

	public Date getDateLastLogin() {
		return this.dateLastLogin;
	}

	public void setDateLastLogin(Date dateLastLogin) {
		this.dateLastLogin = dateLastLogin;
	}

	public Date getDateRegistration() {
		return this.dateRegistration;
	}

	public void setDateRegistration(Date dateRegistration) {
		this.dateRegistration = dateRegistration;
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getLastname() {
		return this.lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getName() {
		return this.name;
	}

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

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public List<AuthExternal> getAuthExternals() {
		return this.authExternals;
	}

	public void setAuthExternals(List<AuthExternal> authExternals) {
		this.authExternals = authExternals;
	}

	public AuthExternal addAuthExternal(AuthExternal authExternal) {
		getAuthExternals().add(authExternal);
		authExternal.setUser(this);

		return authExternal;
	}

	public AuthExternal removeAuthExternal(AuthExternal authExternal) {
		getAuthExternals().remove(authExternal);
		authExternal.setUser(null);

		return authExternal;
	}

	public List<ParkingPlace> getParkingPlaces() {
		return this.parkingPlaces;
	}

	public void setParkingPlaces(List<ParkingPlace> parkingPlaces) {
		this.parkingPlaces = parkingPlaces;
	}

	public ParkingPlace addParkingPlace(ParkingPlace parkingPlace) {
		getParkingPlaces().add(parkingPlace);
		parkingPlace.setUser(this);

		return parkingPlace;
	}

	public ParkingPlace removeParkingPlace(ParkingPlace parkingPlace) {
		getParkingPlaces().remove(parkingPlace);
		parkingPlace.setUser(null);

		return parkingPlace;
	}

	public List<Reserve> getReserves() {
		return this.reserves;
	}

	public void setReserves(List<Reserve> reserves) {
		this.reserves = reserves;
	}

	public Reserve addReserve(Reserve reserve) {
		getReserves().add(reserve);
		reserve.setUser(this);

		return reserve;
	}

	public Reserve removeReserve(Reserve reserve) {
		getReserves().remove(reserve);
		reserve.setUser(null);

		return reserve;
	}

	public UserType getUserType() {
		return this.userType;
	}

	public void setUserType(UserType userType) {
		this.userType = userType;
	}
}