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

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

Introduction

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

Prototype

public void setEmptyResultsMessage(String emptyResultsMessage) 

Source Link

Usage

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   w  ww .  java  2  s  .  c  o m

    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  2s . com*/

    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 .j  a  v  a  2  s.  c o  m

    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.layout.admin.web.internal.display.context.LayoutPageTemplateDisplayContext.java

License:Open Source License

public SearchContainer getLayoutPageTemplateCollectionsSearchContainer() throws PortalException {

    if (_layoutPageTemplateCollectionsSearchContainer != null) {
        return _layoutPageTemplateCollectionsSearchContainer;
    }/*from  w  ww  . j av  a 2s  . 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  w w  w . j a v a 2  s  .  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.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.ja  v a2s.co m

    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;
}

From source file:com.liferay.message.boards.web.internal.display.context.DefaultMBListDisplayContext.java

License:Open Source License

@Override
public void populateResultsAndTotal(SearchContainer searchContainer) throws PortalException {

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

    if (isShowSearch()) {
        long searchCategoryId = ParamUtil.getLong(_request, "searchCategoryId");

        long[] categoryIdsArray = null;

        List categoryIds = new ArrayList();

        categoryIds.add(Long.valueOf(searchCategoryId));

        MBCategoryServiceUtil.getSubcategoryIds(categoryIds, themeDisplay.getScopeGroupId(), searchCategoryId);

        categoryIdsArray = StringUtil.split(StringUtil.merge(categoryIds), 0L);

        Indexer indexer = IndexerRegistryUtil.getIndexer(MBMessage.class);

        SearchContext searchContext = SearchContextFactory.getInstance(_request);

        searchContext.setAttribute("paginationType", "more");
        searchContext.setCategoryIds(categoryIdsArray);
        searchContext.setEnd(searchContainer.getEnd());
        searchContext.setIncludeAttachments(true);

        String keywords = ParamUtil.getString(_request, "keywords");

        searchContext.setKeywords(keywords);

        searchContext.setStart(searchContainer.getStart());

        Hits hits = indexer.search(searchContext);

        searchContainer.setResults(SearchResultUtil.getSearchResults(hits, _request.getLocale()));

        searchContainer.setSearch(true);
        searchContainer.setTotal(hits.getLength());
    } else if (isShowRecentPosts()) {
        searchContainer.setEmptyResultsMessage("there-are-no-recent-posts");

        long groupThreadsUserId = ParamUtil.getLong(_request, "groupThreadsUserId");

        Calendar calendar = Calendar.getInstance();

        MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings
                .getInstance(themeDisplay.getSiteGroupId());

        int offset = GetterUtil.getInteger(mbGroupServiceSettings.getRecentPostsDateOffset());

        calendar.add(Calendar.DATE, -offset);

        searchContainer.setTotal(MBThreadServiceUtil.getGroupThreadsCount(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, calendar.getTime(), WorkflowConstants.STATUS_APPROVED));
        searchContainer.setResults(MBThreadServiceUtil.getGroupThreads(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, calendar.getTime(), WorkflowConstants.STATUS_APPROVED,
                searchContainer.getStart(), searchContainer.getEnd()));
    } else if (isShowMyPosts()) {
        long groupThreadsUserId = ParamUtil.getLong(_request, "groupThreadsUserId");

        if (themeDisplay.isSignedIn()) {
            groupThreadsUserId = themeDisplay.getUserId();
        }/*  ww w.  j  av a2 s.  c o m*/

        int status = WorkflowConstants.STATUS_ANY;

        searchContainer.setTotal(MBThreadServiceUtil.getGroupThreadsCount(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, status));
        searchContainer.setResults(MBThreadServiceUtil.getGroupThreads(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, status, searchContainer.getStart(), searchContainer.getEnd()));
        searchContainer.setEmptyResultsMessage("you-do-not-have-any-posts");
    } else {
        int status = WorkflowConstants.STATUS_APPROVED;

        PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

        if (permissionChecker.isContentReviewer(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId())) {

            status = WorkflowConstants.STATUS_ANY;
        }

        searchContainer.setTotal(MBCategoryLocalServiceUtil
                .getCategoriesAndThreadsCount(themeDisplay.getScopeGroupId(), _categoryId, status));
        searchContainer.setResults(MBCategoryServiceUtil.getCategoriesAndThreads(themeDisplay.getScopeGroupId(),
                _categoryId, status, searchContainer.getStart(), searchContainer.getEnd()));
    }
}

From source file:com.liferay.site.teams.web.internal.display.context.SiteTeamsDisplayContext.java

License:Open Source License

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

    SearchContainer searchContainer = new TeamSearch(_renderRequest, getPortletURL());

    searchContainer.setEmptyResultsMessage("there-are-no-site-teams");

    if (Validator.isNull(getKeywords())) {
        if (isShowAddButton()) {
            searchContainer.setEmptyResultsMessage("there-are-no-site-teams.-you-can-add-a-site-team-by-"
                    + "clicking-the-plus-button-on-the-bottom-right-corner");
            searchContainer.setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
        }/*from   w  ww  .jav a  2 s. c o  m*/
    } else {
        searchContainer.setSearch(true);
    }

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

    searchContainer.setTotal(getTotal());

    List results = TeamServiceUtil.search(themeDisplay.getScopeGroupId(), getKeywords(), getKeywords(),
            new LinkedHashMap<String, Object>(), searchContainer.getStart(), searchContainer.getEnd(),
            searchContainer.getOrderByComparator());

    searchContainer.setResults(results);

    return searchContainer;
}