use of org.broadleafcommerce.profile.core.domain.Phone 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.Phone in project BroadleafCommerce by BroadleafCommerce.
the class PhoneValidator method validate.
public void validate(Object obj, Errors errors) {
// use regular phone
Phone phone = (Phone) obj;
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "phoneNumber", "phone.required", new Object[] { phone });
if (!errors.hasErrors()) {
String phoneNumber = phone.getPhoneNumber();
String newString = phoneNumber.replaceAll("\\D", "");
if (newString.length() != 10) {
errors.rejectValue("phoneNumber", "phone.ten_digits_required", null);
}
// Check for common false data.
if (newString.equals("1234567890") || newString.equals("0123456789") || newString.matches("0{10}") || newString.matches("1{10}") || newString.matches("2{10}") || newString.matches("3{10}") || newString.matches("4{10}") || newString.matches("5{10}") || newString.matches("6{10}") || newString.matches("7{10}") || newString.matches("8{10}") || newString.matches("9{10}")) {
errors.rejectValue("phoneNumber", "phone.invalid", null);
}
}
}
use of org.broadleafcommerce.profile.core.domain.Phone in project BroadleafCommerce by BroadleafCommerce.
the class CustomerPhoneControllerTestDataProvider method createCustomerPhone.
@DataProvider(name = "setupCustomerPhoneControllerData")
public static Object[][] createCustomerPhone() {
PhoneNameForm pnf1 = new PhoneNameForm();
Phone phone1 = new PhoneImpl();
phone1.setPhoneNumber("111-222-3333");
pnf1.setPhone(phone1);
pnf1.setPhoneName("phone_1");
PhoneNameForm pnf2 = new PhoneNameForm();
Phone phone2 = new PhoneImpl();
phone2.setPhoneNumber("222-333-4444");
pnf2.setPhone(phone2);
pnf2.setPhoneName("phone_2");
return new Object[][] { new Object[] { pnf1 }, new Object[] { pnf2 } };
}
use of org.broadleafcommerce.profile.core.domain.Phone in project BroadleafCommerce by BroadleafCommerce.
the class CustomerPhoneDataProvider method createCustomerPhone.
@DataProvider(name = "setupCustomerPhone")
public static Object[][] createCustomerPhone() {
CustomerPhone cp1 = new CustomerPhoneImpl();
Phone phone1 = new PhoneImpl();
phone1.setPhoneNumber("111-111-1111");
cp1.setPhone(phone1);
cp1.setPhoneName("phone1");
CustomerPhone cp2 = new CustomerPhoneImpl();
Phone phone2 = new PhoneImpl();
phone1.setPhoneNumber("222-222-2222");
cp2.setPhone(phone2);
cp2.setPhoneName("phone2");
return new Object[][] { new Object[] { cp1 }, new Object[] { cp2 } };
}
use of org.broadleafcommerce.profile.core.domain.Phone in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafShippingInfoController method removeUnusedPhones.
public void removeUnusedPhones(ShippingInfoForm form) {
Address address = form.getAddress();
Phone primaryPhone = address.getPhonePrimary();
Phone secondaryPhone = address.getPhoneSecondary();
Phone faxPhone = address.getPhoneFax();
if ((primaryPhone != null) && (StringUtils.isEmpty(primaryPhone.getPhoneNumber()))) {
address.setPhonePrimary(null);
}
if ((secondaryPhone != null) && (StringUtils.isEmpty(secondaryPhone.getPhoneNumber()))) {
address.setPhoneSecondary(null);
}
if ((faxPhone != null) && (StringUtils.isEmpty(faxPhone.getPhoneNumber()))) {
address.setPhoneFax(null);
}
}
Aggregations