Incoterm.java
package com.tradecloud.domain.common;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
/**
* <p>
* Java class for Incoterm.
*
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
* <p>
*
* <pre>
* <simpleType name="Incoterm">
* <restriction base="{http://www.w3.org/2001/XMLSchema}token">
* <enumeration value="EXW"/>
* <enumeration value="FCA"/>
* <enumeration value="FCA2"/>
* <enumeration value="FAS"/>
* <enumeration value="FOB"/>
* <enumeration value="CFR"/>
* <enumeration value="CIF"/>
* <enumeration value="CPT"/>
* <enumeration value="CIP"/>
* <enumeration value="DAF"/>
* <enumeration value="DES"/>
* <enumeration value="DEQ"/>
* <enumeration value="DDU"/>
* <enumeration value="DDP"/>
* </restriction>
* </simpleType>
* </pre>
* <p>
* Example: <incoterm code="EXW" name="Ex Works" /> <incoterm code="FCA"
* name="Free Carrier" /> <incoterm code="FCA2" name="Free Carrier" />
*/
@Entity
@Table(name = "incoterm", uniqueConstraints = {@UniqueConstraint(columnNames = {"code"})})
@NamedQueries({
@NamedQuery(name = "incoterm.byCostingContextAndOrgUnitAssociatedToCostSetup",
query = "from Incoterm i where i in (select distinct incoterm from CostDefinition where costingContextType = :costingContextType "
+ "and organisationalUnit = :organisationalUnit and costableCostDefinition='f' and active='t')"),
@NamedQuery(name = "incoterm.byCostingContextAssociatedToCostSetup",
query = "from Incoterm i where i in (select distinct incoterm from CostDefinition where costingContextType = :costingContextType " +
"and costableCostDefinition='f' and active='t') order by i.code desc"),
@NamedQuery(name = "incoterm.byActiveIncoTerm",
query = "from Incoterm i where i.active=true")})
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Incoterm")
//@Cacheable(value = "incoterm")
public class Incoterm extends IntegratedStaticDataEntityBase {
/**
* UID.
*/
private static final long serialVersionUID = -2886804756569893010L;
private static final short INCOTERM_CODE_SIZE = 3;
private static final short INCOTERM_CODE_SIZE_ALT = 4;
public Incoterm(String code, String name) {
if (code.length() == INCOTERM_CODE_SIZE || code.length() == INCOTERM_CODE_SIZE_ALT) {
setCode(code);
setName(name);
} else {
throw new IllegalArgumentException("Incoterm code must be of length: " + INCOTERM_CODE_SIZE + " or " + INCOTERM_CODE_SIZE_ALT);
}
}
public Incoterm(String code) {
super(code, null);
}
public Incoterm() {
}
public static Incoterm findClosestIncoterm(Incoterm targetIncoterm, List<Incoterm> incoterms, boolean b, boolean c) {
// TODO Auto-generated method stub
return null;
}
@Override
public String toString() {
return getCode() + " (" + getName() + ")";
}
}