package eu.dnetlib.broker.objects;

public class Project {

	private String code;
	private String acronym;
	private String title;
	private String funder;
	private String fundingProgram;
	private String jurisdiction;

	public Project() {}

	public Project(final String code, final String acronym, final String title, final String funder, final String fundingProgram, final String jurisdiction) {
		this.code = code;
		this.acronym = acronym;
		this.title = title;
		this.funder = funder;
		this.fundingProgram = fundingProgram;
		this.jurisdiction = jurisdiction;
	}

	public String getCode() {
		return this.code;
	}

	public Project setCode(final String code) {
		this.code = code;
		return this;
	}

	public String getAcronym() {
		return this.acronym;
	}

	public Project setAcronym(final String acronym) {
		this.acronym = acronym;
		return this;
	}

	public String getTitle() {
		return this.title;
	}

	public Project setTitle(final String title) {
		this.title = title;
		return this;
	}

	public String getFunder() {
		return this.funder;
	}

	public Project setFunder(final String funder) {
		this.funder = funder;
		return this;
	}

	public String getFundingProgram() {
		return this.fundingProgram;
	}

	public Project setFundingProgram(final String fundingProgram) {
		this.fundingProgram = fundingProgram;
		return this;
	}

	public String getJurisdiction() {
		return this.jurisdiction;
	}

	public Project setJurisdiction(final String jurisdiction) {
		this.jurisdiction = jurisdiction;
		return this;
	}

	public String asOpenaireProjectIdentifier() {
		if (verifyManadatoryFields()) {
			return String.format("info:eu-repo/grantAgreement/%s/%s/%s/%s/%s/%s",
					this.funder,
					this.fundingProgram,
					this.code,
					this.jurisdiction != null ? this.jurisdiction : "",
					this.title != null ? this.title : "",
					this.acronym != null ? this.acronym : "");
		} else {
			return "";
		}
	}

	public boolean verifyManadatoryFields() {
		return (this.funder != null && this.fundingProgram != null && this.code != null
				&& !this.funder.isEmpty() && !this.fundingProgram.isEmpty() && !this.code.isEmpty());
	}

}
