Search in sources :

Example 1 with Phone

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);
}
Also used : State(org.broadleafcommerce.profile.core.domain.State) Phone(org.broadleafcommerce.profile.core.domain.Phone) Country(org.broadleafcommerce.profile.core.domain.Country) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) CountrySubdivision(org.broadleafcommerce.profile.core.domain.CountrySubdivision) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry)

Example 2 with Phone

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);
        }
    }
}
Also used : Phone(org.broadleafcommerce.profile.core.domain.Phone)

Example 3 with Phone

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 } };
}
Also used : PhoneNameForm(org.broadleafcommerce.profile.web.core.model.PhoneNameForm) Phone(org.broadleafcommerce.profile.core.domain.Phone) PhoneImpl(org.broadleafcommerce.profile.core.domain.PhoneImpl) DataProvider(org.testng.annotations.DataProvider)

Example 4 with Phone

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 } };
}
Also used : CustomerPhone(org.broadleafcommerce.profile.core.domain.CustomerPhone) Phone(org.broadleafcommerce.profile.core.domain.Phone) CustomerPhone(org.broadleafcommerce.profile.core.domain.CustomerPhone) CustomerPhoneImpl(org.broadleafcommerce.profile.core.domain.CustomerPhoneImpl) CustomerPhoneImpl(org.broadleafcommerce.profile.core.domain.CustomerPhoneImpl) PhoneImpl(org.broadleafcommerce.profile.core.domain.PhoneImpl) DataProvider(org.testng.annotations.DataProvider)

Example 5 with Phone

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);
    }
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) Phone(org.broadleafcommerce.profile.core.domain.Phone)

Aggregations

Phone (org.broadleafcommerce.profile.core.domain.Phone)10 PhoneImpl (org.broadleafcommerce.profile.core.domain.PhoneImpl)7 ISOCountry (org.broadleafcommerce.common.i18n.domain.ISOCountry)4 Country (org.broadleafcommerce.profile.core.domain.Country)4 State (org.broadleafcommerce.profile.core.domain.State)4 Address (org.broadleafcommerce.profile.core.domain.Address)3 Customer (org.broadleafcommerce.profile.core.domain.Customer)3 ISOCountryImpl (org.broadleafcommerce.common.i18n.domain.ISOCountryImpl)2 Money (org.broadleafcommerce.common.money.Money)2 Category (org.broadleafcommerce.core.catalog.domain.Category)2 CategoryImpl (org.broadleafcommerce.core.catalog.domain.CategoryImpl)2 CategoryProductXref (org.broadleafcommerce.core.catalog.domain.CategoryProductXref)2 CategoryProductXrefImpl (org.broadleafcommerce.core.catalog.domain.CategoryProductXrefImpl)2 Product (org.broadleafcommerce.core.catalog.domain.Product)2 ProductImpl (org.broadleafcommerce.core.catalog.domain.ProductImpl)2 Sku (org.broadleafcommerce.core.catalog.domain.Sku)2 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)2 PromotableOrder (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder)2 PromotableOrderImpl (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderImpl)2 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)2