package eu.dnetlib.openaire.db.objects;

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

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity(name = "results")
@Table(name = "results")
public class Result implements Serializable {

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

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

	@Column(name = "title")
	private String title;
	
	@Column(name = "publication_date", nullable=true)
	private Date publicationDate;
	
	@Lob
	@Column(name = "description")
	private String description;
	
	@Column(name = "publisher", nullable=true)
	private String publisher;
	
	@ManyToOne
	@JoinColumn(name = "hasKind")
	private ResultKind resultKind;
	
	@ManyToOne
	@JoinColumn(name = "hasType", nullable = true)
	private ResultType resultType;
	
	@ManyToOne
	@JoinColumn(name = "language")
	private Language language;
	
	@ManyToOne
	@JoinColumn(name = "access_mode")
	private AccessMode accessMode;
	
	@Column(name="embargo_end_date", nullable=true)
	private Date embargoEndDate;
	
	@Lob
	@Column(name="keywords")
	private String keywords;

	@OneToMany(mappedBy="result", cascade=CascadeType.ALL, fetch=FetchType.LAZY)
	private Collection<AuthorShip> authorShips;
	
	@Column(name = "optional1", nullable=true)
	private String optional1;

	@Column(name = "optional2", nullable=true)
	private String optional2;
	
	@ManyToMany(
		cascade={CascadeType.PERSIST, CascadeType.MERGE},
		mappedBy = "results"
	)
	private Collection<Project> projects;

	public String getResultID() {
		return resultID;
	}

	public void setResultID(String resultID) {
		this.resultID = resultID;
	}

	public String getTitle() {
		return title;
	}

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

	public Date getPublicationDate() {
		return publicationDate;
	}

	public void setPublicationDate(Date publicationDate) {
		this.publicationDate = publicationDate;
	}

	public String getDescription() {
		return description;
	}

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

	public String getPublisher() {
		return publisher;
	}

	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	public ResultKind getResultKind() {
		return resultKind;
	}

	public void setResultKind(ResultKind resultKind) {
		this.resultKind = resultKind;
	}

	public ResultType getResultType() {
		return resultType;
	}

	public void setResultType(ResultType resultType) {
		this.resultType = resultType;
	}

	public Language getLanguage() {
		return language;
	}

	public void setLanguage(Language language) {
		this.language = language;
	}

	public AccessMode getAccessMode() {
		return accessMode;
	}

	public void setAccessMode(AccessMode accessMode) {
		this.accessMode = accessMode;
	}

	public Date getEmbargoEndDate() {
		return embargoEndDate;
	}

	public void setEmbargoEndDate(Date embargoEndDate) {
		this.embargoEndDate = embargoEndDate;
	}

	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	public Collection<AuthorShip> getAuthorShips() {
		return authorShips;
	}

	public void setAuthorShips(Collection<AuthorShip> authorShips) {
		this.authorShips = authorShips;
	}

	public Collection<Project> getProjects() {
		return projects;
	}

	public void setProjects(Collection<Project> projects) {
		this.projects = projects;
	}


	public String getOptional1() {
		return optional1;
	}

	public void setOptional1(String optional1) {
		this.optional1 = optional1;
	}

	public String getOptional2() {
		return optional2;
	}

	public void setOptional2(String optional2) {
		this.optional2 = optional2;
	}	

}
