} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaLocalization(engineEcoSession, localization);
}
// RETAILER
Retailer retailer = marketArea.getRetailer(retailerCode);
if (retailer == null) {
Retailer defaultRetailer = marketArea.getDefaultRetailer();
engineEcoSession = (EngineEcoSession) setSessionMarketAreaRetailer(engineEcoSession, defaultRetailer);
} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaRetailer(engineEcoSession, retailer);
}
// CURRENCY
CurrencyReferential currency = marketArea.getCurrency(currencyCode);
if (currency == null) {
CurrencyReferential defaultCurrency = marketArea.getDefaultCurrency();
engineEcoSession = (EngineEcoSession) setSessionMarketAreaCurrency(engineEcoSession, defaultCurrency);
} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaCurrency(engineEcoSession, currency);
}
}
} else {
Market market = engineEcoSession.getCurrentMarket();
if (market != null && !market.getCode().equalsIgnoreCase(marketCode)) {
// CHANGE THE MARKET
Market newMarket = marketService.getMarketByCode(marketCode);
if (newMarket == null) {
newMarket = currentMarketPlace.getDefaultMarket();
}
engineEcoSession = (EngineEcoSession) setSessionMarket(engineEcoSession, market);
updateCurrentTheme(request, newMarket.getTheme());
// MARKET AREA
MarketArea marketArea = newMarket.getMarketArea(marketAreaCode);
if (marketArea == null) {
marketArea = market.getDefaultMarketArea();
}
engineEcoSession = (EngineEcoSession) setSessionMarketArea(engineEcoSession, marketArea);
marketArea = engineEcoSession.getCurrentMarketArea();
// LOCALE
Localization localization = marketArea.getLocalization(localizationCode);
if (localization == null) {
Localization defaultLocalization = marketArea.getDefaultLocalization();
engineEcoSession = (EngineEcoSession) setSessionMarketAreaLocalization(engineEcoSession, defaultLocalization);
} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaLocalization(engineEcoSession, localization);
}
// RETAILER
Retailer retailer = marketArea.getRetailer(retailerCode);
if (retailer == null) {
Retailer defaultRetailer = marketArea.getDefaultRetailer();
engineEcoSession = (EngineEcoSession) setSessionMarketAreaRetailer(engineEcoSession, defaultRetailer);
} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaRetailer(engineEcoSession, retailer);
}
// CURRENCY
CurrencyReferential currency = marketArea.getCurrency(currencyCode);
if (currency == null) {
CurrencyReferential defaultCurrency = marketArea.getDefaultCurrency();
engineEcoSession = (EngineEcoSession) setSessionMarketAreaCurrency(engineEcoSession, defaultCurrency);
} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaCurrency(engineEcoSession, currency);
}
} else {
MarketArea marketArea = engineEcoSession.getCurrentMarketArea();
if (marketArea != null && !marketArea.getCode().equalsIgnoreCase(marketAreaCode)) {
// CHANGE THE MARKET AREA
MarketArea newMarketArea = market.getMarketArea(marketAreaCode);
if (newMarketArea == null) {
newMarketArea = market.getDefaultMarketArea();
}
engineEcoSession = (EngineEcoSession) setSessionMarketArea(engineEcoSession, newMarketArea);
marketArea = engineEcoSession.getCurrentMarketArea();
updateCurrentTheme(request, newMarketArea.getTheme());
// LOCALE
Localization localization = newMarketArea.getLocalization(localizationCode);
if (localization == null) {
Localization defaultLocalization = marketArea.getDefaultLocalization();
engineEcoSession = (EngineEcoSession) setSessionMarketAreaLocalization(engineEcoSession, defaultLocalization);
} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaLocalization(engineEcoSession, localization);
}
// RETAILER
Retailer retailer = marketArea.getRetailer(retailerCode);
if (retailer == null) {
Retailer defaultRetailer = marketArea.getDefaultRetailer();
engineEcoSession = (EngineEcoSession) setSessionMarketAreaRetailer(engineEcoSession, defaultRetailer);
} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaRetailer(engineEcoSession, retailer);
}
// CURRENCY
CurrencyReferential currency = marketArea.getCurrency(currencyCode);
if (currency == null) {
CurrencyReferential defaultCurrency = marketArea.getDefaultCurrency();
engineEcoSession = (EngineEcoSession) setSessionMarketAreaCurrency(engineEcoSession, defaultCurrency);
} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaCurrency(engineEcoSession, currency);
}
} else {
Localization localization = engineEcoSession.getCurrentMarketAreaLocalization();
Retailer retailer = engineEcoSession.getCurrentMarketAreaRetailer();
CurrencyReferential currency = engineEcoSession.getCurrentMarketAreaCurrency();
if (localization != null && !localization.getLocale().toString().equalsIgnoreCase(localizationCode)) {
// CHANGE THE LOCALE
Localization newLocalization = marketArea.getLocalization(localizationCode);
if (newLocalization == null) {
Localization defaultLocalization = marketArea.getDefaultLocalization();
engineEcoSession = (EngineEcoSession) setSessionMarketAreaLocalization(engineEcoSession, defaultLocalization);
} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaLocalization(engineEcoSession, newLocalization);
}
} else if (retailer != null && !retailer.getCode().toString().equalsIgnoreCase(localizationCode)) {
// CHANGE THE RETAILER
Retailer newRetailer = marketArea.getRetailer(retailerCode);
if (newRetailer == null) {
Retailer defaultRetailer = marketArea.getDefaultRetailer();
engineEcoSession = (EngineEcoSession) setSessionMarketAreaRetailer(engineEcoSession, defaultRetailer);
} else {
engineEcoSession = (EngineEcoSession) setSessionMarketAreaRetailer(engineEcoSession, newRetailer);
}