use of com.salesmanager.core.model.system.MerchantConfig 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.MerchantConfig 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;
}
use of com.salesmanager.core.model.system.MerchantConfig in project shopizer by shopizer-ecommerce.
the class MerchantConfigurationFacadeImpl method getMerchantConfig.
@Override
public Configs getMerchantConfig(MerchantStore merchantStore, Language language) {
MerchantConfig configs = getMerchantConfig(merchantStore);
Configs readableConfig = new Configs();
readableConfig.setAllowOnlinePurchase(configs.isAllowPurchaseItems());
readableConfig.setDisplaySearchBox(configs.isDisplaySearchBox());
readableConfig.setDisplayContactUs(configs.isDisplayContactUs());
readableConfig.setDisplayCustomerSection(configs.isDisplayCustomerSection());
readableConfig.setDisplayAddToCartOnFeaturedItems(configs.isDisplayAddToCartOnFeaturedItems());
readableConfig.setDisplayCustomerAgreement(configs.isDisplayCustomerAgreement());
readableConfig.setDisplayPagesMenu(configs.isDisplayPagesMenu());
Optional<String> facebookConfigValue = getConfigValue(KEY_FACEBOOK_PAGE_URL, merchantStore);
facebookConfigValue.ifPresent(readableConfig::setFacebook);
Optional<String> googleConfigValue = getConfigValue(KEY_GOOGLE_ANALYTICS_URL, merchantStore);
googleConfigValue.ifPresent(readableConfig::setGa);
Optional<String> instagramConfigValue = getConfigValue(KEY_INSTAGRAM_URL, merchantStore);
instagramConfigValue.ifPresent(readableConfig::setInstagram);
Optional<String> pinterestConfigValue = getConfigValue(KEY_PINTEREST_PAGE_URL, merchantStore);
pinterestConfigValue.ifPresent(readableConfig::setPinterest);
readableConfig.setDisplayShipping(false);
try {
if (!StringUtils.isBlank(displayShipping)) {
readableConfig.setDisplayShipping(Boolean.valueOf(displayShipping));
}
} catch (Exception e) {
LOGGER.error("Cannot parse value of " + displayShipping);
}
return readableConfig;
}
use of com.salesmanager.core.model.system.MerchantConfig in project shopizer by shopizer-ecommerce.
the class InitializationLoader method init.
@PostConstruct
public void init() {
try {
// Check flag to populate or not the database
if (!this.initDefaultData) {
return;
}
if (initializationDatabase.isEmpty()) {
// All default data to be created
LOGGER.info(String.format("%s : Shopizer database is empty, populate it....", "sm-shop"));
initializationDatabase.populate("sm-shop");
MerchantStore store = merchantService.getByCode(MerchantStore.DEFAULT_STORE);
userDetailsService.createDefaultAdmin();
MerchantConfig config = new MerchantConfig();
config.setAllowPurchaseItems(true);
config.setDisplayAddToCartOnFeaturedItems(true);
merchantConfigurationService.saveMerchantConfig(config, store);
}
} catch (Exception e) {
LOGGER.error("Error in the init method", e);
}
}
Aggregations