ShippingInformation.java

package com.tradecloud.domain.shipment;

import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.common.Incoterm;
import com.tradecloud.domain.model.shipment.ShippingMode;
import com.tradecloud.domain.party.ServiceProvider;
import com.tradecloud.domain.place.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ForeignKey;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;

@Entity
@Table(name = "shippinginformation")
@Getter
@Setter
public class ShippingInformation extends PersistenceBase implements BaseShippingInfo {

    private static final long serialVersionUID = 1L;

    @XmlAttribute
    private Boolean partShipment = false;

    @XmlAttribute
    private Boolean transShipment = false;

    /**
     * The reference used by the LSP to track an order.
     */
    @XmlAttribute
    private String shippingReference;

    /**
     * The shipping mode that will be used to deliver the order. This should
     * default to the shipping mode configured in the client setup.
     */
    @Enumerated(value = EnumType.STRING)
    @XmlAttribute
    private ShippingMode shippingMode;

    @Enumerated(EnumType.STRING)
    private ShippingMode multiModalShippingMode;

    @XmlElement(name = "Incoterm")
    @ManyToOne
    private Incoterm incoterm;

    @XmlElement(name = "RouteType")
    @Enumerated(value = EnumType.STRING)
    private RouteType routeType;
    /**
     * The place where the order is loaded. This should default to the place of
     * loading configured in the client setup.
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @XmlElement(name = "PlaceOfLoading")
    private PlaceOfLoading placeOfLoading;

    /**
     * The place where the order is discharged. This should default to the place
     * of discharge configured in the client setup.
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @XmlElement(name = "PlaceOfDischarge")
    private PlaceOfDischarge placeOfDischarge;

    /**
     * The country the order originates from. This should default to the country
     * of origin configured in the client setup.
     */
    @ManyToOne
    @XmlElement(name = "CountryOfOrigin")
    private Country countryOfOrigin;

    /**
     * Generated Booking Request & Response DTOs
     * The country the order exports from.
     */
    @ManyToOne
    @XmlElement(name = "CountryOfExport")
    private Country countryOfExport;

    /*
     * TODO: Should this be a City?!
     */
    /**
     * The depot where the order is cleared. No default.
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @XmlElement(name = "ClearingDepot")
    private Depot clearingDepot;

    /*
     * TODO: Is this used? Not on rebox screen.
     */
    /**
     * The depot that the order is forwarded to.
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @XmlElement(name = "ForwardingDepot")
    private Depot forwardingDepot;

    /**
     * A place where this order will be delivered. This should default to the
     * named place configured in client setup.
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @XmlElement(name = "NamedPlace")
    private NamedPlace namedPlace;

    /**
     * The final destination for the order. No default.
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotNull(message = "Final Destination is required")
    @XmlElement(name = "FinalDestination", required = true)
    private FinalDestination finalDestination;

    /**
     * The freight forwarder responsible for the order. This should default to
     * the the supplier's freight forwarder. If there is no freight forwarder
     * provided for the supplier then the freight forwarder configured in the
     * client setup will be used.
     */
    @XmlElement(name = "FreightForwarder")
    @ManyToOne(fetch = FetchType.LAZY)
    @ForeignKey(name = "fk_freightforwarder")
    private ServiceProvider freightForwarder;

    /**
     * The agent who will be responsible for clearing the goods. This should
     * default to the the supplier's clearing agent. If there is no clearing
     * agent provided for the supplier then the clearing agent configured in the
     * client setup will be used.
     */
    @XmlElement(name = "ClearingAgent")
    @ManyToOne(fetch = FetchType.LAZY)
    @ForeignKey(name = "fk_clearingagent")
    private ServiceProvider clearingAgent;

    /**
     * The transporter who will transport the goods to the final destination.
     * This should default to the the supplier's transporter. If there is no
     * transporter provided for the supplier then the transporter configured in
     * the client setup will be used.
     */
    @XmlElement(name = "Transporter")
    @ManyToOne(fetch = FetchType.LAZY)
    @ForeignKey(name = "fk_transporter")
    private ServiceProvider transporter;

    @XmlElement(name = "ForexProvider")
    @ManyToOne(fetch = FetchType.LAZY)
    @ForeignKey(name = "fk_forexProvider")
    private ServiceProvider forexProvider;

    @XmlElement(name = "FinanceProvider")
    @ManyToOne(fetch = FetchType.LAZY)
    @ForeignKey(name = "fk_financeProvider")
    private ServiceProvider financeProvider;

    @XmlElement(name = "Reseller")
    @ManyToOne(fetch = FetchType.LAZY)
    @ForeignKey(name = "fk_reseller")
    private ServiceProvider reseller;

    public ShippingInformation() {
    }

    public RouteType getRouteType() {
        return routeType;
    }

    public void setRouteType(RouteType routeType) {
        this.routeType = routeType;
    }

    public String getShippingReference() {
        return shippingReference;
    }

    public void setShippingReference(String shippingReference) {
        this.shippingReference = shippingReference;
    }

    public Depot getClearingDepot() {
        return clearingDepot;
    }

    public void setClearingDepot(Depot clearingDepot) {
        this.clearingDepot = clearingDepot;
    }

    public FinalDestination getFinalDestination() {
        return finalDestination;
    }

    public void setFinalDestination(FinalDestination finalDestination) {
        this.finalDestination = finalDestination;
    }

    public Depot getForwardingDepot() {
        return forwardingDepot;
    }

    public void setForwardingDepot(Depot forwardingDepot) {
        this.forwardingDepot = forwardingDepot;
    }

    public Country getCountryOfOrigin() {
        return countryOfOrigin;
    }

    public void setCountryOfOrigin(Country countryOfOrigin) {
        this.countryOfOrigin = countryOfOrigin;
    }

    @Override
    public PlaceOfLoading getPlaceOfLoading() {
        return placeOfLoading;
    }

    @Override
    public void setPlaceOfLoading(PlaceOfLoading placeOfLoading) {
        this.placeOfLoading = placeOfLoading;
    }

    @Override
    public PlaceOfDischarge getPlaceOfDischarge() {
        return placeOfDischarge;
    }

    @Override
    public void setPlaceOfDischarge(PlaceOfDischarge placeOfDischarge) {
        this.placeOfDischarge = placeOfDischarge;
    }

    public Boolean getPartShipment() {
        return partShipment;
    }

    public void setPartShipment(Boolean partShipment) {
        this.partShipment = partShipment;
    }

    public Boolean getTransShipment() {
        return transShipment;
    }

    public void setTransShipment(Boolean transShipment) {
        this.transShipment = transShipment;
    }

    @Override
    public ShippingMode getShippingMode() {
        return shippingMode;
    }

    @Override
    public void setShippingMode(ShippingMode shippingMode) {
        this.shippingMode = shippingMode;
    }

    public NamedPlace getNamedPlace() {
        return namedPlace;
    }

    public void setNamedPlace(NamedPlace namedPlace) {
        this.namedPlace = namedPlace;
    }

    @Override
    public ServiceProvider getFreightForwarder() {
        return freightForwarder;
    }

    @Override
    public void setFreightForwarder(ServiceProvider freightForwarder) {
        this.freightForwarder = freightForwarder;
    }

    @Override
    public ServiceProvider getClearingAgent() {
        return clearingAgent;
    }

    @Override
    public void setClearingAgent(ServiceProvider clearingAgent) {
        this.clearingAgent = clearingAgent;
    }

    public ServiceProvider getTransporter() {
        return transporter;
    }

    public void setTransporter(ServiceProvider transporter) {
        this.transporter = transporter;
    }

    /*
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("partShipment=").append(partShipment).append(",transShipment=").append(transShipment).append(",shippingReference=")
                .append(shippingReference).append(",shippingMode=").append(shippingMode).append(",placeOfLoading=").append(placeOfLoading)
                .append(",placeOfDischarge=").append(placeOfDischarge).append(",countryOfOrigin=").append(countryOfOrigin).append(",clearingDepot=")
                .append(clearingDepot).append(",forwardingDepot=").append(forwardingDepot).append(",namedPlace=").append(namedPlace)
                .append(",finalDestination=").append(finalDestination).append(",freightForwarder=").append(freightForwarder)
                .append(",clearingAgent=").append(clearingAgent).append(",transporter=").append(transporter);
        return sb.toString();
    }
    */

    @Override
    public Incoterm getIncoterm() {
        return incoterm;
    }

    @Override
    public void setIncoterm(Incoterm incoterm) {
        this.incoterm = incoterm;
    }

    public Country getCountryOfExport() {
        return countryOfExport;
    }

    public void setCountryOfExport(Country countryOfExport) {
        this.countryOfExport = countryOfExport;
    }

    /**
     * The transporter who will transport the goods to the final destination.
     * This should default to the the supplier's transporter. If there is no
     * transporter provided for the supplier then the transporter configured in
     * the client setup will be used.
     */
    public ServiceProvider getForexProvider() {
        return forexProvider;
    }

    public void setForexProvider(ServiceProvider forexProvider) {
        this.forexProvider = forexProvider;
    }

    /**
     * The transporter who will transport the goods to the final destination.
     * This should default to the the supplier's transporter. If there is no
     * transporter provided for the supplier then the transporter configured in
     * the client setup will be used.
     */
    public ServiceProvider getFinanceProvider() {
        return financeProvider;
    }

    public void setFinanceProvider(ServiceProvider financeProvider) {
        this.financeProvider = financeProvider;
    }

    /**
     * The transporter who will transport the goods to the final destination.
     * This should default to the the supplier's transporter. If there is no
     * transporter provided for the supplier then the transporter configured in
     * the client setup will be used.
     */
    public ServiceProvider getReseller() {
        return reseller;
    }

    public void setReseller(ServiceProvider reseller) {
        this.reseller = reseller;
    }
}