Search in sources :

Example 1 with MerchantConfigEntity

use of com.salesmanager.shop.model.store.MerchantConfigEntity in project shopizer by shopizer-ecommerce.

the class StoreFacadeImpl method getBrand.

@Override
public ReadableBrand getBrand(String code) {
    MerchantStore mStore = getMerchantStoreByCode(code);
    ReadableBrand readableBrand = new ReadableBrand();
    if (!StringUtils.isEmpty(mStore.getStoreLogo())) {
        String imagePath = imageUtils.buildStoreLogoFilePath(mStore);
        ReadableImage image = createReadableImage(mStore.getStoreLogo(), imagePath);
        readableBrand.setLogo(image);
    }
    List<MerchantConfigEntity> merchantConfigTOs = getMerchantConfigEntities(mStore);
    readableBrand.getSocialNetworks().addAll(merchantConfigTOs);
    return readableBrand;
}
Also used : ReadableImage(com.salesmanager.shop.model.content.ReadableImage) MerchantConfigEntity(com.salesmanager.shop.model.store.MerchantConfigEntity) MerchantStore(com.salesmanager.core.model.merchant.MerchantStore) ReadableMerchantStore(com.salesmanager.shop.model.store.ReadableMerchantStore) PersistableMerchantStore(com.salesmanager.shop.model.store.PersistableMerchantStore) ReadableBrand(com.salesmanager.shop.model.store.ReadableBrand)

Example 2 with MerchantConfigEntity

use of com.salesmanager.shop.model.store.MerchantConfigEntity in project shopizer by shopizer-ecommerce.

the class StoreFacadeImpl method convertToMerchantConfigEntity.

private MerchantConfigEntity convertToMerchantConfigEntity(MerchantConfiguration config) {
    MerchantConfigEntity configTO = new MerchantConfigEntity();
    configTO.setId(config.getId());
    configTO.setKey(config.getKey());
    configTO.setType(config.getMerchantConfigurationType());
    configTO.setValue(config.getValue());
    configTO.setActive(config.getActive() != null ? config.getActive().booleanValue() : false);
    return configTO;
}
Also used : MerchantConfigEntity(com.salesmanager.shop.model.store.MerchantConfigEntity)

Example 3 with MerchantConfigEntity

use of com.salesmanager.shop.model.store.MerchantConfigEntity 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

MerchantConfigEntity (com.salesmanager.shop.model.store.MerchantConfigEntity)3 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)2 ReadableImage (com.salesmanager.shop.model.content.ReadableImage)2 PersistableMerchantStore (com.salesmanager.shop.model.store.PersistableMerchantStore)2 ReadableBrand (com.salesmanager.shop.model.store.ReadableBrand)2 ReadableMerchantStore (com.salesmanager.shop.model.store.ReadableMerchantStore)2 ConversionException (com.salesmanager.core.business.exception.ConversionException)1 ServiceException (com.salesmanager.core.business.exception.ServiceException)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 GenericEntityList (com.salesmanager.core.model.common.GenericEntityList)1 InputContentFile (com.salesmanager.core.model.content.InputContentFile)1 MerchantStoreCriteria (com.salesmanager.core.model.merchant.MerchantStoreCriteria)1 Language (com.salesmanager.core.model.reference.language.Language)1 MerchantConfiguration (com.salesmanager.core.model.system.MerchantConfiguration)1