use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class StoreFilter method getConfigurations.
@SuppressWarnings("unused")
private Map<String, Object> getConfigurations(MerchantStore store) {
Map<String, Object> configs = new HashMap<String, Object>();
try {
List<MerchantConfiguration> merchantConfiguration = merchantConfigurationService.listByType(MerchantConfigurationType.CONFIG, store);
// get social
List<MerchantConfiguration> socialConfigs = merchantConfigurationService.listByType(MerchantConfigurationType.SOCIAL, store);
if (!CollectionUtils.isEmpty(socialConfigs)) {
if (CollectionUtils.isEmpty(merchantConfiguration)) {
merchantConfiguration = new ArrayList<MerchantConfiguration>();
}
merchantConfiguration.addAll(socialConfigs);
}
if (CollectionUtils.isEmpty(merchantConfiguration)) {
return configs;
}
for (MerchantConfiguration configuration : merchantConfiguration) {
configs.put(configuration.getKey(), configuration.getValue());
}
configs.put(Constants.SHOP_SCHEME, coreConfiguration.getProperty(Constants.SHOP_SCHEME));
configs.put(Constants.FACEBOOK_APP_ID, coreConfiguration.getProperty(Constants.FACEBOOK_APP_ID));
// get MerchantConfig
MerchantConfig merchantConfig = merchantConfigurationService.getMerchantConfig(store);
if (merchantConfig != null) {
if (configs == null) {
configs = new HashMap<String, Object>();
}
ObjectMapper m = new ObjectMapper();
@SuppressWarnings("unchecked") Map<String, Object> props = m.convertValue(merchantConfig, Map.class);
for (String key : props.keySet()) {
configs.put(key, props.get(key));
}
}
} catch (Exception e) {
LOGGER.error("Exception while getting configurations", e);
}
return configs;
}
use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class ShippingServiceImpl method saveShippingConfiguration.
@Override
public void saveShippingConfiguration(ShippingConfiguration shippingConfiguration, MerchantStore store) throws ServiceException {
MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(ShippingConstants.SHIPPING_CONFIGURATION, store);
if (configuration == null) {
configuration = new MerchantConfiguration();
configuration.setMerchantStore(store);
configuration.setKey(ShippingConstants.SHIPPING_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 ShippingServiceImpl method removeShippingQuoteModuleConfiguration.
@Override
public void removeShippingQuoteModuleConfiguration(String moduleCode, MerchantStore store) throws ServiceException {
try {
Map<String, IntegrationConfiguration> modules = new HashMap<String, IntegrationConfiguration>();
MerchantConfiguration merchantConfiguration = merchantConfigurationService.getMerchantConfiguration(SHIPPING_MODULES, store);
if (merchantConfiguration != null) {
if (!StringUtils.isBlank(merchantConfiguration.getValue())) {
String decrypted = encryption.decrypt(merchantConfiguration.getValue());
modules = ConfigurationModulesLoader.loadIntegrationConfigurations(decrypted);
}
modules.remove(moduleCode);
String configs = ConfigurationModulesLoader.toJSONString(modules);
String encrypted = encryption.encrypt(configs);
merchantConfiguration.setValue(encrypted);
merchantConfigurationService.saveOrUpdate(merchantConfiguration);
}
MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(moduleCode, store);
if (configuration != null) {
// custom module
merchantConfigurationService.delete(configuration);
}
} catch (Exception e) {
throw new ServiceException(e);
}
}
use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class ShippingServiceImpl method getSupportedCountries.
@Override
public List<String> getSupportedCountries(MerchantStore store) throws ServiceException {
List<String> supportedCountries = new ArrayList<String>();
MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(SUPPORTED_COUNTRIES, store);
if (configuration != null) {
String countries = configuration.getValue();
if (!StringUtils.isBlank(countries)) {
Object objRegions = JSONValue.parse(countries);
JSONArray arrayRegions = (JSONArray) objRegions;
for (Object arrayRegion : arrayRegions) {
supportedCountries.add((String) arrayRegion);
}
}
}
return supportedCountries;
}
use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.
the class ShippingServiceImpl method removeCustomShippingQuoteModuleConfiguration.
@Override
public void removeCustomShippingQuoteModuleConfiguration(String moduleCode, MerchantStore store) throws ServiceException {
try {
removeShippingQuoteModuleConfiguration(moduleCode, store);
MerchantConfiguration merchantConfiguration = merchantConfigurationService.getMerchantConfiguration(moduleCode, store);
if (merchantConfiguration != null) {
merchantConfigurationService.delete(merchantConfiguration);
}
} catch (Exception e) {
throw new ServiceException(e);
}
}
Aggregations