SellingPriceList.java
package com.tradecloud.domain.item;
import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.common.Currency;
import com.tradecloud.domain.common.Incoterm;
import com.tradecloud.domain.configuration.PriceCode;
import com.tradecloud.domain.export.ExportParty;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.ForeignKey;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.*;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@Entity
@Table(name = "sellingpricelist")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "SellingPriceList")
public class SellingPriceList extends PersistenceBase {
private static final long serialVersionUID = 1L;
@ManyToOne
private Incoterm incoterm;
@ManyToOne
private ExportParty exportParty;
@OneToMany(mappedBy = "sellingPriceList", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Fetch(value = FetchMode.SUBSELECT)
private List<SellingPriceListProduct> sellingPriceListProduct = new LinkedList<SellingPriceListProduct>();
@Temporal(TemporalType.TIMESTAMP)
@Column(nullable = false)
@NotNull
@XmlAttribute(required = true)
private Date effectiveDate;
@ManyToOne
@JoinColumn(name = "currency_code")
@ForeignKey(name = "fk_currency")
@XmlElement(name = "Currency", required = true)
private Currency currency;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private PriceCode priceCode;
public Incoterm getIncoterm() {
return incoterm;
}
public void setIncoterm(Incoterm incoterm) {
this.incoterm = incoterm;
}
public ExportParty getExportParty() {
return exportParty;
}
public void setExportParty(ExportParty exportParty) {
this.exportParty = exportParty;
}
public Date getEffectiveDate() {
if (null == effectiveDate) {
effectiveDate = new Date();
}
return effectiveDate;
}
public void setEffectiveDate(Date effectiveDate) {
this.effectiveDate = effectiveDate;
}
public Currency getCurrency() {
return currency;
}
public void setCurrency(Currency currency) {
this.currency = currency;
}
public List<SellingPriceListProduct> getSellingPriceListProduct() {
return sellingPriceListProduct;
}
public void setSellingPriceListProduct(List<SellingPriceListProduct> sellingPriceListProduct) {
this.sellingPriceListProduct = sellingPriceListProduct;
}
public PriceCode getPriceCode() {
return priceCode;
}
public void setPriceCode(PriceCode priceCode) {
this.priceCode = priceCode;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((currency == null) ? 0 : currency.hashCode());
result = prime * result + ((effectiveDate == null) ? 0 : effectiveDate.hashCode());
result = prime * result + ((exportParty == null) ? 0 : exportParty.hashCode());
result = prime * result + ((incoterm == null) ? 0 : incoterm.hashCode());
result = prime * result + ((priceCode == null) ? 0 : priceCode.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
SellingPriceList other = (SellingPriceList) obj;
if (currency == null) {
if (other.currency != null)
return false;
} else if (!currency.equals(other.currency))
return false;
if (effectiveDate == null) {
if (other.effectiveDate != null)
return false;
} else if (!effectiveDate.equals(other.effectiveDate))
return false;
if (exportParty == null) {
if (other.exportParty != null)
return false;
} else if (!exportParty.equals(other.exportParty))
return false;
if (incoterm == null) {
if (other.incoterm != null)
return false;
} else if (!incoterm.equals(other.incoterm))
return false;
if (priceCode == null) {
if (other.priceCode != null)
return false;
} else if (!priceCode.equals(other.priceCode))
return false;
if (sellingPriceListProduct == null) {
if (other.sellingPriceListProduct != null)
return false;
} else if (!sellingPriceListProduct.equals(other.sellingPriceListProduct))
return false;
return true;
}
}