use of org.broadleafcommerce.profile.core.domain.State in project BroadleafCommerce by BroadleafCommerce.
the class CheckoutTest method buildAddress.
private Address buildAddress() {
Address address = new AddressImpl();
address.setAddressLine1("123 Test Rd");
address.setCity("Dallas");
address.setFirstName("Jeff");
address.setLastName("Fischer");
address.setPostalCode("75240");
address.setPrimaryPhone("972-978-9067");
State state = new StateImpl();
state.setAbbreviation("ALL");
state.setName("ALL");
address.setState(state);
Country country = new CountryImpl();
country.setAbbreviation("US");
country.setName("United States");
state.setCountry(country);
address.setCountry(country);
ISOCountry isoCountry = new ISOCountryImpl();
isoCountry.setAlpha2("US");
isoCountry.setName("UNITED STATES");
address.setIsoCountryAlpha2(isoCountry);
return address;
}
use of org.broadleafcommerce.profile.core.domain.State in project BroadleafCommerce by BroadleafCommerce.
the class PaymentResponseDTOToEntityServiceImpl method populateAddressInfo.
@Override
public void populateAddressInfo(AddressDTO<PaymentResponseDTO> dto, Address address) {
address.setFirstName(dto.getAddressFirstName());
address.setLastName(dto.getAddressLastName());
address.setFullName(dto.getAddressFullName());
address.setAddressLine1(dto.getAddressLine1());
address.setAddressLine2(dto.getAddressLine2());
address.setCity(dto.getAddressCityLocality());
State state = null;
if (dto.getAddressStateRegion() != null) {
state = stateService.findStateByAbbreviation(dto.getAddressStateRegion());
}
if (state == null) {
LOG.warn("The given state from the response: " + StringUtil.sanitize(dto.getAddressStateRegion()) + " could not be found" + " as a state abbreviation in BLC_STATE");
}
address.setState(state);
CountrySubdivision isoCountrySub = countrySubdivisionService.findSubdivisionByAbbreviation(dto.getAddressStateRegion());
if (isoCountrySub != null) {
address.setIsoCountrySubdivision(isoCountrySub.getAbbreviation());
address.setStateProvinceRegion(isoCountrySub.getName());
} else {
// Integration does not conform to the ISO Code standard - just set the non-referential state province region
address.setStateProvinceRegion(dto.getAddressStateRegion());
}
address.setPostalCode(dto.getAddressPostalCode());
Country country = null;
ISOCountry isoCountry = null;
if (dto.getAddressCountryCode() != null) {
country = countryService.findCountryByAbbreviation(dto.getAddressCountryCode());
isoCountry = isoService.findISOCountryByAlpha2Code(dto.getAddressCountryCode());
}
if (country == null) {
LOG.warn("The given country from the response: " + StringUtil.sanitize(dto.getAddressCountryCode()) + " could not be found" + " as a country abbreviation in BLC_COUNTRY");
} else if (isoCountry == null) {
LOG.error("The given country from the response: " + StringUtil.sanitize(dto.getAddressCountryCode()) + " could not be found" + " as a country alpha-2 code in BLC_ISO_COUNTRY");
}
address.setCountry(country);
address.setIsoCountryAlpha2(isoCountry);
if (dto.getAddressPhone() != null) {
Phone billingPhone = phoneService.create();
billingPhone.setPhoneNumber(dto.getAddressPhone());
address.setPhonePrimary(billingPhone);
}
if (dto.getAddressEmail() != null) {
address.setEmailAddress(dto.getAddressEmail());
}
if (dto.getAddressCompanyName() != null) {
address.setCompanyName(dto.getAddressCompanyName());
}
addressService.populateAddressISOCountrySub(address);
}
use of org.broadleafcommerce.profile.core.domain.State in project BroadleafCommerce by BroadleafCommerce.
the class OfferTest method createFulfillmentGroups.
private List<FulfillmentGroup> createFulfillmentGroups(FulfillmentOption option, Double shippingPrice, Order order) {
List<FulfillmentGroup> groups = new ArrayList<FulfillmentGroup>();
FulfillmentGroup group = new FulfillmentGroupImpl();
group.setFulfillmentOption(option);
groups.add(group);
group.setRetailShippingPrice(new Money(shippingPrice));
group.setOrder(order);
Address address = new AddressImpl();
address.setAddressLine1("123 Test Rd");
address.setCity("Dallas");
address.setFirstName("Jeff");
address.setLastName("Fischer");
address.setPostalCode("75240");
address.setPrimaryPhone("972-978-9067");
Country country = new CountryImpl();
country.setAbbreviation("US");
country.setName("United States");
countryService.save(country);
ISOCountry isoCountry = new ISOCountryImpl();
isoCountry.setAlpha2("US");
isoCountry.setName("UNITED STATES");
isoService.save(isoCountry);
State state = new StateImpl();
state.setAbbreviation("TX");
state.setName("Texas");
state.setCountry(country);
stateService.save(state);
address.setState(state);
address.setCountry(country);
address.setIsoCountrySubdivision("US-TX");
address.setIsoCountryAlpha2(isoCountry);
for (OrderItem orderItem : order.getOrderItems()) {
FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
fgItem.setFulfillmentGroup(group);
fgItem.setOrderItem(orderItem);
fgItem.setQuantity(orderItem.getQuantity());
group.addFulfillmentGroupItem(fgItem);
}
group.setAddress(address);
return groups;
}
use of org.broadleafcommerce.profile.core.domain.State in project BroadleafCommerce by BroadleafCommerce.
the class CommonSetupBaseTest method createState.
public void createState() {
State state = new StateImpl();
state.setAbbreviation("KY");
state.setName("Kentucky");
state.setCountry(countryService.findCountryByAbbreviation("US"));
stateService.save(state);
}
use of org.broadleafcommerce.profile.core.domain.State in project BroadleafCommerce by BroadleafCommerce.
the class CommonSetupBaseTest method saveCustomerAddress.
/**
* Saves a customerAddress with state KY and country US. Requires that createCountry() and createState() have been called
* @param customerAddress
*/
public CustomerAddress saveCustomerAddress(CustomerAddress customerAddress) {
State state = stateService.findStateByAbbreviation("KY");
customerAddress.getAddress().setState(state);
Country country = countryService.findCountryByAbbreviation("US");
customerAddress.getAddress().setCountry(country);
customerAddress.getAddress().setIsoCountrySubdivision("US-KY");
ISOCountry isoCountry = isoService.findISOCountryByAlpha2Code("US");
customerAddress.getAddress().setIsoCountryAlpha2(isoCountry);
return customerAddressService.saveCustomerAddress(customerAddress);
}
Aggregations