SupplierClientConfig.java

package com.tradecloud.domain.configuration.supplier;

import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.model.DestinationSystem;
import com.tradecloud.domain.supplier.SupplierUniqueIdentifier;
import org.hibernate.annotations.ForeignKey;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import java.math.BigDecimal;

/**
 * A holder for supplier client configuration values.
 */
@Entity
@Table(name = "supplierclientconfig")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "SupplierClientConfig")
@NamedQueries({
        @NamedQuery(name = "supplierClientConfig.findSupplierIntegrationProperties",
                query = "select supplierIntegrationProperties from SupplierClientConfig"),
        @NamedQuery(name = "supplierClientConfig.findSupplierValidationProperties",
                query = "select supplierValidationProperties from SupplierClientConfig")})
public class SupplierClientConfig extends PersistenceBase {

    private static final long serialVersionUID = 1L;

    /**
     * Maximum Supplier name field length. Can be a whole number between 1 and 75,
     * defaults to 60.
     */
    @XmlAttribute
    @NotNull
    private int maxNameLength;

    /**
     * Maximum Supplier reference field length. Can be a whole number between 1 and
     * 75, defaults to 40.
     */
    @XmlAttribute
    @NotNull
    private int maxReferenceLength;

    /**
     * Options are 15 and 21, defaults to 15.
     */
    @XmlAttribute
    @NotNull
    private int presentationDays;

    /**
     * Supplier destination system (Tradecloud or MasterData are the only two
     * options).
     */
    @Enumerated(value = EnumType.STRING)
    @XmlAttribute
    @NotNull
    private DestinationSystem supplierDestinationSystem;

    /**
     * Whether or not suppliers can be created through the UI. With some of our
     * clients all the suppliers must come through integrations.
     */
    @XmlAttribute
    @NotNull
    private boolean allowNonIntegratedSupplierCreation;

    private boolean allowDeleteSupplierOnOrgDelete;

    @Enumerated(value = EnumType.STRING)
    @NotNull
    private SupplierUniqueIdentifier supplierUniqueIdentifier;

    /**
     * Indicates that a LC can be drawn for X% more than the face value of the LC.
     * Should not be less than 0 and more than 10. Supplier specific config
     * overrides order level config.
     */
    @XmlAttribute
    @NotNull
    private BigDecimal lcToleranceAbove;

    /**
     * Indicates that a LC can be drawn for X% less than the face value of the LC.
     * Should not be less than 0 or more than 10. Supplier specific config overrides
     * order level config.
     */
    @XmlAttribute
    @NotNull
    private BigDecimal lcToleranceBelow;

    /**
     * Minimum length allowed for the supplier contact phone number.
     */
    @XmlAttribute
    @NotNull
    private Integer minPhoneNumberLength;

    /**
     * Minimum length allowed for the supplier contact phone number.
     */
    @XmlAttribute
    @NotNull
    private Integer minMobilePhoneNumberLength;

    /**
     * Minimum length allowed for the supplier contact mobile phone number.
     */
    @XmlAttribute
    @NotNull
    private Integer minFaxNumberLength;


    @OneToOne(cascade = CascadeType.ALL)
    @ForeignKey(name = "fk_supplierintegrationproperties")
    private SupplierIntegrationProperties supplierIntegrationProperties = new SupplierIntegrationProperties();

    @OneToOne(cascade = CascadeType.ALL)
    @ForeignKey(name = "fk_suppliervalidationproperties")
    private SupplierValidationProperties supplierValidationProperties = new SupplierValidationProperties();

    //Confirm here
    @OneToOne(cascade = CascadeType.ALL)
    @ForeignKey(name = "fk_elcsuppliervalidationproperties")
    private SupplierValidationProperties elcsupplierValidationProperties = new SupplierValidationProperties();

    public SupplierValidationProperties getElcsupplierValidationProperties() {
        return elcsupplierValidationProperties;
    }

    public void setElcsupplierValidationProperties(SupplierValidationProperties elcsupplierValidationProperties) {
        this.elcsupplierValidationProperties = elcsupplierValidationProperties;
    }

    public SupplierIntegrationProperties getSupplierIntegrationProperties() {
        return supplierIntegrationProperties;
    }

    public void setSupplierIntegrationProperties(SupplierIntegrationProperties supplierIntegrationProperties) {
        this.supplierIntegrationProperties = supplierIntegrationProperties;
    }

    public SupplierValidationProperties getSupplierValidationProperties() {
        return supplierValidationProperties;
    }

    public void setSupplierValidationProperties(SupplierValidationProperties supplierValidationProperties) {
        this.supplierValidationProperties = supplierValidationProperties;
    }

    public int getMaxNameLength() {
        return maxNameLength;
    }

    public void setMaxNameLength(int maxNameLength) {
        this.maxNameLength = maxNameLength;
    }

    public int getMaxReferenceLength() {
        return maxReferenceLength;
    }

    public void setMaxReferenceLength(int maxReferenceLength) {
        this.maxReferenceLength = maxReferenceLength;
    }

    public int getPresentationDays() {
        return presentationDays;
    }

    public void setPresentationDays(int presentationDays) {
        this.presentationDays = presentationDays;
    }

    public BigDecimal getLcToleranceAbove() {
        return lcToleranceAbove;
    }

    public void setLcToleranceAbove(BigDecimal lcToleranceAbove) {
        this.lcToleranceAbove = lcToleranceAbove;
    }

    public BigDecimal getLcToleranceBelow() {
        return lcToleranceBelow;
    }

    public void setLcToleranceBelow(BigDecimal lcToleranceBelow) {
        this.lcToleranceBelow = lcToleranceBelow;
    }

    public DestinationSystem getSupplierDestinationSystem() {
        return supplierDestinationSystem;
    }

    public void setSupplierDestinationSystem(DestinationSystem supplierDestinationSystem) {
        this.supplierDestinationSystem = supplierDestinationSystem;
    }

    public boolean isAllowNonIntegratedSupplierCreation() {
        return allowNonIntegratedSupplierCreation;
    }

    public void setAllowNonIntegratedSupplierCreation(boolean allowNonIntegratedSupplierCreation) {
        this.allowNonIntegratedSupplierCreation = allowNonIntegratedSupplierCreation;
    }

    public int getMinPhoneNumberLength() {
        return minPhoneNumberLength;
    }

    public void setMinPhoneNumberLength(int minPhoneNumberLength) {
        this.minPhoneNumberLength = minPhoneNumberLength;
    }

    public int getMinMobilePhoneNumberLength() {
        return minMobilePhoneNumberLength;
    }

    public void setMinMobilePhoneNumberLength(int minMobilePhoneNumberLength) {
        this.minMobilePhoneNumberLength = minMobilePhoneNumberLength;
    }

    public int getMinFaxNumberLength() {
        return minFaxNumberLength;
    }

    public void setMinFaxNumberLength(int minFaxNumberLength) {
        this.minFaxNumberLength = minFaxNumberLength;
    }

    public SupplierUniqueIdentifier getSupplierUniqueIdentifier() {
        return supplierUniqueIdentifier;
    }

    public void setSupplierUniqueIdentifier(SupplierUniqueIdentifier supplierUniqueIdentifier) {
        this.supplierUniqueIdentifier = supplierUniqueIdentifier;
    }

    public boolean isAllowDeleteSupplierOnOrgDelete() {
        return allowDeleteSupplierOnOrgDelete;
    }

    public void setAllowDeleteSupplierOnOrgDelete(boolean allowDeleteSupplierOnOrgDelete) {
        this.allowDeleteSupplierOnOrgDelete = allowDeleteSupplierOnOrgDelete;
    }
}