package io.delphiplatform.api.v3.model.gras;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import javax.validation.constraints.NotNull;

import io.delphiplatform.api.v3.rdb.entity.ProductVersionEntity;

/**
 * A Product Version is a group of Products that contain the same contents on different Configurations. Configurations
 * include formats like cassette, vinyl, CD, digital audio, etc. A Product Version typically contains between 1 and
 * &lt;10 Products.  A Product Version is mostly synonymous with a Product Family. When users are discussing a Product
 * Family, they typically are referring to a Product Version that is the head of the Product Family.
 */
@JsonPropertyOrder(alphabetic = true)
public class ProductVersion {

    @JsonProperty("product_version_no")
    private Integer productVersionNo;

    @JsonProperty("config_cat_key")
    private String configCatKey;

    @JsonProperty("config_cat_name")
    private String configCatName;

    @JsonProperty("is_product_family_head")
    private Boolean isProductFamilyHead;

    @JsonProperty("label_id")
    private String labelId;

    @JsonProperty("label_name")
    private String labelName;

    @JsonProperty("main_artist_id")
    private String mainArtistId;

    @JsonProperty("product_class_key")
    private String productClassKey;

    @JsonProperty("product_class_name")
    private String productClassName;

    @JsonProperty("product_family_no")
    private Integer productFamilyNo;

    @JsonProperty("product_title")
    private String productTitle;

    @JsonProperty("product_title_suppl")
    private String productTitleSuppl;

    @JsonProperty("rep_owner_key")
    private String repOwnerKey;

    @JsonProperty("rep_owner_company")
    private Company repOwnerCompany;

    public static ProductVersion from(ProductVersionEntity entity) {
        if (entity == null) {
            return null;
        }

        return new ProductVersion()
            .productVersionNo(entity.getProdVersNo())
            .configCatKey(entity.getConfigurationCategory() == null ?
                null : entity.getConfigurationCategory().getConfigCatKey())
            .configCatName(entity.getConfigurationCategory() == null ?
                null : entity.getConfigurationCategory().getConfigCatName())
            .isProductFamilyHead(entity.isProdFamHead())
            .labelId(entity.getLabel() == null ? null : entity.getLabel().getLabelId())
            .labelName(entity.getLabel() == null ? null : entity.getLabel().getName())
            .mainArtistId(entity.getMainArtist() == null ? null : entity.getMainArtist().getArtistId())
            .productClassKey(entity.getProductClass() == null ? null : entity.getProductClass().getProdClassKey())
            .productClassName(entity.getProductClass() == null ? null : entity.getProductClass().getProdClassName())
            .productFamilyNo(entity.getProdFamNo())
            .productTitle(entity.getProdTitle())
            .productTitleSuppl(entity.getProdTitleSuppl())
            .repOwnerKey(entity.getRepertoireOwner() == null ? null : entity.getRepertoireOwner().getRepOwnerKey())
            .repOwnerCompany(entity.getRepertoireOwner() == null
                ? null : Company.from(entity.getRepertoireOwner().getRepertoireOwnerCompany()));

    }

    public ProductVersion productVersionNo(Integer productVersionNo) {
        this.productVersionNo = productVersionNo;
        return this;
    }

    /**
     * Primary key identifier for a ProductVersion.
     *
     * @return productVersionNo
     */
    @NotNull
    public Integer getProductVersionNo() {
        return productVersionNo;
    }

    public void setProductVersionNo(Integer productVersionNo) {
        this.productVersionNo = productVersionNo;
    }

    public ProductVersion configCatKey(String configCatKey) {
        this.configCatKey = configCatKey;
        return this;
    }

    /**
     * Configuration Category: A - single, C - album, D - digital single, etc.
     *
     * @return configCatKey
     */
    @NotNull
    public String getConfigCatKey() {
        return configCatKey;
    }

    public void setConfigCatKey(String configCatKey) {
        this.configCatKey = configCatKey;
    }

    public ProductVersion configCatName(String configCatName) {
        this.configCatName = configCatName;
        return this;
    }

    /**
     * Name of the Configuration Category
     *
     * @return configCatName
     */
    public String getConfigCatName() {
        return configCatName;
    }

    public void setConfigCatName(String configCatName) {
        this.configCatName = configCatName;
    }

    public ProductVersion isProductFamilyHead(Boolean isProductFamilyHead) {
        this.isProductFamilyHead = isProductFamilyHead;
        return this;
    }

    /**
     * True if the Product Version is the head of the Product Family.
     *
     * @return isProductFamilyHead
     */
    @NotNull
    public Boolean getIsProductFamilyHead() {
        return isProductFamilyHead;
    }

    public void setIsProductFamilyHead(Boolean isProductFamilyHead) {
        this.isProductFamilyHead = isProductFamilyHead;
    }

    public ProductVersion labelId(String labelId) {
        this.labelId = labelId;
        return this;
    }

    /**
     * Primary key identifier for a Label
     *
     * @return labelId
     */
    @NotNull
    public String getLabelId() {
        return labelId;
    }

    public void setLabelId(String labelId) {
        this.labelId = labelId;
    }

    public ProductVersion labelName(String labelName) {
        this.labelName = labelName;
        return this;
    }

    /**
     * Name of the label
     *
     * @return labelName
     */
    @NotNull
    public String getLabelName() {
        return labelName;
    }

    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }

    public ProductVersion mainArtistId(String mainArtistId) {
        this.mainArtistId = mainArtistId;
        return this;
    }

    /**
     * Primary key identifier for Artist
     *
     * @return mainArtistId
     */
    @NotNull
    public String getMainArtistId() {
        return mainArtistId;
    }

    public void setMainArtistId(String mainArtistId) {
        this.mainArtistId = mainArtistId;
    }

    public ProductVersion productClassKey(String productClassKey) {
        this.productClassKey = productClassKey;
        return this;
    }

    /**
     * Internal key number of a ProductClass
     *
     * @return productClassKey
     */
    @NotNull
    public String getProductClassKey() {
        return productClassKey;
    }

    public void setProductClassKey(String productClassKey) {
        this.productClassKey = productClassKey;
    }

    public ProductVersion productClassName(String productClassName) {
        this.productClassName = productClassName;
        return this;
    }

    /**
     * Name of the Product Class
     *
     * @return productClassName
     */
    public String getProductClassName() {
        return productClassName;
    }

    public void setProductClassName(String productClassName) {
        this.productClassName = productClassName;
    }

    public ProductVersion productFamilyNo(Integer productFamilyNo) {
        this.productFamilyNo = productFamilyNo;
        return this;
    }

    /**
     * Identifier for a Product Family. A Product Family is a group containing multiple ProductVersions.
     *
     * @return productFamilyNo
     */
    @NotNull
    public Integer getProductFamilyNo() {
        return productFamilyNo;
    }

    public void setProductFamilyNo(Integer productFamilyNo) {
        this.productFamilyNo = productFamilyNo;
    }

    public ProductVersion productTitle(String productTitle) {
        this.productTitle = productTitle;
        return this;
    }

    /**
     * The title of the Product
     *
     * @return productTitle
     */
    @NotNull
    public String getProductTitle() {
        return productTitle;
    }

    public void setProductTitle(String productTitle) {
        this.productTitle = productTitle;
    }

    public ProductVersion productTitleSuppl(String productTitleSuppl) {
        this.productTitleSuppl = productTitleSuppl;
        return this;
    }

    /**
     * The supplementary title of the Product
     *
     * @return productTitleSuppl
     */
    public String getProductTitleSuppl() {
        return productTitleSuppl;
    }

    public void setProductTitleSuppl(String productTitleSuppl) {
        this.productTitleSuppl = productTitleSuppl;
    }

    public ProductVersion repOwnerKey(String repOwnerKey) {
        this.repOwnerKey = repOwnerKey;
        return this;
    }

    /**
     * Primary key identifier for a Company, also used via RepertoireOwner, ParentRepertoireOwner and ProfitCenter.
     *
     * @return repOwnerKey
     */
    @NotNull
    public String getRepOwnerKey() {
        return repOwnerKey;
    }

    public void setRepOwnerKey(String repOwnerKey) {
        this.repOwnerKey = repOwnerKey;
    }

    public ProductVersion repOwnerCompany(Company repOwnerCompany) {
        this.repOwnerCompany = repOwnerCompany;
        return this;
    }

    public Company getRepOwnerCompany() {
        return repOwnerCompany;
    }

    public void setRepOwnerCompany(Company repOwnerCompany) {
        this.repOwnerCompany = repOwnerCompany;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class ProductVersion {\n");

        sb.append("    productVersionNo: ").append(toIndentedString(productVersionNo)).append("\n");
        sb.append("    configCatKey: ").append(toIndentedString(configCatKey)).append("\n");
        sb.append("    configCatName: ").append(toIndentedString(configCatName)).append("\n");
        sb.append("    isProductFamilyHead: ").append(toIndentedString(isProductFamilyHead)).append("\n");
        sb.append("    labelId: ").append(toIndentedString(labelId)).append("\n");
        sb.append("    labelName: ").append(toIndentedString(labelName)).append("\n");
        sb.append("    mainArtistId: ").append(toIndentedString(mainArtistId)).append("\n");
        sb.append("    productClassKey: ").append(toIndentedString(productClassKey)).append("\n");
        sb.append("    productClassName: ").append(toIndentedString(productClassName)).append("\n");
        sb.append("    productFamilyNo: ").append(toIndentedString(productFamilyNo)).append("\n");
        sb.append("    productTitle: ").append(toIndentedString(productTitle)).append("\n");
        sb.append("    productTitleSuppl: ").append(toIndentedString(productTitleSuppl)).append("\n");
        sb.append("    repOwnerKey: ").append(toIndentedString(repOwnerKey)).append("\n");
        sb.append("    repOwnerCompany: ").append(toIndentedString(repOwnerCompany)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces (except the first line).
     */
    private String toIndentedString(Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }
}

