Search in sources :

Example 1 with CustomerDeliveryAddressPopulator

use of com.salesmanager.shop.populator.customer.CustomerDeliveryAddressPopulator in project shopizer by shopizer-ecommerce.

the class CustomerFacadeImpl method getAddress.

@Override
public Address getAddress(Long userId, final MerchantStore merchantStore, boolean isBillingAddress) throws Exception {
    LOG.info("Fetching customer for id {} ", userId);
    Address address = null;
    final Customer customerModel = customerService.getById(userId);
    if (customerModel == null) {
        LOG.error("Customer with ID {} does not exists..", userId);
        // throw new CustomerNotFoundException( "customer with given id does not exists" );
        throw new Exception("customer with given id does not exists");
    }
    if (isBillingAddress) {
        LOG.info("getting billing address..");
        CustomerBillingAddressPopulator billingAddressPopulator = new CustomerBillingAddressPopulator();
        address = billingAddressPopulator.populate(customerModel, merchantStore, merchantStore.getDefaultLanguage());
        address.setBillingAddress(true);
        return address;
    }
    LOG.info("getting Delivery address..");
    CustomerDeliveryAddressPopulator deliveryAddressPopulator = new CustomerDeliveryAddressPopulator();
    return deliveryAddressPopulator.populate(customerModel, merchantStore, merchantStore.getDefaultLanguage());
}
Also used : Address(com.salesmanager.shop.model.customer.address.Address) ReadableCustomer(com.salesmanager.shop.model.customer.ReadableCustomer) Customer(com.salesmanager.core.model.customer.Customer) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) CustomerDeliveryAddressPopulator(com.salesmanager.shop.populator.customer.CustomerDeliveryAddressPopulator) CustomerBillingAddressPopulator(com.salesmanager.shop.populator.customer.CustomerBillingAddressPopulator) PersistableCustomerBillingAddressPopulator(com.salesmanager.shop.populator.customer.PersistableCustomerBillingAddressPopulator) ServiceException(com.salesmanager.core.business.exception.ServiceException) UserAlreadyExistException(com.salesmanager.shop.model.customer.UserAlreadyExistException) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ConversionException(com.salesmanager.core.business.exception.ConversionException)

Aggregations

ConversionException (com.salesmanager.core.business.exception.ConversionException)1 ServiceException (com.salesmanager.core.business.exception.ServiceException)1 Customer (com.salesmanager.core.model.customer.Customer)1 PersistableCustomer (com.salesmanager.shop.model.customer.PersistableCustomer)1 ReadableCustomer (com.salesmanager.shop.model.customer.ReadableCustomer)1 UserAlreadyExistException (com.salesmanager.shop.model.customer.UserAlreadyExistException)1 Address (com.salesmanager.shop.model.customer.address.Address)1 CustomerBillingAddressPopulator (com.salesmanager.shop.populator.customer.CustomerBillingAddressPopulator)1 CustomerDeliveryAddressPopulator (com.salesmanager.shop.populator.customer.CustomerDeliveryAddressPopulator)1 PersistableCustomerBillingAddressPopulator (com.salesmanager.shop.populator.customer.PersistableCustomerBillingAddressPopulator)1 ConversionRuntimeException (com.salesmanager.shop.store.api.exception.ConversionRuntimeException)1 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)1 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)1