package eu.dnetlib.openaire.db.objects;

import java.sql.Date;
import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Index;

@Entity(name = "projects")
@Table(name = "projects")
public class Project extends AbstractOpenaireObject {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5124327356779301705L;

	@Id
	@Column(name = "projectID")
	private String projectID;

	@Column(name="website")
	private String webSite;
	
	@Column(name="ec_project_website")
	private String ECProjectWebsite;
	
	@Column(name="call_identifier")
	private String callIdentifier;
	
	@Column(name="acronym")
	private String acronym;

	@Column(name="title")
	private String title;
	
	@Column(name="start_date")
	private Date startDate;

	@Column(name="end_date")
	private Date endDate;

	@ManyToOne
	@JoinColumn(name = "fundedby")
	@Index(name="projects_fundedBy_idx")
	private Program fundedBy;
	
	@ManyToOne
	@JoinColumn(name = "fundedhow+")
	@Index(name="projects_fundedhow_idx")
	private FundingScheme fundedHow;
	
	@Column(name="sc39", nullable=false)
	private Boolean SC39 = false;
	
	@ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE})
	@JoinTable(
        name="results_projects",
        joinColumns=@JoinColumn(name="project"),
        inverseJoinColumns=@JoinColumn(name="result")
    )
	private Collection<Result> results;
	
	@ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE})
	@JoinTable(
	        name="projects_projectsubjects",
	        joinColumns=@JoinColumn(name="project"),
	        inverseJoinColumns=@JoinColumn(name="project_subject")
	    )
		private Collection<ProjectSubject> subjects;

	public String getProjectID() {
		return projectID;
	}

	public void setProjectID(String projectID) {
		this.projectID = projectID;
	}

	public String getWebSite() {
		return webSite;
	}

	public void setWebSite(String webSite) {
		this.webSite = webSite;
	}

	public String getECProjectWebsite() {
		return ECProjectWebsite;
	}

	public void setECProjectWebsite(String eCProjectWebsite) {
		ECProjectWebsite = eCProjectWebsite;
	}

	

	public String getCallIdentifier() {
		return callIdentifier;
	}

	public void setCallIdentifier(String callIdentifier) {
		this.callIdentifier = callIdentifier;
	}

	public String getAcronym() {
		return acronym;
	}

	public void setAcronym(String acronym) {
		this.acronym = acronym;
	}

	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;
	}

	public Program getFundedBy() {
		return fundedBy;
	}

	public void setFundedBy(Program fundedBy) {
		this.fundedBy = fundedBy;
	}

	public Collection<Result> getResults() {
		return results;
	}

	public void setResults(Collection<Result> results) {
		this.results = results;
	}

	public void setSC39(Boolean sC39) {
		SC39 = sC39;
	}

	public Boolean getSC39() {
		return SC39;
	}

	public Collection<ProjectSubject> getSubjects() {
		return subjects;
	}

	public void setSubjects(Collection<ProjectSubject> subjects) {
		this.subjects = subjects;
	}

	public void setFundedHow(FundingScheme fundedHow) {
		this.fundedHow = fundedHow;
	}

	public FundingScheme getFundedHow() {
		return fundedHow;
	}
	
}
