List of usage examples for com.liferay.portal.kernel.dao.search SearchContainer setTotal
public void setTotal(int total)
From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java
License:Open Source License
public SearchContainer getCategoriesSearchContainer() throws PortalException { if (_categoriesSearchContainer != null) { return _categoriesSearchContainer; }/*from w w w . j av a2 s . co m*/ SearchContainer categoriesSearchContainer = new SearchContainer(_renderRequest, getIteratorURL(), null, "there-are-no-categories"); if (Validator.isNull(getKeywords())) { if (isShowCategoriesAddButton()) { categoriesSearchContainer .setEmptyResultsMessageCssClass("there-are-no-categories.-you-can-add-a-category-by-" + "clicking-the-plus-button-on-the-bottom-right-corner"); categoriesSearchContainer .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn"); } } else { categoriesSearchContainer.setSearch(true); } categoriesSearchContainer.setOrderByCol(getOrderByCol()); boolean orderByAsc = false; String orderByType = getOrderByType(); if (orderByType.equals("asc")) { orderByAsc = true; } OrderByComparator<AssetCategory> orderByComparator = new AssetCategoryCreateDateComparator(orderByAsc); categoriesSearchContainer.setOrderByComparator(orderByComparator); categoriesSearchContainer.setOrderByType(orderByType); EmptyOnClickRowChecker emptyOnClickRowChecker = new EmptyOnClickRowChecker(_renderResponse); StringBundler sb = new StringBundler(7); sb.append("^(?!.*"); sb.append(_renderResponse.getNamespace()); sb.append("redirect).*(/vocabulary/"); sb.append(getVocabularyId()); sb.append("/category/"); sb.append(getCategoryId()); sb.append(")"); emptyOnClickRowChecker.setRememberCheckBoxStateURLRegex(sb.toString()); categoriesSearchContainer.setRowChecker(emptyOnClickRowChecker); List<AssetCategory> categories = null; int categoriesCount = 0; ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); long scopeGroupId = themeDisplay.getScopeGroupId(); if (Validator.isNotNull(getKeywords())) { AssetCategoryDisplay assetCategoryDisplay = null; Sort sort = null; if (isFlattenedNavigationAllowed()) { sort = new Sort("leftCategoryId", Sort.INT_TYPE, orderByAsc); } else { sort = new Sort("createDate", Sort.LONG_TYPE, orderByAsc); } assetCategoryDisplay = AssetCategoryServiceUtil.searchCategoriesDisplay(new long[] { scopeGroupId }, getKeywords(), new long[] { getVocabularyId() }, new long[0], categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(), sort); categoriesCount = assetCategoryDisplay.getTotal(); categoriesSearchContainer.setTotal(categoriesCount); categories = assetCategoryDisplay.getCategories(); } else if (isFlattenedNavigationAllowed()) { AssetCategory category = getCategory(); if (Validator.isNull(category)) { categoriesCount = AssetCategoryServiceUtil .getVocabularyCategoriesCount(themeDisplay.getScopeGroupId(), getVocabularyId()); categories = AssetCategoryServiceUtil.getVocabularyCategories(getVocabularyId(), categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(), new AssetCategoryLeftCategoryIdComparator(orderByAsc)); } else { categoriesCount = AssetCategoryServiceUtil.getVocabularyCategoriesCount( themeDisplay.getScopeGroupId(), category.getCategoryId(), getVocabularyId()); categories = AssetCategoryServiceUtil.getVocabularyCategories(category.getCategoryId(), getVocabularyId(), categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(), new AssetCategoryLeftCategoryIdComparator(orderByAsc)); } categoriesSearchContainer.setTotal(categoriesCount); } else { categoriesCount = AssetCategoryServiceUtil.getVocabularyCategoriesCount(scopeGroupId, getCategoryId(), getVocabularyId()); categoriesSearchContainer.setTotal(categoriesCount); categories = AssetCategoryServiceUtil.getVocabularyCategories(scopeGroupId, getCategoryId(), getVocabularyId(), categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(), categoriesSearchContainer.getOrderByComparator()); } categoriesSearchContainer.setResults(categories); _categoriesSearchContainer = categoriesSearchContainer; return _categoriesSearchContainer; }
From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java
License:Open Source License
public SearchContainer getVocabulariesSearchContainer() throws PortalException { if (_vocabulariesSearchContainer != null) { return _vocabulariesSearchContainer; }// w w w.jav a 2 s .com SearchContainer vocabulariesSearchContainer = new SearchContainer(_renderRequest, _renderResponse.createRenderURL(), null, "there-are-no-vocabularies"); String keywords = getKeywords(); if (Validator.isNull(keywords)) { if (isShowVocabulariesAddButton()) { vocabulariesSearchContainer .setEmptyResultsMessage("there-are-no-vocabularies.-you-can-add-a-vocabulary-by-" + "clicking-the-plus-button-on-the-bottom-right-corner"); vocabulariesSearchContainer .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn"); } } else { vocabulariesSearchContainer.setSearch(true); } vocabulariesSearchContainer.setOrderByCol(getOrderByCol()); String orderByType = getOrderByType(); boolean orderByAsc = false; if (orderByType.equals("asc")) { orderByAsc = true; } OrderByComparator<AssetVocabulary> orderByComparator = new AssetVocabularyCreateDateComparator(orderByAsc); vocabulariesSearchContainer.setOrderByComparator(orderByComparator); vocabulariesSearchContainer.setOrderByType(orderByType); EmptyOnClickRowChecker emptyOnClickRowChecker = new EmptyOnClickRowChecker(_renderResponse); StringBundler sb = new StringBundler(5); sb.append("^(?!.*"); sb.append(_renderResponse.getNamespace()); sb.append("redirect).*(/vocabulary/"); sb.append(getVocabularyId()); sb.append(")"); emptyOnClickRowChecker.setRememberCheckBoxStateURLRegex(sb.toString()); vocabulariesSearchContainer.setRowChecker(emptyOnClickRowChecker); List<AssetVocabulary> vocabularies = null; int vocabulariesCount = 0; ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); long scopeGroupId = themeDisplay.getScopeGroupId(); if (Validator.isNotNull(keywords)) { Sort sort = new Sort("createDate", Sort.LONG_TYPE, orderByAsc); AssetVocabularyDisplay assetVocabularyDisplay = AssetVocabularyServiceUtil.searchVocabulariesDisplay( scopeGroupId, keywords, true, vocabulariesSearchContainer.getStart(), vocabulariesSearchContainer.getEnd(), sort); vocabulariesCount = assetVocabularyDisplay.getTotal(); vocabulariesSearchContainer.setTotal(vocabulariesCount); vocabularies = assetVocabularyDisplay.getVocabularies(); } else { vocabulariesCount = AssetVocabularyServiceUtil.getGroupVocabulariesCount(scopeGroupId); vocabulariesSearchContainer.setTotal(vocabulariesCount); vocabularies = AssetVocabularyServiceUtil.getGroupVocabularies(scopeGroupId, true, vocabulariesSearchContainer.getStart(), vocabulariesSearchContainer.getEnd(), vocabulariesSearchContainer.getOrderByComparator()); if (vocabulariesCount == 0) { vocabulariesCount = AssetVocabularyServiceUtil.getGroupVocabulariesCount(scopeGroupId); vocabulariesSearchContainer.setTotal(vocabulariesCount); } } vocabulariesSearchContainer.setResults(vocabularies); _vocabulariesSearchContainer = vocabulariesSearchContainer; return _vocabulariesSearchContainer; }
From source file:com.liferay.asset.display.template.web.internal.display.context.AssetDisplayTemplateDisplayContext.java
License:Open Source License
public SearchContainer getSearchContainer() throws PortalException { if (_searchContainer != null) { return _searchContainer; }/*from w w w. j av a 2 s . c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); SearchContainer searchContainer = new SearchContainer(_renderRequest, _renderResponse.createRenderURL(), null, "there-are-no-asset-display-templates"); if (!isSearch()) { if (isShowAddButton()) { searchContainer.setEmptyResultsMessage("there-are-no-asset-display-templates-you-can-add-an-" + "asset-display-template-by-clicking-plus-button-on-" + "the-bottom-right-corner"); searchContainer.setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn"); } } else { searchContainer.setSearch(true); } searchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse)); searchContainer.setOrderByCol(getOrderByCol()); OrderByComparator<AssetDisplayTemplate> orderByComparator = _getOrderByComparator(getOrderByCol(), getOrderByType()); searchContainer.setOrderByComparator(orderByComparator); searchContainer.setOrderByType(getOrderByType()); int assetDisplayTemplatesCount = 0; List<AssetDisplayTemplate> assetDisplayTemplates = null; if (isSearch()) { assetDisplayTemplatesCount = AssetDisplayTemplateLocalServiceUtil .getAssetDisplayTemplatesCount(themeDisplay.getScopeGroupId(), getKeywords()); assetDisplayTemplates = AssetDisplayTemplateLocalServiceUtil.getAssetDisplayTemplates( themeDisplay.getScopeGroupId(), getKeywords(), searchContainer.getStart(), searchContainer.getEnd(), orderByComparator); } else { assetDisplayTemplatesCount = AssetDisplayTemplateLocalServiceUtil .getAssetDisplayTemplatesCount(themeDisplay.getScopeGroupId()); assetDisplayTemplates = AssetDisplayTemplateLocalServiceUtil.getAssetDisplayTemplates( themeDisplay.getScopeGroupId(), searchContainer.getStart(), searchContainer.getEnd(), orderByComparator); } searchContainer.setTotal(assetDisplayTemplatesCount); searchContainer.setResults(assetDisplayTemplates); _searchContainer = searchContainer; return _searchContainer; }
From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java
License:Open Source License
private List<AssetEntryResult> _getAssetEntryResultsByClassName(SearchContainer searchContainer, AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, long[] classNameIds, Map<String, Serializable> attributes) throws Exception { List<AssetEntryResult> assetEntryResults = new ArrayList<>(); int end = searchContainer.getEnd(); int start = searchContainer.getStart(); int total = 0; for (long classNameId : classNameIds) { assetEntryQuery.setClassNameIds(new long[] { classNameId }); BaseModelSearchResult<AssetEntry> baseModelSearchResult = getAssetEntries(assetEntryQuery, layout, portletPreferences, portletName, locale, timeZone, companyId, scopeGroupId, userId, attributes, start, end);//from w ww . j av a 2 s. c o m int groupTotal = baseModelSearchResult.getLength(); total += groupTotal; List<AssetEntry> assetEntries = baseModelSearchResult.getBaseModels(); if (!assetEntries.isEmpty() && (start < groupTotal)) { AssetRendererFactory<?> groupAssetRendererFactory = AssetRendererFactoryRegistryUtil .getAssetRendererFactoryByClassNameId(classNameId); String title = ResourceActionsUtil.getModelResource(locale, groupAssetRendererFactory.getClassName()); assetEntryResults.add(new AssetEntryResult(title, assetEntries)); } if (!portletName.equals(AssetPublisherPortletKeys.RECENT_CONTENT)) { if (groupTotal > 0) { if ((end > 0) && (end > groupTotal)) { end -= groupTotal; } else { end = 0; } if ((start > 0) && (start > groupTotal)) { start -= groupTotal; } else { start = 0; } } assetEntryQuery.setEnd(QueryUtil.ALL_POS); assetEntryQuery.setStart(QueryUtil.ALL_POS); } } searchContainer.setTotal(total); return assetEntryResults; }
From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java
License:Open Source License
private List<AssetEntryResult> _getAssetEntryResultsByDefault(SearchContainer searchContainer, AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, long[] classNameIds, Map<String, Serializable> attributes) throws Exception { List<AssetEntryResult> assetEntryResults = new ArrayList<>(); int end = searchContainer.getEnd(); int start = searchContainer.getStart(); assetEntryQuery.setClassNameIds(classNameIds); BaseModelSearchResult<AssetEntry> baseModelSearchResult = getAssetEntries(assetEntryQuery, layout, portletPreferences, portletName, locale, timeZone, companyId, scopeGroupId, userId, attributes, start, end);// w w w . ja v a2s .co m int total = baseModelSearchResult.getLength(); searchContainer.setTotal(total); List<AssetEntry> assetEntries = baseModelSearchResult.getBaseModels(); if (!assetEntries.isEmpty() && (start < total)) { assetEntryResults.add(new AssetEntryResult(assetEntries)); } return assetEntryResults; }
From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java
License:Open Source License
private List<AssetEntryResult> _getAssetEntryResultsByVocabulary(SearchContainer searchContainer, AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, long[] classNameIds, long assetVocabularyId, Map<String, Serializable> attributes) throws Exception { List<AssetEntryResult> assetEntryResults = new ArrayList<>(); List<AssetCategory> assetCategories = _assetCategoryLocalService .getVocabularyRootCategories(assetVocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); assetEntryQuery.setClassNameIds(classNameIds); int end = searchContainer.getEnd(); int start = searchContainer.getStart(); int total = 0; for (AssetCategory assetCategory : assetCategories) { long[] oldAllCategoryIds = assetEntryQuery.getAllCategoryIds(); long[] newAllAssetCategoryIds = ArrayUtil.append(oldAllCategoryIds, assetCategory.getCategoryId()); assetEntryQuery.setAllCategoryIds(newAllAssetCategoryIds); BaseModelSearchResult<AssetEntry> baseModelSearchResult = getAssetEntries(assetEntryQuery, layout, portletPreferences, portletName, locale, timeZone, companyId, scopeGroupId, userId, attributes, start, end);// w w w . ja va 2 s .c o m int groupTotal = baseModelSearchResult.getLength(); total += groupTotal; List<AssetEntry> assetEntries = baseModelSearchResult.getBaseModels(); if (!assetEntries.isEmpty() && (start < groupTotal)) { String title = assetCategory.getTitle(locale); assetEntryResults.add(new AssetEntryResult(title, assetEntries)); } if (groupTotal > 0) { if ((end > 0) && (end > groupTotal)) { end -= groupTotal; } else { end = 0; } if ((start > 0) && (start > groupTotal)) { start -= groupTotal; } else { start = 0; } } assetEntryQuery.setAllCategoryIds(oldAllCategoryIds); assetEntryQuery.setEnd(QueryUtil.ALL_POS); assetEntryQuery.setStart(QueryUtil.ALL_POS); } searchContainer.setTotal(total); return assetEntryResults; }
From source file:com.liferay.asset.publisher.lar.test.AssetPublisherExportImportTest.java
License:Open Source License
protected void testDynamicExportImport(Map<String, String[]> preferenceMap, List<AssetEntry> expectedAssetEntries, boolean filtering) throws Exception { if (filtering) { // Creating entries to validate filtering addAssetEntries(group, 2, new ArrayList<AssetEntry>(), ServiceContextTestUtil.getServiceContext()); }/*from w ww . ja v a 2s . c om*/ String scopeId = _assetPublisherHelper.getScopeId(group, group.getGroupId()); preferenceMap.put("scopeIds", new String[] { scopeId }); preferenceMap.put("selectionStyle", new String[] { "dynamic" }); PortletPreferences portletPreferences = getImportedPortletPreferences(preferenceMap); Company company = CompanyLocalServiceUtil.getCompany(TestPropsValues.getCompanyId()); AssetEntryQuery assetEntryQuery = _assetPublisherHelper.getAssetEntryQuery(portletPreferences, importedGroup.getGroupId(), layout, null, null); SearchContainer<AssetEntry> searchContainer = new SearchContainer<>(); searchContainer.setTotal(10); List<AssetEntryResult> actualAssetEntryResults = _assetPublisherHelper.getAssetEntryResults(searchContainer, assetEntryQuery, layout, portletPreferences, StringPool.BLANK, null, null, company.getCompanyId(), importedGroup.getGroupId(), TestPropsValues.getUserId(), assetEntryQuery.getClassNameIds(), null); List<AssetEntry> actualAssetEntries = new ArrayList<>(); for (AssetEntryResult assetEntryResult : actualAssetEntryResults) { actualAssetEntries.addAll(assetEntryResult.getAssetEntries()); } assertAssetEntries(expectedAssetEntries, actualAssetEntries); }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
protected static List<AssetEntryResult> getAssetEntryResultsByClassName(SearchContainer searchContainer, AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, long[] classNameIds, Map<String, Serializable> attributes) throws Exception { List<AssetEntryResult> assetEntryResults = new ArrayList<>(); int end = searchContainer.getEnd(); int start = searchContainer.getStart(); int total = 0; for (long classNameId : classNameIds) { assetEntryQuery.setClassNameIds(new long[] { classNameId }); BaseModelSearchResult<AssetEntry> baseModelSearchResult = getAssetEntries(assetEntryQuery, layout, portletPreferences, portletName, locale, timeZone, companyId, scopeGroupId, userId, attributes, start, end);/*from w w w . j a v a 2 s .c o m*/ int groupTotal = baseModelSearchResult.getLength(); total += groupTotal; List<AssetEntry> assetEntries = baseModelSearchResult.getBaseModels(); if (!assetEntries.isEmpty() && (start < groupTotal)) { AssetRendererFactory<?> groupAssetRendererFactory = AssetRendererFactoryRegistryUtil .getAssetRendererFactoryByClassNameId(classNameId); String title = ResourceActionsUtil.getModelResource(locale, groupAssetRendererFactory.getClassName()); assetEntryResults.add(new AssetEntryResult(title, assetEntries)); } if (!portletName.equals(AssetPublisherPortletKeys.RECENT_CONTENT)) { if (groupTotal > 0) { if ((end > 0) && (end > groupTotal)) { end -= groupTotal; } else { end = 0; } if ((start > 0) && (start > groupTotal)) { start -= groupTotal; } else { start = 0; } } assetEntryQuery.setEnd(QueryUtil.ALL_POS); assetEntryQuery.setStart(QueryUtil.ALL_POS); } } searchContainer.setTotal(total); return assetEntryResults; }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
protected static List<AssetEntryResult> getAssetEntryResultsByDefault(SearchContainer searchContainer, AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, long[] classNameIds, Map<String, Serializable> attributes) throws Exception { List<AssetEntryResult> assetEntryResults = new ArrayList<>(); int end = searchContainer.getEnd(); int start = searchContainer.getStart(); assetEntryQuery.setClassNameIds(classNameIds); BaseModelSearchResult<AssetEntry> baseModelSearchResult = getAssetEntries(assetEntryQuery, layout, portletPreferences, portletName, locale, timeZone, companyId, scopeGroupId, userId, attributes, start, end);/*from w w w. j a va 2s. c o m*/ int total = baseModelSearchResult.getLength(); searchContainer.setTotal(total); List<AssetEntry> assetEntries = baseModelSearchResult.getBaseModels(); if (!assetEntries.isEmpty() && (start < total)) { assetEntryResults.add(new AssetEntryResult(assetEntries)); } return assetEntryResults; }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
protected static List<AssetEntryResult> getAssetEntryResultsByVocabulary(SearchContainer searchContainer, AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, long[] classNameIds, long assetVocabularyId, Map<String, Serializable> attributes) throws Exception { List<AssetEntryResult> assetEntryResults = new ArrayList<>(); List<AssetCategory> assetCategories = _assetCategoryLocalService .getVocabularyRootCategories(assetVocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); assetEntryQuery.setClassNameIds(classNameIds); int end = searchContainer.getEnd(); int start = searchContainer.getStart(); int total = 0; for (AssetCategory assetCategory : assetCategories) { long[] oldAllCategoryIds = assetEntryQuery.getAllCategoryIds(); long[] newAllAssetCategoryIds = ArrayUtil.append(oldAllCategoryIds, assetCategory.getCategoryId()); assetEntryQuery.setAllCategoryIds(newAllAssetCategoryIds); BaseModelSearchResult<AssetEntry> baseModelSearchResult = getAssetEntries(assetEntryQuery, layout, portletPreferences, portletName, locale, timeZone, companyId, scopeGroupId, userId, attributes, start, end);// ww w. java 2 s .c o m int groupTotal = baseModelSearchResult.getLength(); total += groupTotal; List<AssetEntry> assetEntries = baseModelSearchResult.getBaseModels(); if (!assetEntries.isEmpty() && (start < groupTotal)) { String title = assetCategory.getTitle(locale); assetEntryResults.add(new AssetEntryResult(title, assetEntries)); } if (groupTotal > 0) { if ((end > 0) && (end > groupTotal)) { end -= groupTotal; } else { end = 0; } if ((start > 0) && (start > groupTotal)) { start -= groupTotal; } else { start = 0; } } assetEntryQuery.setAllCategoryIds(oldAllCategoryIds); assetEntryQuery.setEnd(QueryUtil.ALL_POS); assetEntryQuery.setStart(QueryUtil.ALL_POS); } searchContainer.setTotal(total); return assetEntryResults; }