package eu.dnetlib.data.openaire.dsm.model;

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

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@DynamicUpdate
@SelectBeforeUpdate
@Table(name = "dsm_organizations")
public class Organization implements Serializable {

	private static final long serialVersionUID = -8517323814472121142L;

	@Id
	private String id;
	private String legalshortname;
	private String legalname;
	private String websiteurl;
	private String logourl;

	private String country;
	private String collectedfrom;

	private Date dateofcollection;
	private String provenanceaction;

	@ManyToMany(cascade = {
		CascadeType.PERSIST, CascadeType.MERGE
	}, fetch = FetchType.EAGER, mappedBy = "organizations")
	private Set<Datasource> datasources;

	public String getId() {
		return id;
	}

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

	public String getLegalshortname() {
		return legalshortname;
	}

	public void setLegalshortname(final String legalshortname) {
		this.legalshortname = legalshortname;
	}

	public String getLegalname() {
		return legalname;
	}

	public void setLegalname(final String legalname) {
		this.legalname = legalname;
	}

	public String getWebsiteurl() {
		return websiteurl;
	}

	public void setWebsiteurl(final String websiteurl) {
		this.websiteurl = websiteurl;
	}

	public String getLogourl() {
		return logourl;
	}

	public void setLogourl(final String logourl) {
		this.logourl = logourl;
	}

	public String getCountry() {
		return country;
	}

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

	public String getCollectedfrom() {
		return collectedfrom;
	}

	public void setCollectedfrom(final String collectedfrom) {
		this.collectedfrom = collectedfrom;
	}

	public Date getDateofcollection() {
		return dateofcollection;
	}

	public void setDateofcollection(final Date dateofcollection) {
		this.dateofcollection = dateofcollection;
	}

	public String getProvenanceaction() {
		return provenanceaction;
	}

	public void setProvenanceaction(final String provenanceaction) {
		this.provenanceaction = provenanceaction;
	}

	@JsonIgnore
	public Set<Datasource> getDatasources() {
		return datasources;
	}

	public void setDatasources(final Set<Datasource> datasources) {
		this.datasources = datasources;
	}

}
