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 reserve database table.
 * 
 */
@Entity
@Table(name="reserve")
public class Reserve implements Serializable {
	private static final long serialVersionUID = 1L;

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

	@Temporal(TemporalType.DATE)
	@Column(name="cancellation_date")
	private Date cancellationDate;

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

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

	//bi-directional many-to-one association to Deal
	@ManyToOne
	@JoinColumn(name="deal_id", nullable=false)
	private Deal deal;

	//bi-directional many-to-one association to UserApp
	@ManyToOne
	@JoinColumn(name="user_app_id", nullable=false)
	private User user;

	//bi-directional many-to-one association to ReserveTime
	@OneToMany(mappedBy="reserve")
	private List<ReserveTime> reserveTimes;

	public Reserve() {
	}

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

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

	public Date getCancellationDate() {
		return this.cancellationDate;
	}

	public void setCancellationDate(Date cancellationDate) {
		this.cancellationDate = cancellationDate;
	}

	public String getComment() {
		return this.comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

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

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

	public Deal getDeal() {
		return this.deal;
	}

	public void setDeal(Deal deal) {
		this.deal = deal;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<ReserveTime> getReserveTimes() {
		return this.reserveTimes;
	}

	public void setReserveTimes(List<ReserveTime> reserveTimes) {
		this.reserveTimes = reserveTimes;
	}

	public ReserveTime addReserveTime(ReserveTime reserveTime) {
		getReserveTimes().add(reserveTime);
		reserveTime.setReserve(this);

		return reserveTime;
	}

	public ReserveTime removeReserveTime(ReserveTime reserveTime) {
		getReserveTimes().remove(reserveTime);
		reserveTime.setReserve(null);

		return reserveTime;
	}

}