CostLineTemplate.java
package com.tradecloud.domain.costing;
import com.tradecloud.common.base.HibernateUtils;
import com.tradecloud.domain.common.IntegratedStaticDataEntityBase;
import com.tradecloud.domain.configuration.clearing.za.AllowanceType;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
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;
/**
* Entity for cost line template details.
*/
@Entity
@Table(name = "costlinetemplate")
@NamedQueries({@NamedQuery(name = "costLineTemplate.byCostGroupOrderedByCostLineName",
query = "from CostLineTemplate where costGroup = :costGroup order by name")})
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "CostLineTemplate")
//@Cacheable(value = "costLineTemplate")
public class CostLineTemplate extends IntegratedStaticDataEntityBase {
private static final long serialVersionUID = 1L;
@NotNull
@Enumerated(EnumType.STRING)
@XmlAttribute
private CostGroup costGroup;
@Enumerated(EnumType.STRING)
private AllowanceType allowanceType;
@XmlAttribute
private String displayCostGroup;
@NotNull
private int sortingPriority = 0;
/**
* This is for an ordering in which the costlines should be evaluated. Value
* 0 evalutated first, 1 after, 2 after that, etc. Null will be evaluated
* last, for legacy costlines. This is to fix the problem of some costlines
* depending on the result of another one
*/
private Integer evaluationPriority;
private boolean dutiable;
private boolean discount;
private boolean transactionFee;
private boolean transporter;
private transient boolean updating;
public CostGroup getCostGroup() {
return costGroup;
}
public CostLineTemplate() {
}
public CostLineTemplate(String code, String name, CostGroup costGroup) {
super(code, name);
this.costGroup = costGroup;
}
public void setCostGroup(CostGroup costGroup) {
this.costGroup = costGroup;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (!HibernateUtils.proxyClassEquals(this, obj)) {
return false;
}
CostLineTemplate obj1 = (CostLineTemplate) obj;
return new EqualsBuilder().appendSuper(super.equals(obj)).append(getCostGroup(), obj1.getCostGroup()).isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder().appendSuper(super.hashCode()).append(getCostGroup()).toHashCode();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("code=").append(getCode()).append(",name=").append(getName()).append(",costGroup=").append(costGroup);
return sb.toString();
}
public int getSortingPriority() {
return sortingPriority;
}
public void setSortingPriority(int sortingPriority) {
this.sortingPriority = sortingPriority;
}
public void setEvalutationPriority(Integer evaluationPriority) {
this.evaluationPriority = evaluationPriority;
}
public Integer getEvaluationPriority() {
return evaluationPriority;
}
public boolean equalCostLineCode(String costLineCode) {
return this.getCode().equals(costLineCode);
}
public boolean isDutiable() {
return dutiable;
}
public void setDutiable(boolean dutiable) {
this.dutiable = dutiable;
}
public String getDisplayCostGroup() {
return displayCostGroup;
}
public void setDisplayCostGroup(String displayCostGroup) {
this.displayCostGroup = displayCostGroup;
}
public boolean isBaseSupply() {
return this.costGroup == CostGroup.BASE_SUPPLY;
}
public boolean isTransactionFee() {
return transactionFee;
}
public void setTransactionFee(boolean transactionFee) {
this.transactionFee = transactionFee;
}
public boolean isDiscount() {
return discount;
}
public void setDiscount(boolean discount) {
this.discount = discount;
}
public boolean isTransporter() {
return transporter;
}
public void setTransporter(boolean transporter) {
this.transporter = transporter;
}
public AllowanceType getAllowanceType() {
return allowanceType;
}
public void setAllowanceType(AllowanceType allowanceType) {
this.allowanceType = allowanceType;
}
public boolean isUpdating() {
return updating;
}
public void setUpdating(boolean updating) {
this.updating = updating;
}
}