Search in sources :

Example 1 with MerchantConfiguration

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;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration) MerchantConfig(com.salesmanager.core.model.system.MerchantConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with MerchantConfiguration

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);
}
Also used : MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration)

Example 3 with MerchantConfiguration

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);
    }
}
Also used : ServiceException(com.salesmanager.core.business.exception.ServiceException) HashMap(java.util.HashMap) CustomIntegrationConfiguration(com.salesmanager.core.model.system.CustomIntegrationConfiguration) IntegrationConfiguration(com.salesmanager.core.model.system.IntegrationConfiguration) MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration) ServiceException(com.salesmanager.core.business.exception.ServiceException) IntegrationException(com.salesmanager.core.modules.integration.IntegrationException)

Example 4 with MerchantConfiguration

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;
}
Also used : ArrayList(java.util.ArrayList) MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration) JSONArray(org.json.simple.JSONArray)

Example 5 with MerchantConfiguration

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);
    }
}
Also used : ServiceException(com.salesmanager.core.business.exception.ServiceException) MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration) ServiceException(com.salesmanager.core.business.exception.ServiceException) IntegrationException(com.salesmanager.core.modules.integration.IntegrationException)

Aggregations

MerchantConfiguration (com.salesmanager.core.model.system.MerchantConfiguration)23 ServiceException (com.salesmanager.core.business.exception.ServiceException)15 IntegrationException (com.salesmanager.core.modules.integration.IntegrationException)11 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 IntegrationConfiguration (com.salesmanager.core.model.system.IntegrationConfiguration)6 HashMap (java.util.HashMap)6 CustomIntegrationConfiguration (com.salesmanager.core.model.system.CustomIntegrationConfiguration)3 ArrayList (java.util.ArrayList)3 ShippingConfiguration (com.salesmanager.core.model.shipping.ShippingConfiguration)2 MerchantConfig (com.salesmanager.core.model.system.MerchantConfig)2 ShippingQuoteModule (com.salesmanager.core.modules.integration.shipping.model.ShippingQuoteModule)2 ConversionException (com.salesmanager.core.business.exception.ConversionException)1 EmailConfig (com.salesmanager.core.business.modules.email.EmailConfig)1 ContentService (com.salesmanager.core.business.services.content.ContentService)1 MerchantStoreService (com.salesmanager.core.business.services.merchant.MerchantStoreService)1 CountryService (com.salesmanager.core.business.services.reference.country.CountryService)1 LanguageService (com.salesmanager.core.business.services.reference.language.LanguageService)1 ZoneService (com.salesmanager.core.business.services.reference.zone.ZoneService)1 MerchantConfigurationService (com.salesmanager.core.business.services.system.MerchantConfigurationService)1 MeasureUnit (com.salesmanager.core.constants.MeasureUnit)1