package com.sonymusic.dx.persistence.gras;

import jakarta.persistence.*;
import org.hibernate.type.YesNoConverter;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "vgras369")
@IdClass(RecordingProjectCountryPk.class)
public class RecordingProjectCountry extends RAASClientSpecificEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "country_key", nullable = false, length = 3, updatable = false, insertable = false)
	private String countryKey;

	@Id
	@Column(name = "rec_project_id", nullable = false, updatable = false, insertable = false)
	private Long recordingProjectId;

//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "financ_label_key")
//    private FinancialLabelTier1 financialLabel;

	@Column(name = "is_confidential", nullable = false, length = 1)
	@Convert(converter = YesNoConverter.class)
	private boolean isConfidential;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "label_key", referencedColumnName = "label_key"),
			@JoinColumn(name = "label_ext", referencedColumnName = "label_ext") })
	private Label label;

	@Column(name = "loc_financ_project_no", length = 20)
	private String localFinancialProjectNo;

//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumns({ @JoinColumn(name = "loc_genre_key", referencedColumnName = "loc_genre_key", insertable = false, updatable = false),
//            @JoinColumn(name = "country_key", referencedColumnName = "country_key", insertable = false, updatable = false) })
//    private LocalGenre localGenre;

	@Column(name = "log_mod_stamp", nullable = false)
	private Timestamp lastLogicalModificationTime;

	@Column(name = "log_mod_user", nullable = false, length = 8)
	private String lastLogicalModificationUser;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "strategic_rep_grp_key")
	private StrategicReportingGroup strategicReportingGroup;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "country_key", insertable = false, updatable = false)
	private Country country;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "rec_project_id", insertable = false, updatable = false)
	private RecordingProject recordingProject;

	@Column(name = "sap_profit_center_key")
	private String sapProfitCenterKey;

	@Column(name = "sap_company_key")
	private String sapCompanyKey;

	@Column(name = "royalty_account_no")
	private String royaltyAccountNo;

//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "loc_ownership_key", insertable = false, updatable = false)
//    private LocalOwnership localOwnership;

	@ElementCollection
	@Column(name = "sap_profit_center_name")
	@JoinTable(name = "vgras0258", joinColumns = @JoinColumn(name = "sap_profit_center_key", referencedColumnName = "sap_profit_center_key"))
	private List<String> sapProfitCenters = new ArrayList<String>();

	@ElementCollection
	@Column(name = "sap_company_name")
	@JoinTable(name = "vgras0259", joinColumns = @JoinColumn(name = "sap_company_key", referencedColumnName = "sap_company_key"))
	private List<String> royaltyAccs = new ArrayList<String>();

	@ElementCollection
	@Column(name = "royalty_account_name")
	@JoinTable(name = "vgras0262", joinColumns = @JoinColumn(name = "royalty_account_no", referencedColumnName = "royalty_account_no"))
	private List<String> sapCompanies = new ArrayList<String>();

	@Column(name = "video_royalty_account_no")
	private String videoRoyaltyAccountNo;

//    public FinancialLabelTier1 getFinancialLabel() {
//        return financialLabel;
//    }
//
//    public void setFinancialLabel(FinancialLabelTier1 financialLabel) {
//        this.financialLabel = financialLabel;
//    }

	public boolean isConfidential() {
		return isConfidential;
	}

	public void setConfidential(boolean isConfidential) {
		this.isConfidential = isConfidential;
	}

	public Label getLabel() {
		return label;
	}

	public void setLabel(Label label) {
		this.label = label;
	}

	public String getLocalFinancialProjectNo() {
		return localFinancialProjectNo;
	}

	public void setLocalFinancialProjectNo(String localFinancialProjectNo) {
		this.localFinancialProjectNo = localFinancialProjectNo;
	}

//    public LocalGenre getLocalGenre() {
//        return localGenre;
//    }
//
//    public void setLocalGenre(LocalGenre localGenre) {
//        this.localGenre = localGenre;
//    }

	public Timestamp getLastLogicalModificationTime() {
		return lastLogicalModificationTime;
	}

	public void setLastLogicalModificationTime(Timestamp lastLogicalModificationTime) {
		this.lastLogicalModificationTime = lastLogicalModificationTime;
	}

	public String getLastLogicalModificationUser() {
		return lastLogicalModificationUser;
	}

	public void setLastLogicalModificationUser(String lastLogicalModificationUser) {
		this.lastLogicalModificationUser = lastLogicalModificationUser;
	}

	public StrategicReportingGroup getStrategicReportingGroup() {
		return strategicReportingGroup;
	}

	public void setStrategicReportingGroup(StrategicReportingGroup strategicReportingGroup) {
		this.strategicReportingGroup = strategicReportingGroup;
	}

	public Country getCountry() {
		return country;
	}

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

	public RecordingProject getRecordingProject() {
		return recordingProject;
	}

	public void setRecordingProject(RecordingProject recordingProject) {
		this.recordingProject = recordingProject;
	}

	protected String getCountryKey() {
		return countryKey;
	}

	protected void setCountryKey(String countryKey) {
		this.countryKey = countryKey;
	}

	protected Long getRecordingProjectId() {
		return recordingProjectId;
	}

	protected void setRecordingProjectId(Long recordingProjectId) {
		this.recordingProjectId = recordingProjectId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((getCountryKey() == null) ? 0 : getCountryKey().hashCode());
		result = prime * result + ((getRecordingProjectId() == null) ? 0 : getRecordingProjectId().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof RecordingProjectCountry))
			return false;
		RecordingProjectCountry other = (RecordingProjectCountry) obj;
		if (getCountryKey() == null) {
			if (other.getCountryKey() != null)
				return false;
		} else if (!getCountryKey().equals(other.getCountryKey()))
			return false;
		if (getRecordingProjectId() == null) {
			if (other.getRecordingProjectId() != null)
				return false;
		} else if (!getRecordingProjectId().equals(other.getRecordingProjectId()))
			return false;
		return true;
	}

	public List<String> getSapProfitCenters() {
		return sapProfitCenters;
	}

	public void setSapProfitCenters(List<String> sapProfitCenters) {
		this.sapProfitCenters = sapProfitCenters;
	}

	public List<String> getRoyaltyAccs() {
		return royaltyAccs;
	}

	public String getVideoRoyaltyAccountNo() {
		return videoRoyaltyAccountNo;
	}

	public void setVideoRoyaltyAccountNo(String videoRoyaltyAccountNo) {
		this.videoRoyaltyAccountNo = videoRoyaltyAccountNo;
	}

	public void setRoyaltyAccs(List<String> royaltyAcc) {
		this.royaltyAccs = royaltyAcc;
	}

	public List<String> getsapCompanies() {
		return sapCompanies;
	}

	public void setsapCompanies(List<String> sapCompanies) {
		this.sapCompanies = sapCompanies;
	}

	public String getSapProfitCenterKey() {
		return sapProfitCenterKey;
	}

	public void setSapProfitCenterKey(String sapProfitCenterKey) {
		this.sapProfitCenterKey = sapProfitCenterKey;
	}

	public String getSapCompanyKey() {
		return sapCompanyKey;
	}

	public void setSapCompanyKey(String sapCompanyKey) {
		this.sapCompanyKey = sapCompanyKey;
	}

	public String getRoyaltyAccountNo() {
		return royaltyAccountNo;
	}

	public void setRoyaltyAccountNo(String royaltyAccountNo) {
		this.royaltyAccountNo = royaltyAccountNo;
	}

//    public LocalOwnership getLocalOwnership() {
//        return localOwnership;
//    }
//
//    public void setLocalOwnership(LocalOwnership localOwnership) {
//        this.localOwnership = localOwnership;
//    }

}