package com.pas.model;

import java.io.Serializable;
import java.math.BigDecimal;
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 deal database table.
 * 
 */
@Entity
@Table(name="deal")
public class Deal 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;

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

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

	@Column(name="type_vehicle", nullable=false, precision=1)
	private BigDecimal typeVehicle;

	//bi-directional many-to-one association to DealType
	@ManyToOne
	@JoinColumn(name="deal_type_id", nullable=false)
	private DealType dealType;

	//bi-directional many-to-one association to ParkingPlace
	@ManyToOne
	@JoinColumn(name="parking_place_id", nullable=false)
	private ParkingPlace parkingPlace;

	//bi-directional many-to-one association to DealTime
	@OneToMany(mappedBy="deal")
	private List<DealTime> dealTimes;

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

	public Deal() {
	}

	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 Date getDateRegistration() {
		return this.dateRegistration;
	}

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

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public BigDecimal getTypeVehicle() {
		return this.typeVehicle;
	}

	public void setTypeVehicle(BigDecimal typeVehicle) {
		this.typeVehicle = typeVehicle;
	}

	public DealType getDealType() {
		return this.dealType;
	}

	public void setDealType(DealType dealType) {
		this.dealType = dealType;
	}

	public ParkingPlace getParkingPlace() {
		return this.parkingPlace;
	}

	public void setParkingPlace(ParkingPlace parkingPlace) {
		this.parkingPlace = parkingPlace;
	}

	public List<DealTime> getDealTimes() {
		return this.dealTimes;
	}

	public void setDealTimes(List<DealTime> dealTimes) {
		this.dealTimes = dealTimes;
	}

	public DealTime addDealTime(DealTime dealTime) {
		getDealTimes().add(dealTime);
		dealTime.setDeal(this);

		return dealTime;
	}

	public DealTime removeDealTime(DealTime dealTime) {
		getDealTimes().remove(dealTime);
		dealTime.setDeal(null);

		return dealTime;
	}

	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.setDeal(this);

		return reserve;
	}

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

		return reserve;
	}

}