use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class MerchantConfigurationServiceImpl method getMerchantConfig.
@Override
public MerchantConfig getMerchantConfig(MerchantStore store) throws ServiceException {
MerchantConfiguration configuration = merchantConfigurationRepository.findByMerchantStoreAndKey(store.getId(), MerchantConfigurationType.CONFIG.name());
MerchantConfig config = null;
if (configuration != null) {
String value = configuration.getValue();
ObjectMapper mapper = new ObjectMapper();
try {
config = mapper.readValue(value, MerchantConfig.class);
} catch (Exception e) {
throw new ServiceException("Cannot parse json string " + value);
}
}
return config;
}
use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class TaxServiceImpl method saveTaxConfiguration.
@Override
public void saveTaxConfiguration(TaxConfiguration shippingConfiguration, MerchantStore store) throws ServiceException {
MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(TAX_CONFIGURATION, store);
if (configuration == null) {
configuration = new MerchantConfiguration();
configuration.setMerchantStore(store);
configuration.setKey(TAX_CONFIGURATION);
}
String value = shippingConfiguration.toJSONString();
configuration.setValue(value);
merchantConfigurationService.saveOrUpdate(configuration);
}
use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class TaxServiceImpl method getTaxConfiguration.
@Override
public TaxConfiguration getTaxConfiguration(MerchantStore store) throws ServiceException {
MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(TAX_CONFIGURATION, store);
TaxConfiguration taxConfiguration = null;
if (configuration != null) {
String value = configuration.getValue();
ObjectMapper mapper = new ObjectMapper();
try {
taxConfiguration = mapper.readValue(value, TaxConfiguration.class);
} catch (Exception e) {
throw new ServiceException("Cannot parse json string " + value);
}
}
return taxConfiguration;
}
use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class CustomWeightBasedShippingQuote method getCustomModuleConfiguration.
@Override
public CustomIntegrationConfiguration getCustomModuleConfiguration(MerchantStore store) throws IntegrationException {
try {
MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(MODULE_CODE, store);
if (configuration != null) {
String value = configuration.getValue();
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.readValue(value, CustomShippingQuotesConfiguration.class);
} catch (Exception e) {
throw new ServiceException("Cannot parse json string " + value);
}
} else {
CustomShippingQuotesConfiguration custom = new CustomShippingQuotesConfiguration();
custom.setModuleCode(MODULE_CODE);
return custom;
}
} catch (Exception e) {
throw new IntegrationException(e);
}
}
use of com.salesmanager.core.model.system.MerchantConfiguration 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