use of com.salesmanager.shop.model.store.PersistableBrand in project shopizer by shopizer-ecommerce.
the class StoreFacadeImpl method createBrand.
@Override
public void createBrand(String merchantStoreCode, PersistableBrand brand) {
MerchantStore mStore = getMerchantStoreByCode(merchantStoreCode);
List<MerchantConfigEntity> createdConfigs = brand.getSocialNetworks();
List<MerchantConfiguration> configurations = createdConfigs.stream().map(config -> convertToMerchantConfiguration(config, MerchantConfigurationType.SOCIAL)).collect(Collectors.toList());
try {
for (MerchantConfiguration mConfigs : configurations) {
mConfigs.setMerchantStore(mStore);
if (!StringUtils.isEmpty(mConfigs.getValue())) {
mConfigs.setMerchantConfigurationType(MerchantConfigurationType.SOCIAL);
merchantConfigurationService.saveOrUpdate(mConfigs);
} else {
// remove if submited blank and exists
MerchantConfiguration config = merchantConfigurationService.getMerchantConfiguration(mConfigs.getKey(), mStore);
if (config != null) {
merchantConfigurationService.delete(config);
}
}
}
} catch (ServiceException se) {
throw new ServiceRuntimeException(se);
}
}
Aggregations