FreightRate.java
package com.tradecloud.domain.rate;
import com.tradecloud.domain.container.ContainerType;
import com.tradecloud.domain.model.organisationalunit.OrganisationalUnit;
import com.tradecloud.domain.model.shipment.ShippingMode;
import com.tradecloud.domain.party.ServiceProvider;
import com.tradecloud.domain.place.Country;
import com.tradecloud.domain.place.PlaceOfDischarge;
import com.tradecloud.domain.place.PlaceOfLoading;
import lombok.Getter;
import lombok.Setter;
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.XmlRootElement;
import java.math.BigDecimal;
@Entity
@Table(name = "freightrate")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "FreightRate")
@Getter
@Setter
public class FreightRate extends Rate implements MinMaxRate, CompanyRate {
@NotNull
@Basic(optional = false)
@Enumerated(EnumType.STRING)
private ShippingMode shippingMode;
@Enumerated(EnumType.STRING)
private ShippingMode multiModalShippingMode;
@ManyToOne
private ContainerType containerType;
@ManyToOne
private PlaceOfLoading placeOfLoading;
@ManyToOne
private PlaceOfDischarge placeOfDischarge;
@ManyToOne
private ServiceProvider freightForwarder;
@ManyToOne
private ServiceProvider carrier;
@ManyToOne
private Country country;
@ManyToOne
private OrganisationalUnit company;
private BigDecimal weightFrom;
private BigDecimal weightTo;
private BigDecimal minValue;
private BigDecimal maxValue;
public ContainerType getContainerType() {
return containerType;
}
public void setContainerType(ContainerType containerType) {
this.containerType = containerType;
}
public ShippingMode getShippingMode() {
return shippingMode;
}
public void setShippingMode(ShippingMode shippingMode) {
this.shippingMode = shippingMode;
}
public PlaceOfLoading getPlaceOfLoading() {
return placeOfLoading;
}
public void setPlaceOfLoading(PlaceOfLoading placeOfLoading) {
this.placeOfLoading = placeOfLoading;
}
public PlaceOfDischarge getPlaceOfDischarge() {
return placeOfDischarge;
}
public void setPlaceOfDischarge(PlaceOfDischarge placeOfDischarge) {
this.placeOfDischarge = placeOfDischarge;
}
public ServiceProvider getFreightForwarder() {
return freightForwarder;
}
public void setFreightForwarder(ServiceProvider lsp) {
this.freightForwarder = lsp;
}
public Country getCountry() {
return country;
}
public void setCountry(Country country) {
this.country = country;
}
public ServiceProvider getCarrier() {
return carrier;
}
public void setCarrier(ServiceProvider carrier) {
this.carrier = carrier;
}
@Override
public String toString() {
String toReturn = super.toString();
String shippingModeStr = "Shipping Mode: '" + shippingMode + "', ";
String containerTypeStr = "Container Type: '" +
(containerType != null ? containerType.getName() : "") + "', ";
String placeOfLoadingStr = "Place of Loading: '" +
(placeOfLoading != null ? placeOfLoading.getName() : "") + "', ";
String placeOfDischargeStr = "Place of Discharge: '" +
(placeOfDischarge != null ? placeOfDischarge.getName() : "") + "', ";
String freightForwarderStr = "Freight Forwarder: '" +
(freightForwarder != null ? freightForwarder.getName() : "") + "', ";
String carrierStr = "Carrier: '" + (carrier != null ? carrier.getName() : "") + "', ";
String countryStr = "Country: '" + (country != null ? country.getName() : "") + "', ";
String weightF = "WeightFrom: '" + (weightFrom != null ? weightFrom : "") + "' ,";
String weightT = "WeightTo: '" + (weightTo != null ? weightTo : "") + "' ,";
String minimum = "minimum: '" + (minValue != null ? minValue : "") + "' ,";
String maximun = "maximun: '" + (maxValue != null ? maxValue : "") + "' ,";
String organisationalUnitStr = "Organisational Unit: '" + (getOrganisationalUnit() != null ? getOrganisationalUnit().getName() : "") + "',";
toReturn += shippingModeStr + containerTypeStr + placeOfLoadingStr +
placeOfDischargeStr + freightForwarderStr + carrierStr + countryStr + weightF + weightT + minimum + maximun + organisationalUnitStr;
return toReturn;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null)
return false;
if (!(obj instanceof FreightRate)) {
return false;
}
if (!super.equals(obj))
return false;
FreightRate other = (FreightRate) obj;
if (other.getShippingMode() == shippingMode
&& objectsEqual(containerType, other.getContainerType())
&& objectsEqual(placeOfDischarge, other.getPlaceOfDischarge())
&& objectsEqual(placeOfLoading, other.getPlaceOfLoading())
&& objectsEqual(freightForwarder, other.getFreightForwarder())
&& objectsEqual(carrier, other.getCarrier())
&& objectsEqual(country, other.getCountry())
&& objectsEqual(weightFrom, other.getWeightFrom())
&& objectsEqual(weightTo, other.getWeightTo())
&& objectsEqual(minValue, other.getMinValue())
&& objectsEqual(maxValue, other.getMaxValue())
&& objectsEqual(getOrganisationalUnit(), other.getOrganisationalUnit())
&& objectsEqual(company, other.getCompany())
)
return true;
return false;
}
public BigDecimal getWeightFrom() {
return weightFrom;
}
public void setWeightFrom(BigDecimal weightFrom) {
this.weightFrom = weightFrom;
}
public BigDecimal getWeightTo() {
return weightTo;
}
public void setWeightTo(BigDecimal weightTo) {
this.weightTo = weightTo;
}
public BigDecimal getMinValue() {
return minValue;
}
public void setMinValue(BigDecimal minValue) {
this.minValue = minValue;
}
public BigDecimal getMaxValue() {
return maxValue;
}
public void setMaxValue(BigDecimal maxValue) {
this.maxValue = maxValue;
}
}