Search in sources :

Example 21 with MerchantConfiguration

use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.

the class ShippingServiceImpl method getShippingConfiguration.

@Override
public ShippingConfiguration getShippingConfiguration(MerchantStore store) throws ServiceException {
    MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(ShippingConstants.SHIPPING_CONFIGURATION, store);
    ShippingConfiguration shippingConfiguration = null;
    if (configuration != null) {
        String value = configuration.getValue();
        ObjectMapper mapper = new ObjectMapper();
        try {
            shippingConfiguration = mapper.readValue(value, ShippingConfiguration.class);
        } catch (Exception e) {
            throw new ServiceException("Cannot parse json string " + value);
        }
    }
    return shippingConfiguration;
}
Also used : ServiceException(com.salesmanager.core.business.exception.ServiceException) MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceException(com.salesmanager.core.business.exception.ServiceException) IntegrationException(com.salesmanager.core.modules.integration.IntegrationException) ShippingConfiguration(com.salesmanager.core.model.shipping.ShippingConfiguration)

Example 22 with MerchantConfiguration

use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.

the class EmailServiceImpl method saveEmailConfiguration.

@Override
public void saveEmailConfiguration(EmailConfig emailConfig, MerchantStore store) throws ServiceException {
    MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(Constants.EMAIL_CONFIG, store);
    if (configuration == null) {
        configuration = new MerchantConfiguration();
        configuration.setMerchantStore(store);
        configuration.setKey(Constants.EMAIL_CONFIG);
    }
    String value = emailConfig.toJSONString();
    configuration.setValue(value);
    merchantConfigurationService.saveOrUpdate(configuration);
}
Also used : MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration)

Example 23 with MerchantConfiguration

use of com.salesmanager.core.model.system.MerchantConfiguration in project shopizer by shopizer-ecommerce.

the class MerchantConfigurationServiceImpl method saveMerchantConfig.

@Override
public void saveMerchantConfig(MerchantConfig config, MerchantStore store) throws ServiceException {
    MerchantConfiguration configuration = merchantConfigurationRepository.findByMerchantStoreAndKey(store.getId(), MerchantConfigurationType.CONFIG.name());
    if (configuration == null) {
        configuration = new MerchantConfiguration();
        configuration.setMerchantStore(store);
        configuration.setKey(MerchantConfigurationType.CONFIG.name());
        configuration.setMerchantConfigurationType(MerchantConfigurationType.CONFIG);
    }
    String value = config.toJSONString();
    configuration.setValue(value);
    if (configuration.getId() != null && configuration.getId() > 0) {
        super.update(configuration);
    } else {
        super.create(configuration);
    }
}
Also used : MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration)

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