List of usage examples for com.liferay.portal.kernel.model Company getLocale
public java.util.Locale getLocale() throws com.liferay.portal.kernel.exception.PortalException;
From source file:com.liferay.journal.internal.upgrade.v0_0_3.UpgradeJournalArticleType.java
License:Open Source License
protected void updateArticleType() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer()) { if (!hasSelectedArticleTypes()) { return; }/*ww w .j a v a 2 s .com*/ List<String> types = getArticleTypes(); if (types.size() <= 0) { return; } Locale localeThreadLocalDefaultLocale = LocaleThreadLocal.getDefaultLocale(); try { List<Company> companies = _companyLocalService.getCompanies(); for (Company company : companies) { LocaleThreadLocal.setDefaultLocale(company.getLocale()); Set<Locale> locales = LanguageUtil.getAvailableLocales(company.getGroupId()); Locale defaultLocale = LocaleUtil .fromLanguageId(UpgradeProcessUtil.getDefaultLanguageId(company.getCompanyId())); Map<Locale, String> nameMap = LocalizationUtil.getLocalizationMap(locales, defaultLocale, "type"); AssetVocabulary assetVocabulary = addAssetVocabulary(company.getGroupId(), company.getCompanyId(), "type", nameMap, new HashMap<Locale, String>()); Map<String, Long> journalArticleTypesToAssetCategoryIds = new HashMap<>(); for (String type : types) { AssetCategory assetCategory = addAssetCategory(company.getGroupId(), company.getCompanyId(), type, assetVocabulary.getVocabularyId()); journalArticleTypesToAssetCategoryIds.put(type, assetCategory.getCategoryId()); } updateArticles(company.getCompanyId(), journalArticleTypesToAssetCategoryIds); } } finally { LocaleThreadLocal.setDefaultLocale(localeThreadLocalDefaultLocale); } } }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testGetGlobalSiteDefaultLocale() throws Exception { Company company = CompanyLocalServiceUtil.getCompany(_group.getCompanyId()); Assert.assertEquals(company.getLocale(), PortalUtil.getSiteDefaultLocale(company.getGroupId())); }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testGetSiteDefaultInheritLocale() throws Exception { Company company = CompanyLocalServiceUtil.getCompany(_group.getCompanyId()); Assert.assertEquals(company.getLocale(), PortalUtil.getSiteDefaultLocale(_group.getGroupId())); }