package domain;

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

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import enumeration.Gender;

@Entity
public class Season implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Integer id;
	private String title;
	private Date startDate;
	private Date endDate;
	private Gender gender;
	private Competition competition;
	private List<Tour> tours;

	public Season() {
		super();
	}
   
	private Season(String title, Date startDate, Date endDate, Competition competition, Gender gender) {
		super();
		this.title = title;
		this.startDate = startDate;
		this.endDate = endDate;
		this.competition = competition;
		this.gender = gender;
	}
	
	public Season(String title, Date startDate, Date endDate, Competition competition, List<Tour> tours) {
		super();
		this.title = title;
		this.startDate = startDate;
		this.endDate = endDate;
		this.competition = competition;
		this.tours = tours;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}

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

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

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

	@ManyToOne(cascade=CascadeType.PERSIST)
	public Competition getCompetition() {
		return competition;
	}

	public void setCompetition(Competition competition) {
		this.competition = competition;
	}

	@OneToMany(mappedBy = "season", fetch = FetchType.EAGER)
	public List<Tour> getTours() {
		return tours;
	}

	public void setTours(List<Tour> tours) {
		this.tours = tours;
	}

	@Override
	public String toString() {
		return title;
	}

	public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

}
