package info.bukova.isspst.data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;

@Entity
@Table(name = "TRIPREQUIREMENT")
@Indexed
public class TripRequirement extends RequirementBase {
	
	@Column(name = "TRIP_FROM")
	@Field(index = Index.YES, analyze = Analyze.YES)
	private String from;
	@Column(name = "TRIP_TO")
	@Field(index = Index.YES, analyze = Analyze.YES)
	private String to;
	@Column(name = "TRIP_DATE")
	private Date tripDate;
	@Column(name = "END")
	private String end;
	@Column(name = "END_DATE")
	private Date endDate;
	@ManyToMany
	@LazyCollection(LazyCollectionOption.TRUE)
	@JoinTable(name="TRIPREQUIREMENT_PASSANGER", joinColumns={@JoinColumn(name="TRIPREQUIREMENT_ID")}, inverseJoinColumns={@JoinColumn(name="USER_ID")})
	private List<User> passengers;
	@Embedded
	private Vehicle vehicle;
	@Column(name = "REQUIRE_DOWN_PAYMENT")
	private Boolean requireDownPayment;
	@Column(name = "DOWN_PAYMENT", precision = 15, scale = 4)
	private BigDecimal downPayment;
	@OneToMany
	@LazyCollection(LazyCollectionOption.TRUE)
	@IndexedEmbedded
	private List<FileMetainfo> attachedFiles;

	public TripRequirement() {
		this.setOwnedBy(new User());
		passengers = new ArrayList<User>();
	}
	
	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getTo() {
		return to;
	}

	public void setTo(String to) {
		this.to = to;
	}

	public Date getTripDate() {
		return tripDate;
	}

	public void setTripDate(Date tripDate) {
		this.tripDate = tripDate;
	}

	public String getEnd() {
		return end;
	}

	public void setEnd(String end) {
		this.end = end;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public List<User> getPassengers() {
		return passengers;
	}

	public void setPassengers(List<User> passengers) {
		this.passengers = passengers;
	}

	public Vehicle getVehicle() {
		return vehicle;
	}

	public void setVehicle(Vehicle vehicle) {
		this.vehicle = vehicle;
	}

	public Boolean getRequireDownPayment() {
		return requireDownPayment;
	}

	public void setRequireDownPayment(Boolean requireDownPayment) {
		this.requireDownPayment = requireDownPayment;
	}

	public BigDecimal getDownPayment() {
		return downPayment;
	}

	public void setDownPayment(BigDecimal downPayment) {
		this.downPayment = downPayment;
	}

	public List<FileMetainfo> getAttachedFiles() {
		return attachedFiles;
	}

	public void setAttachedFiles(List<FileMetainfo> attachedFiles) {
		this.attachedFiles = attachedFiles;
	}

}
