package com.sonymusic.dx.persistence.gras;

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

import java.io.Serializable;

@Entity
@Table(name = "vgras389")
@IdClass(RecordingProjectPublisherPk.class)
public class RecordingProjectPublisher extends RAASClientSpecificEntity implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

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

    @Column(name = "administered_by", length = 250)
    private String administeredBy;

    @Column(name = "mod_publisher_name", length = 250)
    private String modifiedPublisherName;

    @Column(name = "seq_no", nullable = false)
    private Long sequence;

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

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

//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "copy_soc_key")
//    private CopyrightSociety copyrightSociety;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "link_word_key")
    private ArtworkLinkingWord linkingWord;

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

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

//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "publisher_no", insertable = false, updatable = false)
//    private Publisher publisher;

    public String getAdministeredBy() {
        return administeredBy;
    }

    public void setAdministeredBy(String administeredBy) {
        this.administeredBy = administeredBy;
    }

    public String getModifiedPublisherName() {
        return modifiedPublisherName;
    }

    public void setModifiedPublisherName(String modifiedPublisherName) {
        this.modifiedPublisherName = modifiedPublisherName;
    }

    public Long getSequence() {
        return sequence;
    }

    public void setSequence(Long sequence) {
        this.sequence = sequence;
    }

    public boolean isIncludeOnSong() {
        return includeOnSong;
    }

    public void setIncludeOnSong(boolean includeOnSong) {
        this.includeOnSong = includeOnSong;
    }

    public boolean isConfidential() {
        return isConfidential;
    }

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

//    public CopyrightSociety getCopyrightSociety() {
//        return copyrightSociety;
//    }
//
//    public void setCopyrightSociety(CopyrightSociety copyrightSociety) {
//        this.copyrightSociety = copyrightSociety;
//    }

    public ArtworkLinkingWord getLinkingWord() {
        return linkingWord;
    }

    public void setLinkingWord(ArtworkLinkingWord linkingWord) {
        this.linkingWord = linkingWord;
    }

    public RecordingProject getRecordingProject() {
        return recordingProject;
    }

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

    public Country getCountry() {
        return country;
    }

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

//    public Publisher getPublisher() {
//        return publisher;
//    }
//
//    public void setPublisher(Publisher publisher) {
//        this.publisher = publisher;
//    }

    protected Long getRecordingProjectId() {
        return recordingProjectId;
    }

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

    protected String getCountryKey() {
        return countryKey;
    }

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

    protected Long getPublisherNo() {
        return publisherNo;
    }

    protected void setPublisherNo(Long publisherNo) {
        this.publisherNo = publisherNo;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getCountryKey() == null) ? 0 : getCountryKey().hashCode());
        result = prime * result + ((getPublisherNo() == null) ? 0 : getPublisherNo().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 RecordingProjectPublisher))
            return false;
        RecordingProjectPublisher other = (RecordingProjectPublisher) obj;
        if (getCountryKey() == null) {
            if (other.getCountryKey() != null)
                return false;
        } else if (!getCountryKey().equals(other.getCountryKey()))
            return false;
        if (getPublisherNo() == null) {
            if (other.getPublisherNo() != null)
                return false;
        } else if (!getPublisherNo().equals(other.getPublisherNo()))
            return false;
        if (getRecordingProjectId() == null) {
            if (other.getRecordingProjectId() != null)
                return false;
        } else if (!getRecordingProjectId().equals(other.getRecordingProjectId()))
            return false;
        return true;
    }

}