marketArea = market.getDefaultMarketArea();
}
engineBoSession = (EngineBoSession) setSessionMarketArea(engineBoSession, marketArea);
// LOCALE
Localization localization = marketArea.getLocalization(localizationCode);
if (localization == null) {
Localization defaultLocalization = marketArea.getDefaultLocalization();
engineBoSession = (EngineBoSession) setSessionMarketAreaLocalization(engineBoSession, defaultLocalization);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaLocalization(engineBoSession, localization);
}
// RETAILER
Retailer retailer = marketArea.getRetailer(localizationCode);
if (retailer == null) {
Retailer defaultRetailer = marketArea.getDefaultRetailer();
engineBoSession = (EngineBoSession) setSessionMarketAreaRetailer(engineBoSession, defaultRetailer);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaRetailer(engineBoSession, retailer);
}
// CURRENCY
CurrencyReferential currency = marketArea.getCurrency(currencyCode);
if (currency == null) {
CurrencyReferential defaultCurrency = marketArea.getDefaultCurrency();
engineBoSession = (EngineBoSession) setSessionMarketAreaCurrency(engineBoSession, defaultCurrency);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaCurrency(engineBoSession, currency);
}
}
} else {
Market market = engineBoSession.getCurrentMarket();
if (market != null && !market.getCode().equalsIgnoreCase(marketCode)) {
// CHANGE THE MARKET
Market newMarket = marketService.getMarketByCode(marketCode);
if (newMarket == null) {
newMarket = currentMarketPlace.getDefaultMarket();
}
engineBoSession = (EngineBoSession) setSessionMarket(engineBoSession, market);
updateCurrentTheme(request, newMarket.getTheme());
// MARKET AREA
MarketArea marketArea = newMarket.getMarketArea(marketAreaCode);
if (marketArea == null) {
marketArea = market.getDefaultMarketArea();
}
engineBoSession = (EngineBoSession) setSessionMarketArea(engineBoSession, marketArea);
// LOCALE
Localization localization = marketArea.getLocalization(localizationCode);
if (localization == null) {
Localization defaultLocalization = marketArea.getDefaultLocalization();
engineBoSession = (EngineBoSession) setSessionMarketAreaLocalization(engineBoSession, defaultLocalization);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaLocalization(engineBoSession, localization);
}
// RETAILER
Retailer retailer = marketArea.getRetailer(retailerCode);
if (retailer == null) {
Retailer defaultRetailer = marketArea.getDefaultRetailer();
engineBoSession = (EngineBoSession) setSessionMarketAreaRetailer(engineBoSession, defaultRetailer);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaRetailer(engineBoSession, retailer);
}
// CURRENCY
CurrencyReferential currency = marketArea.getCurrency(currencyCode);
if (currency == null) {
CurrencyReferential defaultCurrency = marketArea.getDefaultCurrency();
engineBoSession = (EngineBoSession) setSessionMarketAreaCurrency(engineBoSession, defaultCurrency);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaCurrency(engineBoSession, currency);
}
} else {
MarketArea marketArea = engineBoSession.getCurrentMarketArea();
if (marketArea != null && !marketArea.getCode().equalsIgnoreCase(marketAreaCode)) {
// CHANGE THE MARKET AREA
MarketArea newMarketArea = market.getMarketArea(marketAreaCode);
if (newMarketArea == null) {
newMarketArea = market.getDefaultMarketArea();
}
engineBoSession = (EngineBoSession) setSessionMarketArea(engineBoSession, marketArea);
updateCurrentTheme(request, newMarketArea.getTheme());
// LOCALE
Localization localization = newMarketArea.getLocalization(localizationCode);
if (localization == null) {
Localization defaultLocalization = marketArea.getDefaultLocalization();
engineBoSession = (EngineBoSession) setSessionMarketAreaLocalization(engineBoSession, defaultLocalization);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaLocalization(engineBoSession, localization);
}
// RETAILER
Retailer retailer = marketArea.getRetailer(retailerCode);
if (retailer == null) {
Retailer defaultRetailer = marketArea.getDefaultRetailer();
engineBoSession = (EngineBoSession) setSessionMarketAreaRetailer(engineBoSession, defaultRetailer);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaRetailer(engineBoSession, retailer);
}
// CURRENCY
CurrencyReferential currency = marketArea.getCurrency(currencyCode);
if (currency == null) {
CurrencyReferential defaultCurrency = marketArea.getDefaultCurrency();
engineBoSession = (EngineBoSession) setSessionMarketAreaCurrency(engineBoSession, defaultCurrency);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaCurrency(engineBoSession, currency);
}
} else {
Localization localization = engineBoSession.getCurrentMarketAreaLocalization();
Retailer retailer = engineBoSession.getCurrentMarketAreaRetailer();
CurrencyReferential currency = engineBoSession.getCurrentMarketAreaCurrency();
if (localization != null && !localization.getLocale().toString().equalsIgnoreCase(localizationCode)) {
// CHANGE THE LOCALE
Localization newLocalization = marketArea.getLocalization(localizationCode);
if (newLocalization == null) {
Localization defaultLocalization = marketArea.getDefaultLocalization();
engineBoSession = (EngineBoSession) setSessionMarketAreaLocalization(engineBoSession, defaultLocalization);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaLocalization(engineBoSession, 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();
engineBoSession = (EngineBoSession) setSessionMarketAreaRetailer(engineBoSession, defaultRetailer);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaRetailer(engineBoSession, newRetailer);
}
} else if (currency != null && !currency.getCode().toString().equalsIgnoreCase(currencyCode)) {
// CHANGE THE CURRENCY
CurrencyReferential newCurrency = marketArea.getCurrency(currencyCode);
if (newCurrency == null) {
CurrencyReferential defaultCurrency = marketArea.getDefaultCurrency();
engineBoSession = (EngineBoSession) setSessionMarketAreaCurrency(engineBoSession, defaultCurrency);
} else {
engineBoSession = (EngineBoSession) setSessionMarketAreaCurrency(engineBoSession, newCurrency);
}
}
}
}
}
}
// CHECK BACKOFFICE LANGUAGES
String backofficeLocalizationCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_LOCALE_CODE);
// LOCALIZATIONS
Company company = getCurrentCompany(request);
if (company != null) {
Localization localization = company.getLocalization(backofficeLocalizationCode);
if (localization != null) {
engineBoSession.setCurrentBackofficeLocalization(localization);
}
}