ExchangeRateClientConfig.java

package com.tradecloud.domain.configuration;

import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.model.organisationalunit.OrganisationalUnitTier;
import com.tradecloud.domain.rate.RateSourceType;

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.util.Set;

/**
 * A holder for exchange rate client configuration values.
 */
@Entity
@Table(name = "exchangerateclientconfig")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "ExchangeRateClientConfig")
public class ExchangeRateClientConfig extends PersistenceBase {

    private static final long serialVersionUID = 1L;

    /**
     * The source of the CLC rate. Defaults to {@link RateSourceType#RATES_FEED}
     * .
     */
    @Enumerated(value = EnumType.STRING)
    @XmlAttribute
    @NotNull
    private RateSourceType clcRateSource;

    /**
     * The source of the ALC rate. Defaults to
     * {@link RateSourceType#TREASURY_LINKED_RATE}.
     */
    @Enumerated(value = EnumType.STRING)
    @XmlAttribute
    @NotNull
    private RateSourceType alcRateSource;

    @Enumerated(value = EnumType.STRING)
    @XmlAttribute
    @NotNull
    private RateSourceType clcImporterRateSource;

    @Enumerated(value = EnumType.STRING)
    @XmlAttribute
    @NotNull
    private RateSourceType alcImporterRateSource;


    /**
     * Allows for the rate in the costsheet as derived from
     * {@link #clcRateSource} to be overridden. Defaults to false.
     */
    @XmlAttribute
    @NotNull
    private boolean allowCLCRateOverride;

    /**
     * Allows for the rate in the costsheet as derived from
     * {@link #alcRateSource} to be overridden. Defaults to false.
     */
    @XmlAttribute
    @NotNull
    private boolean allowALCRateOverride;

    /**
     * Indicates whether to always refresh rates. If true then
     * {@link #minimumDaysForRefreshRate} should not be editable. Defaults to
     * true.
     */
    @XmlAttribute
    @NotNull
    private boolean alwaysRefreshRates;

    @XmlAttribute
    @NotNull
    private boolean alwaysUseLatesEffectivetDateRate;

    /**
     * Do not refresh rates if Latest Shipment Date (LSD) change is less than
     * this number of days. Defaults to 14. Options are 14 and 30.
     */
    @XmlAttribute
    @NotNull
    private int minimumDaysForRefreshRateAfterLSDChange;

    private int effectiveDaysForAverageFECRate;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "stdOrganisationalUnitTier_code")
    private OrganisationalUnitTier stdOrganisationalUnitTier;

    //    @XmlElementWrapper(name = "rateSourceConfigs")
//    @XmlElement(name = "rateSourceConfig")
//    @OneToMany(cascade = CascadeType.ALL)
//    @JoinTable(name = "exchangerateclientconfig_rateSourceConfigs",
//            joinColumns = {@JoinColumn(name = "exchangerateclientconfig_id", unique = false)},
//            inverseJoinColumns = {@JoinColumn(name = "rateSourceConfigs_id", unique = false)})
    private transient Set<RateSourceConfig> rateSourceConfigs;

    public RateSourceType getClcRateSource() {
        return clcRateSource;
    }

    public void setClcRateSource(RateSourceType clcRateSource) {
        this.clcRateSource = clcRateSource;
    }

    public RateSourceType getAlcRateSource() {
        return alcRateSource;
    }

    public void setAlcRateSource(RateSourceType alcRateSource) {
        this.alcRateSource = alcRateSource;
    }

    public boolean isAllowCLCRateOverride() {
        return allowCLCRateOverride;
    }

    public boolean isAlwaysUseLatesEffectivetDateRate() {
        return alwaysUseLatesEffectivetDateRate;
    }

    public void setAlwaysUseLatesEffectivetDateRate(boolean alwaysUseLatesEffectivetDateRate) {
        this.alwaysUseLatesEffectivetDateRate = alwaysUseLatesEffectivetDateRate;
    }

    public void setAllowCLCRateOverride(boolean allowCLCRateOverride) {
        this.allowCLCRateOverride = allowCLCRateOverride;
    }

    public boolean isAllowALCRateOverride() {
        return allowALCRateOverride;
    }

    public void setAllowALCRateOverride(boolean allowALCRateOverride) {
        this.allowALCRateOverride = allowALCRateOverride;
    }

    public boolean isAlwaysRefreshRates() {
        return alwaysRefreshRates;
    }

    public void setAlwaysRefreshRates(boolean alwaysRefreshRates) {
        this.alwaysRefreshRates = alwaysRefreshRates;
    }

    public int getMinimumDaysForRefreshRateAfterLSDChange() {
        return minimumDaysForRefreshRateAfterLSDChange;
    }

    public void setMinimumDaysForRefreshRateAfterLSDChange(int minimumDaysForRefreshRateAfterLSDChange) {
        this.minimumDaysForRefreshRateAfterLSDChange = minimumDaysForRefreshRateAfterLSDChange;
    }

    public OrganisationalUnitTier getStdOrganisationalUnitTier() {
        return stdOrganisationalUnitTier;
    }

    public void setStdOrganisationalUnitTier(OrganisationalUnitTier stdOrganisationalUnitTier) {
        this.stdOrganisationalUnitTier = stdOrganisationalUnitTier;
    }

    public RateSourceType getClcImporterRateSource() {
        return clcImporterRateSource;
    }

    public void setClcImporterRateSource(RateSourceType clcImporterRateSource) {
        this.clcImporterRateSource = clcImporterRateSource;
    }

    public RateSourceType getAlcImporterRateSource() {
        return alcImporterRateSource;
    }

    public void setAlcImporterRateSource(RateSourceType alcImporterRateSource) {
        this.alcImporterRateSource = alcImporterRateSource;
    }

    public int getEffectiveDaysForAverageFECRate() {
        return effectiveDaysForAverageFECRate;
    }

    public void setEffectiveDaysForAverageFECRate(int effectiveDaysForAverageFECRate) {
        this.effectiveDaysForAverageFECRate = effectiveDaysForAverageFECRate;
    }

    public Set<RateSourceConfig> getRateSourceConfigs() {
        return rateSourceConfigs;
    }

    public void setRateSourceConfigs(Set<RateSourceConfig> rateSourceConfigs) {
        this.rateSourceConfigs = rateSourceConfigs;
    }
}