Search in sources :

Example 11 with MerchantConfiguration

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;
}
Also used : ServiceException(com.salesmanager.core.business.exception.ServiceException) MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration) MerchantConfig(com.salesmanager.core.model.system.MerchantConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceException(com.salesmanager.core.business.exception.ServiceException)

Example 12 with MerchantConfiguration

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

Example 13 with MerchantConfiguration

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

Example 14 with MerchantConfiguration

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

Example 15 with MerchantConfiguration

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);
    }
}
Also used : MerchantConfigEntity(com.salesmanager.shop.model.store.MerchantConfigEntity) ReadableMerchantStoreList(com.salesmanager.shop.model.store.ReadableMerchantStoreList) PersistableMerchantStorePopulator(com.salesmanager.shop.populator.store.PersistableMerchantStorePopulator) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ReadableBrand(com.salesmanager.shop.model.store.ReadableBrand) CollectionUtils(org.apache.commons.collections4.CollectionUtils) LanguageService(com.salesmanager.core.business.services.reference.language.LanguageService) ArrayList(java.util.ArrayList) ServiceException(com.salesmanager.core.business.exception.ServiceException) ZoneService(com.salesmanager.core.business.services.reference.zone.ZoneService) Inject(javax.inject.Inject) Language(com.salesmanager.core.model.reference.language.Language) PersistableBrand(com.salesmanager.shop.model.store.PersistableBrand) MerchantStoreCriteria(com.salesmanager.core.model.merchant.MerchantStoreCriteria) HttpServletRequest(javax.servlet.http.HttpServletRequest) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) Service(org.springframework.stereotype.Service) Qualifier(org.springframework.beans.factory.annotation.Qualifier) GenericEntityList(com.salesmanager.core.model.common.GenericEntityList) ReadableMerchantStorePopulator(com.salesmanager.shop.populator.store.ReadableMerchantStorePopulator) MerchantStoreService(com.salesmanager.core.business.services.merchant.MerchantStoreService) MeasureUnit(com.salesmanager.core.constants.MeasureUnit) CountryService(com.salesmanager.core.business.services.reference.country.CountryService) Logger(org.slf4j.Logger) ReadableMerchantStore(com.salesmanager.shop.model.store.ReadableMerchantStore) ImageFilePath(com.salesmanager.shop.utils.ImageFilePath) Page(org.springframework.data.domain.Page) InputContentFile(com.salesmanager.core.model.content.InputContentFile) Collectors(java.util.stream.Collectors) MerchantConfigurationService(com.salesmanager.core.business.services.system.MerchantConfigurationService) ContentService(com.salesmanager.core.business.services.content.ContentService) List(java.util.List) ReadableImage(com.salesmanager.shop.model.content.ReadableImage) Validate(org.apache.commons.lang3.Validate) MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration) LanguageUtils(com.salesmanager.shop.utils.LanguageUtils) MerchantConfigurationType(com.salesmanager.core.model.system.MerchantConfigurationType) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException) PersistableMerchantStore(com.salesmanager.shop.model.store.PersistableMerchantStore) Optional(java.util.Optional) ConversionException(com.salesmanager.core.business.exception.ConversionException) Collections(java.util.Collections) StringUtils(org.drools.core.util.StringUtils) MerchantConfigEntity(com.salesmanager.shop.model.store.MerchantConfigEntity) ServiceException(com.salesmanager.core.business.exception.ServiceException) MerchantConfiguration(com.salesmanager.core.model.system.MerchantConfiguration) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableMerchantStore(com.salesmanager.shop.model.store.ReadableMerchantStore) PersistableMerchantStore(com.salesmanager.shop.model.store.PersistableMerchantStore) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

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