Example usage for com.liferay.portal.kernel.dao.search SearchContainer setEmptyResultsMessageCssClass

List of usage examples for com.liferay.portal.kernel.dao.search SearchContainer setEmptyResultsMessageCssClass

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.search SearchContainer setEmptyResultsMessageCssClass.

Prototype

public void setEmptyResultsMessageCssClass(String emptyResultsMessageCssClass) 

Source Link

Usage

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;
    }//  w ww  . j a v a  2  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;
    }//from   www. java  2  s .  c  om

    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  ww  w . j a  va2  s  . c om*/

    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.tags.admin.web.internal.display.context.AssetTagsDisplayContext.java

License:Open Source License

public SearchContainer getTagsSearchContainer() throws PortalException {
    if (_tagsSearchContainer != null) {
        return _tagsSearchContainer;
    }/*  w w w  . ja va2s .c om*/

    SearchContainer tagsSearchContainer = new SearchContainer(_renderRequest, _renderResponse.createRenderURL(),
            null, "there-are-no-tags");

    String keywords = getKeywords();

    if (Validator.isNull(keywords)) {
        if (isShowAddButton()) {
            tagsSearchContainer.setEmptyResultsMessage("there-are-no-tags.-you-can-add-a-tag-by-clicking-the-"
                    + "plus-button-on-the-bottom-right-corner");
            tagsSearchContainer
                    .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
        }
    } else {
        tagsSearchContainer.setSearch(true);
    }

    tagsSearchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse));

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    if (Validator.isNotNull(keywords)) {
        Sort sort = null;

        String orderByCol = getOrderByCol();

        if (orderByCol.equals("name")) {
            sort = SortFactoryUtil.getSort(AssetTag.class, Sort.STRING_TYPE, Field.NAME, getOrderByType());
        } else if (orderByCol.equals("usages")) {
            sort = SortFactoryUtil.getSort(AssetTag.class, Sort.INT_TYPE, "assetCount_Number",
                    getOrderByType());
        }

        BaseModelSearchResult<AssetTag> baseModelSearchResult = AssetTagLocalServiceUtil.searchTags(
                new long[] { themeDisplay.getScopeGroupId() }, keywords, tagsSearchContainer.getStart(),
                tagsSearchContainer.getEnd(), sort);

        tagsSearchContainer.setResults(baseModelSearchResult.getBaseModels());
        tagsSearchContainer.setTotal(baseModelSearchResult.getLength());
    } else {
        String orderByCol = getOrderByCol();

        tagsSearchContainer.setOrderByCol(orderByCol);

        OrderByComparator<AssetTag> orderByComparator = null;

        boolean orderByAsc = false;

        String orderByType = getOrderByType();

        if (orderByType.equals("asc")) {
            orderByAsc = true;
        }

        if (orderByCol.equals("name")) {
            orderByComparator = new AssetTagNameComparator(orderByAsc);
        } else if (orderByCol.equals("usages")) {
            orderByComparator = new AssetTagAssetCountComparator(orderByAsc);
        }

        tagsSearchContainer.setOrderByComparator(orderByComparator);

        tagsSearchContainer.setOrderByType(orderByType);

        long scopeGroupId = themeDisplay.getScopeGroupId();

        int tagsCount = AssetTagServiceUtil.getTagsCount(scopeGroupId, keywords);

        tagsSearchContainer.setTotal(tagsCount);

        List<AssetTag> tags = AssetTagServiceUtil.getTags(scopeGroupId, StringPool.BLANK,
                tagsSearchContainer.getStart(), tagsSearchContainer.getEnd(),
                tagsSearchContainer.getOrderByComparator());

        tagsSearchContainer.setResults(tags);
    }

    _tagsSearchContainer = tagsSearchContainer;

    return _tagsSearchContainer;
}

From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java

License:Open Source License

public SearchContainer getSearchContainer(boolean showVersions) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    SearchContainer articleSearchContainer = new SearchContainer(_liferayPortletRequest, getPortletURL(), null,
            null);//w  w w.j  a  v a2s  .  c  o  m

    if (!isSearch()) {
        articleSearchContainer
                .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
    } else {
        articleSearchContainer.setSearch(true);
    }

    OrderByComparator<JournalArticle> orderByComparator = JournalPortletUtil
            .getArticleOrderByComparator(getOrderByCol(), getOrderByType());

    articleSearchContainer.setOrderByCol(getOrderByCol());
    articleSearchContainer.setOrderByComparator(orderByComparator);
    articleSearchContainer.setOrderByType(getOrderByType());

    EntriesChecker entriesChecker = new EntriesChecker(_liferayPortletRequest, _liferayPortletResponse);

    entriesChecker.setCssClass("entry-selector");
    entriesChecker.setRememberCheckBoxStateURLRegex(
            "^(?!.*" + _liferayPortletResponse.getNamespace() + "redirect).*(folderId=" + getFolderId() + ")");

    articleSearchContainer.setRowChecker(entriesChecker);

    EntriesMover entriesMover = new EntriesMover(themeDisplay.getScopeGroupId());

    articleSearchContainer.setRowMover(entriesMover);

    if (isNavigationMine() || isNavigationRecent()) {
        boolean includeOwner = true;

        if (isNavigationMine()) {
            includeOwner = false;
        }

        if (isNavigationRecent()) {
            articleSearchContainer.setOrderByCol("create-date");
            articleSearchContainer.setOrderByType(getOrderByType());
        }

        int total = JournalArticleServiceUtil.getGroupArticlesCount(themeDisplay.getScopeGroupId(),
                themeDisplay.getUserId(), getFolderId(), getStatus(), includeOwner);

        articleSearchContainer.setTotal(total);

        List results = JournalArticleServiceUtil.getGroupArticles(themeDisplay.getScopeGroupId(),
                themeDisplay.getUserId(), getFolderId(), getStatus(), includeOwner,
                articleSearchContainer.getStart(), articleSearchContainer.getEnd(),
                articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
    } else if (Validator.isNotNull(getDDMStructureKey())) {
        int total = JournalArticleServiceUtil.getArticlesCountByStructureId(themeDisplay.getScopeGroupId(),
                getDDMStructureKey(), getStatus());

        articleSearchContainer.setTotal(total);

        List results = JournalArticleServiceUtil.getArticlesByStructureId(themeDisplay.getScopeGroupId(),
                getDDMStructureKey(), getStatus(), articleSearchContainer.getStart(),
                articleSearchContainer.getEnd(), articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
    } else if (Validator.isNotNull(getDDMTemplateKey())) {
        List<Long> folderIds = new ArrayList<>(1);

        if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

            folderIds.add(getFolderId());
        }

        int total = JournalArticleServiceUtil.searchCount(themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(), null);

        articleSearchContainer.setTotal(total);

        List results = JournalArticleServiceUtil.search(themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(), null,
                articleSearchContainer.getStart(), articleSearchContainer.getEnd(),
                articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
    } else if (isSearch()) {
        List<Long> folderIds = new ArrayList<>(1);

        if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

            folderIds.add(getFolderId());
        }

        JournalWebConfiguration journalWebConfiguration = (JournalWebConfiguration) _request
                .getAttribute(JournalWebConfiguration.class.getName());

        if (journalWebConfiguration.journalArticlesSearchWithIndex()) {
            boolean orderByAsc = false;

            if (Objects.equals(getOrderByType(), "asc")) {
                orderByAsc = true;
            }

            Sort sort = null;

            if (Objects.equals(getOrderByCol(), "display-date")) {
                sort = new Sort("displayDate", Sort.LONG_TYPE, orderByAsc);
            } else if (Objects.equals(getOrderByCol(), "id")) {
                sort = new Sort(DocumentImpl.getSortableFieldName(Field.ARTICLE_ID), Sort.STRING_TYPE,
                        !orderByAsc);
            } else if (Objects.equals(getOrderByCol(), "modified-date")) {
                sort = new Sort(Field.MODIFIED_DATE, Sort.LONG_TYPE, orderByAsc);
            } else if (Objects.equals(getOrderByCol(), "title")) {
                sort = new Sort("title", Sort.STRING_TYPE, !orderByAsc);
            }

            LinkedHashMap<String, Object> params = new LinkedHashMap<>();

            params.put("expandoAttributes", getKeywords());

            Indexer indexer = JournalSearcher.getInstance();

            SearchContext searchContext = buildSearchContext(themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                    getDDMStructureKey(), getDDMTemplateKey(), getKeywords(), params,
                    articleSearchContainer.getStart(), articleSearchContainer.getEnd(), sort, showVersions);

            Hits hits = indexer.search(searchContext);

            int total = hits.getLength();

            articleSearchContainer.setTotal(total);

            List results = new ArrayList<>();

            Document[] documents = hits.getDocs();

            for (int i = 0; i < documents.length; i++) {
                Document document = documents[i];

                JournalArticle article = null;
                JournalFolder folder = null;

                String className = document.get(Field.ENTRY_CLASS_NAME);
                long classPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

                if (className.equals(JournalArticle.class.getName())) {
                    if (!showVersions) {
                        article = JournalArticleLocalServiceUtil.fetchLatestArticle(classPK,
                                WorkflowConstants.STATUS_ANY, false);
                    } else {
                        String articleId = document.get(Field.ARTICLE_ID);
                        long groupId = GetterUtil.getLong(document.get(Field.GROUP_ID));
                        double version = GetterUtil.getDouble(document.get(Field.VERSION));

                        article = JournalArticleLocalServiceUtil.fetchArticle(groupId, articleId, version);
                    }

                    results.add(article);
                } else if (className.equals(JournalFolder.class.getName())) {
                    folder = JournalFolderLocalServiceUtil.getFolder(classPK);

                    results.add(folder);
                }
            }

            articleSearchContainer.setResults(results);
        } else {
            int total = JournalArticleServiceUtil.searchCount(themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                    getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(),
                    null);

            articleSearchContainer.setTotal(total);

            List results = JournalArticleServiceUtil.search(themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                    getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(),
                    null, articleSearchContainer.getStart(), articleSearchContainer.getEnd(),
                    articleSearchContainer.getOrderByComparator());

            articleSearchContainer.setResults(results);
        }
    } else {
        int total = JournalFolderServiceUtil.getFoldersAndArticlesCount(themeDisplay.getScopeGroupId(), 0,
                getFolderId(), getStatus());

        articleSearchContainer.setTotal(total);

        OrderByComparator<Object> folderOrderByComparator = null;

        boolean orderByAsc = false;

        if (Objects.equals(getOrderByType(), "asc")) {
            orderByAsc = true;
        }

        if (Objects.equals(getOrderByCol(), "display-date")) {
            folderOrderByComparator = new FolderArticleDisplayDateComparator(orderByAsc);
        } else if (Objects.equals(getOrderByCol(), "id")) {
            folderOrderByComparator = new FolderArticleArticleIdComparator(orderByAsc);
        } else if (Objects.equals(getOrderByCol(), "modified-date")) {
            folderOrderByComparator = new FolderArticleModifiedDateComparator(orderByAsc);
        } else if (Objects.equals(getOrderByCol(), "title")) {
            folderOrderByComparator = new FolderArticleTitleComparator(orderByAsc);
        }

        List results = JournalFolderServiceUtil.getFoldersAndArticles(themeDisplay.getScopeGroupId(), 0,
                getFolderId(), getStatus(), themeDisplay.getLocale(), articleSearchContainer.getStart(),
                articleSearchContainer.getEnd(), folderOrderByComparator);

        articleSearchContainer.setResults(results);
    }

    return articleSearchContainer;
}

From source file:com.liferay.layout.admin.web.internal.display.context.LayoutPageTemplateDisplayContext.java

License:Open Source License

public SearchContainer getLayoutPageTemplateCollectionsSearchContainer() throws PortalException {

    if (_layoutPageTemplateCollectionsSearchContainer != null) {
        return _layoutPageTemplateCollectionsSearchContainer;
    }//w  w  w  . j av a2s  . c om

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    SearchContainer layoutPageTemplateCollectionsSearchContainer = new SearchContainer(_renderRequest,
            _renderResponse.createRenderURL(), null, "there-are-no-collections");

    if (!isSearch()) {
        layoutPageTemplateCollectionsSearchContainer
                .setEmptyResultsMessage("there-are-no-collections.-you-can-add-a-collection-by-"
                        + "clicking-the-plus-button-on-the-bottom-right-corner");

        layoutPageTemplateCollectionsSearchContainer
                .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
    } else {
        layoutPageTemplateCollectionsSearchContainer.setSearch(true);
    }

    layoutPageTemplateCollectionsSearchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse));

    layoutPageTemplateCollectionsSearchContainer.setOrderByCol(getOrderByCol());

    OrderByComparator<LayoutPageTemplateCollection> orderByComparator = LayoutPageTemplatePortletUtil
            .getLayoutPageTemplateCollectionOrderByComparator(getOrderByCol(), getOrderByType());

    layoutPageTemplateCollectionsSearchContainer.setOrderByComparator(orderByComparator);

    layoutPageTemplateCollectionsSearchContainer.setOrderByType(getOrderByType());
    layoutPageTemplateCollectionsSearchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse));

    List<LayoutPageTemplateCollection> layoutPageTemplateCollections = null;
    int layoutPageTemplateCollectionsCount = 0;

    if (isSearch()) {
        layoutPageTemplateCollections = LayoutPageTemplateCollectionServiceUtil
                .getLayoutPageTemplateCollections(themeDisplay.getScopeGroupId(), getKeywords(),
                        layoutPageTemplateCollectionsSearchContainer.getStart(),
                        layoutPageTemplateCollectionsSearchContainer.getEnd(), orderByComparator);

        layoutPageTemplateCollectionsCount = LayoutPageTemplateCollectionServiceUtil
                .getLayoutPageTemplateCollectionsCount(themeDisplay.getScopeGroupId(), getKeywords());
    } else {
        layoutPageTemplateCollections = LayoutPageTemplateCollectionServiceUtil
                .getLayoutPageTemplateCollections(themeDisplay.getScopeGroupId(),
                        layoutPageTemplateCollectionsSearchContainer.getStart(),
                        layoutPageTemplateCollectionsSearchContainer.getEnd(), orderByComparator);

        layoutPageTemplateCollectionsCount = LayoutPageTemplateCollectionServiceUtil
                .getLayoutPageTemplateCollectionsCount(themeDisplay.getScopeGroupId());
    }

    layoutPageTemplateCollectionsSearchContainer.setTotal(layoutPageTemplateCollectionsCount);

    layoutPageTemplateCollectionsSearchContainer.setResults(layoutPageTemplateCollections);

    _layoutPageTemplateCollectionsSearchContainer = layoutPageTemplateCollectionsSearchContainer;

    return _layoutPageTemplateCollectionsSearchContainer;
}

From source file:com.liferay.layout.admin.web.internal.display.context.LayoutPageTemplateDisplayContext.java

License:Open Source License

public SearchContainer getLayoutPageTemplateEntriesSearchContainer() throws PortalException {

    if (_layoutPageTemplateEntriesSearchContainer != null) {
        return _layoutPageTemplateEntriesSearchContainer;
    }//from  ww w  .  j ava 2s .c  o m

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    SearchContainer layoutPageTemplateEntriesSearchContainer = new SearchContainer(_renderRequest,
            _renderResponse.createRenderURL(), null, "there-are-no-page-templates");

    if (!isSearch()) {
        layoutPageTemplateEntriesSearchContainer
                .setEmptyResultsMessage("there-are-no-page-templates.-you-can-add-a-page-template-by-"
                        + "clicking-the-plus-button-on-the-bottom-right-corner");
        layoutPageTemplateEntriesSearchContainer
                .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
    } else {
        layoutPageTemplateEntriesSearchContainer.setSearch(true);
    }

    layoutPageTemplateEntriesSearchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse));

    layoutPageTemplateEntriesSearchContainer.setOrderByCol(getOrderByCol());

    OrderByComparator<LayoutPageTemplateEntry> orderByComparator = LayoutPageTemplatePortletUtil
            .getLayoutPageTemplateEntryOrderByComparator(getOrderByCol(), getOrderByType());

    layoutPageTemplateEntriesSearchContainer.setOrderByComparator(orderByComparator);

    layoutPageTemplateEntriesSearchContainer.setOrderByType(getOrderByType());

    List<LayoutPageTemplateEntry> layoutPageTemplateEntries = null;
    int layoutPageTemplateEntriesCount = 0;

    if (isSearch()) {
        layoutPageTemplateEntries = LayoutPageTemplateEntryLocalServiceUtil.getLayoutPageTemplateEntries(
                themeDisplay.getScopeGroupId(), getLayoutPageTemplateCollectionId(), getKeywords(),
                layoutPageTemplateEntriesSearchContainer.getStart(),
                layoutPageTemplateEntriesSearchContainer.getEnd(), orderByComparator);

        layoutPageTemplateEntriesCount = LayoutPageTemplateEntryServiceUtil.getLayoutPageTemplateEntriesCount(
                themeDisplay.getScopeGroupId(), getLayoutPageTemplateCollectionId(), getKeywords());
    } else {
        layoutPageTemplateEntries = LayoutPageTemplateEntryLocalServiceUtil.getLayoutPageTemplateEntries(
                themeDisplay.getScopeGroupId(), getLayoutPageTemplateCollectionId(),
                layoutPageTemplateEntriesSearchContainer.getStart(),
                layoutPageTemplateEntriesSearchContainer.getEnd(), orderByComparator);

        layoutPageTemplateEntriesCount = LayoutPageTemplateEntryServiceUtil.getLayoutPageTemplateEntriesCount(
                themeDisplay.getScopeGroupId(), getLayoutPageTemplateCollectionId());
    }

    layoutPageTemplateEntriesSearchContainer.setResults(layoutPageTemplateEntries);
    layoutPageTemplateEntriesSearchContainer.setTotal(layoutPageTemplateEntriesCount);

    _layoutPageTemplateEntriesSearchContainer = layoutPageTemplateEntriesSearchContainer;

    return _layoutPageTemplateEntriesSearchContainer;
}

From source file:com.liferay.layout.admin.web.internal.display.context.LayoutsAdminDisplayContext.java

License:Open Source License

public SearchContainer getLayoutsSearchContainer() throws PortalException {
    if (_layoutsSearchContainer != null) {
        return _layoutsSearchContainer;
    }/*www  .  j a v a 2 s.  com*/

    String emptyResultMessage = "there-are-no-public-pages";

    if (isPrivatePages()) {
        emptyResultMessage = "there-are-no-private-pages";
    }

    SearchContainer layoutsSearchContainer = new SearchContainer(_liferayPortletRequest, getPortletURL(), null,
            emptyResultMessage);

    if (isShowAddRootLayoutButton()) {
        layoutsSearchContainer
                .setEmptyResultsMessageCssClass("there-are-no-layouts.-you-can-add-a-layout-by-clicking-the-"
                        + "plus-button-on-the-bottom-right-corner");
        layoutsSearchContainer
                .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
    }

    layoutsSearchContainer.setOrderByCol(getOrderByCol());

    OrderByComparator orderByComparator = _getOrderByComparator();

    layoutsSearchContainer.setOrderByComparator(orderByComparator);

    layoutsSearchContainer.setOrderByType(getOrderByType());

    EmptyOnClickRowChecker emptyOnClickRowChecker = new EmptyOnClickRowChecker(_liferayPortletResponse);

    layoutsSearchContainer.setRowChecker(emptyOnClickRowChecker);

    int layoutsCount = LayoutLocalServiceUtil.getLayoutsCount(getSelGroup(), isPrivatePages());
    List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(getSelGroupId(), isPrivatePages(),
            layoutsSearchContainer.getStart(), layoutsSearchContainer.getEnd(), orderByComparator);

    layoutsSearchContainer.setTotal(layoutsCount);
    layoutsSearchContainer.setResults(layouts);

    _layoutsSearchContainer = layoutsSearchContainer;

    return _layoutsSearchContainer;
}

From source file:com.liferay.layout.prototype.web.internal.display.context.LayoutPrototypeDisplayContext.java

License:Open Source License

public SearchContainer getSearchContainer() {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    SearchContainer searchContainer = new SearchContainer(_renderRequest, _renderResponse.createRenderURL(),
            null, "there-are-no-page-templates");

    if (isShowAddButton()) {
        searchContainer
                .setEmptyResultsMessageCssClass("there-are-no-page-templates.-you-can-add-a-page-template-by-"
                        + "clicking-the-plus-button-on-the-bottom-right-corner");
        searchContainer.setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
    }//  ww w.ja va  2  s  .com

    searchContainer.setId("layoutPrototype");
    searchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse));

    boolean orderByAsc = false;

    if (getOrderByType().equals("asc")) {
        orderByAsc = true;
    }

    OrderByComparator<LayoutPrototype> orderByComparator = new LayoutPrototypeCreateDateComparator(orderByAsc);

    searchContainer.setOrderByCol(getOrderByCol());
    searchContainer.setOrderByComparator(orderByComparator);
    searchContainer.setOrderByType(getOrderByType());

    searchContainer.setTotal(getTotal());

    List results = LayoutPrototypeLocalServiceUtil.search(themeDisplay.getCompanyId(), getActive(),
            searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator());

    searchContainer.setResults(results);

    return searchContainer;
}

From source file:com.liferay.layout.set.prototype.web.internal.display.context.LayoutSetPrototypeDisplayContext.java

License:Open Source License

public SearchContainer getSearchContainer() {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    SearchContainer searchContainer = new SearchContainer(_renderRequest, _renderResponse.createRenderURL(),
            null, "there-are-no-site-templates");

    if (isShowAddButton()) {
        searchContainer.setEmptyResultsMessage("there-are-no-site-templates.-you-can-add-a-site-template-by-"
                + "clicking-the-plus-button-on-the-bottom-right-corner");
        searchContainer.setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
    }/*from  w w  w .  jav  a 2 s . c  om*/

    searchContainer.setId("layoutSetPrototype");
    searchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse));

    boolean orderByAsc = false;

    if (getOrderByType().equals("asc")) {
        orderByAsc = true;
    }

    OrderByComparator<LayoutSetPrototype> orderByComparator = new LayoutSetPrototypeCreateDateComparator(
            orderByAsc);

    searchContainer.setOrderByCol(getOrderByCol());
    searchContainer.setOrderByComparator(orderByComparator);
    searchContainer.setOrderByType(getOrderByType());

    searchContainer.setTotal(getTotal());

    List results = LayoutSetPrototypeLocalServiceUtil.search(themeDisplay.getCompanyId(), getActive(),
            searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator());

    searchContainer.setResults(results);

    return searchContainer;
}