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

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

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

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

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

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

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

	@Column(name="latitud")
	private double latitud;

	@Column(name="longitud")
	private double longitud;

	@Column(name="parking_place_geom")
	private String parkingPlaceGeom;
	
	@Column(name="zip_code", nullable=false, precision=5)
	private Integer zipCode;

	//bi-directional many-to-one association to Deal
	@OneToMany(mappedBy="parkingPlace")
	private List<Deal> deals;

	//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 ParkingPlaceImage
	@OneToMany(mappedBy="parkingPlace")
	private List<ParkingPlaceImage> parkingPlaceImages;

	public ParkingPlace() {
	}

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

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

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

	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getCountry() {
		return this.country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

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

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

	public double getLatitud() {
		return this.latitud;
	}

	public void setLatitud(double latitud) {
		this.latitud = latitud;
	}

	public double getLongitud() {
		return this.longitud;
	}

	public void setLongitud(double longitud) {
		this.longitud = longitud;
	}

	public String getParkingPlaceGeom() {
		return this.parkingPlaceGeom;
	}

	public void setParkingPlaceGeom(String parkingPlaceGeom) {
		this.parkingPlaceGeom = parkingPlaceGeom;
	}

	public Integer getZipCode() {
		return this.zipCode;
	}

	public void setZipCode(Integer zipCode) {
		this.zipCode = zipCode;
	}

	public List<Deal> getDeals() {
		return this.deals;
	}

	public void setDeals(List<Deal> deals) {
		this.deals = deals;
	}

	public Deal addDeal(Deal deal) {
		getDeals().add(deal);
		deal.setParkingPlace(this);

		return deal;
	}

	public Deal removeDeal(Deal deal) {
		getDeals().remove(deal);
		deal.setParkingPlace(null);

		return deal;
	}

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

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

	public List<ParkingPlaceImage> getParkingPlaceImages() {
		return this.parkingPlaceImages;
	}

	public void setParkingPlaceImages(List<ParkingPlaceImage> parkingPlaceImages) {
		this.parkingPlaceImages = parkingPlaceImages;
	}

	public ParkingPlaceImage addParkingPlaceImage(ParkingPlaceImage parkingPlaceImage) {
		getParkingPlaceImages().add(parkingPlaceImage);
		parkingPlaceImage.setParkingPlace(this);

		return parkingPlaceImage;
	}

	public ParkingPlaceImage removeParkingPlaceImage(ParkingPlaceImage parkingPlaceImage) {
		getParkingPlaceImages().remove(parkingPlaceImage);
		parkingPlaceImage.setParkingPlace(null);

		return parkingPlaceImage;
	}
}