private void getCustomerOptions( Model model, Customer customer, MerchantStore store, Language language) throws Exception { Map<Long, CustomerOption> options = new HashMap<Long, CustomerOption>(); // get options List<CustomerOptionSet> optionSet = customerOptionSetService.listByStore(store, language); if (!CollectionUtils.isEmpty(optionSet)) { CustomerOptionPopulator optionPopulator = new CustomerOptionPopulator(); Set<CustomerAttribute> customerAttributes = customer.getAttributes(); for (CustomerOptionSet optSet : optionSet) { com.wms.core.business.customer.model.attribute.CustomerOption custOption = optSet.getCustomerOption(); if (!custOption.isActive()) { continue; } CustomerOption customerOption = options.get(custOption.getId()); optionPopulator.setOptionSet(optSet); if (customerOption == null) { customerOption = new CustomerOption(); customerOption.setId(custOption.getId()); customerOption.setType(custOption.getCustomerOptionType()); customerOption.setName(custOption.getDescriptionsSettoList().get(0).getName()); } optionPopulator.populate(custOption, customerOption, store, language); options.put(customerOption.getId(), customerOption); if (!CollectionUtils.isEmpty(customerAttributes)) { for (CustomerAttribute customerAttribute : customerAttributes) { if (customerAttribute.getCustomerOption().getId().longValue() == customerOption.getId()) { CustomerOptionValue selectedValue = new CustomerOptionValue(); com.wms.core.business.customer.model.attribute.CustomerOptionValue attributeValue = customerAttribute.getCustomerOptionValue(); selectedValue.setId(attributeValue.getId()); CustomerOptionValueDescription optValue = attributeValue.getDescriptionsSettoList().get(0); selectedValue.setName(optValue.getName()); customerOption.setDefaultValue(selectedValue); if (customerOption.getType().equalsIgnoreCase(CustomerOptionType.Text.name())) { selectedValue.setName(customerAttribute.getTextValue()); } } } } } } model.addAttribute("options", options.values()); }