package eu.dnetlib.goldoa.domain;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.google.gwt.user.client.rpc.IsSerializable;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;


@Entity
//@Cache(usage= CacheConcurrencyStrategy.READ_ONLY,region = "user")
public class Organization implements IsSerializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(columnDefinition = "text")
	private String id;
	@Column(columnDefinition = "text")
	private String name;
	@Column(columnDefinition = "text")
	private String shortname;
	@Column(columnDefinition = "text")
	private String source;

	@OneToOne
	@JoinColumn(name = "country")
	private Country country;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.organization")
	private List<JournalDiscount> journalDiscounts = new ArrayList<>();


	/*@ManyToMany(fetch = FetchType.LAZY,mappedBy = "organizations")
	@JsonBackReference(value = "organization_budget")
	private List<Budget> budgets = new ArrayList<>();*/

	@ManyToMany(fetch = FetchType.LAZY, mappedBy = "organizations")
	@JsonBackReference(value = "projects")
	private List<Project> projects = new ArrayList<>();


	@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.organization")
	@JsonBackReference(value = "publisherDiscount")
	private List<PublisherDiscount> publisherDiscount = new ArrayList<>();
	
	public Organization() {}

	public String getId() {
		return this.id;
	}

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

	public Country getCountry() {
		return this.country;
	}

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

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getShortname() {
		return this.shortname;
	}

	public void setShortname(String shortname) {
		this.shortname = shortname;
	}

	public String getSource() {
		return this.source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	/*public List<Budget> getBudgets() {
		return budgets;
	}

	public void setBudgets(List<Budget> budgets) {
		this.budgets = budgets;
	}*/

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

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

}