use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method getCustomerModel.
@Override
public Customer getCustomerModel(final PersistableCustomer customer, final MerchantStore merchantStore, Language language) throws Exception {
LOG.info("Starting to populate customer model from customer data");
Customer customerModel = null;
customerModel = customerPopulator.populate(customer, merchantStore, language);
// we are creating or resetting a customer
if (StringUtils.isBlank(customerModel.getPassword()) && !StringUtils.isBlank(customer.getPassword())) {
customerModel.setPassword(customer.getPassword());
}
// set groups
if (!StringUtils.isBlank(customerModel.getPassword()) && !StringUtils.isBlank(customerModel.getNick())) {
customerModel.setPassword(passwordEncoder.encode(customer.getPassword()));
setCustomerModelDefaultProperties(customerModel, merchantStore);
}
return customerModel;
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method deleteById.
@Override
public void deleteById(Long id) {
Customer customer = getCustomerById(id);
delete(customer);
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method update.
@Override
public PersistableCustomer update(PersistableCustomer customer, MerchantStore store) {
if (customer.getId() == null || customer.getId() == 0) {
throw new ServiceRuntimeException("Can't update a customer with null id");
}
Customer cust = customerService.getById(customer.getId());
try {
customerPopulator.populate(customer, cust, store, store.getDefaultLanguage());
} catch (ConversionException e) {
throw new ConversionRuntimeException(e);
}
String password = customer.getPassword();
if (StringUtils.isBlank(password)) {
password = new String(UUID.generateRandomBytes());
customer.setPassword(password);
}
saveCustomer(cust);
customer.setId(cust.getId());
return customer;
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method create.
@Override
public ReadableCustomer create(PersistableCustomer customer, MerchantStore store, Language language) {
Validate.notNull(customer, "Customer cannot be null");
Validate.notNull(customer.getEmailAddress(), "Customer email address is required");
// set customer user name
customer.setUserName(customer.getEmailAddress());
if (userExist(customer.getUserName())) {
throw new ServiceRuntimeException("User already exist");
}
// end user exists
Customer customerToPopulate = convertPersistableCustomerToCustomer(customer, store);
try {
setCustomerModelDefaultProperties(customerToPopulate, store);
} catch (Exception e) {
throw new ServiceRuntimeException("Cannot set default customer properties", e);
}
saveCustomer(customerToPopulate);
customer.setId(customerToPopulate.getId());
notifyNewCustomer(customer, store, customerToPopulate.getDefaultLanguage());
// convert to readable
return convertCustomerToReadableCustomer(customerToPopulate, store, language);
}
use of com.salesmanager.core.model.customer.Customer in project shopizer by shopizer-ecommerce.
the class CustomerFacadeImpl method updateAuthCustomer.
private PersistableCustomer updateAuthCustomer(PersistableCustomer customer, MerchantStore store) {
if (customer.getId() == null || customer.getId() == 0) {
throw new ServiceRuntimeException("Can't update a customer with null id");
}
Customer cust = customerService.getById(customer.getId());
try {
customerPopulator.populate(customer, cust, store, store.getDefaultLanguage());
} catch (ConversionException e) {
throw new ConversionRuntimeException(e);
}
saveCustomer(cust);
customer.setId(cust.getId());
return customer;
}
Aggregations