Example usage for com.liferay.portal.kernel.search BaseModelSearchResult BaseModelSearchResult

List of usage examples for com.liferay.portal.kernel.search BaseModelSearchResult BaseModelSearchResult

Introduction

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

Prototype

public BaseModelSearchResult(List<T> baseModels, int length) 

Source Link

Usage

From source file:com.liferay.asset.internal.util.AssetHelperImpl.java

License:Open Source License

@Override
public BaseModelSearchResult<AssetEntry> searchAssetEntries(SearchContext searchContext,
        AssetEntryQuery assetEntryQuery, int start, int end) throws Exception {

    AssetSearcher assetSearcher = _getAssetSearcher(searchContext, assetEntryQuery, start, end);

    Hits hits = assetSearcher.search(searchContext);

    List<AssetEntry> assetEntries = getAssetEntries(hits);

    return new BaseModelSearchResult<>(assetEntries, hits.getLength());
}

From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java

License:Open Source License

@Override
public BaseModelSearchResult<AssetEntry> getAssetEntries(AssetEntryQuery assetEntryQuery, Layout layout,
        PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone,
        long companyId, long scopeGroupId, long userId, Map<String, Serializable> attributes, int start,
        int end) throws Exception {

    if (_isSearchWithIndex(portletName, assetEntryQuery)) {
        return _assetHelper.searchAssetEntries(assetEntryQuery, getAssetCategoryIds(portletPreferences),
                getAssetTagNames(portletPreferences), attributes, companyId, assetEntryQuery.getKeywords(),
                layout, locale, scopeGroupId, timeZone, userId, start, end);
    }/*from ww w.  j a  va2s . co m*/

    int total = _assetEntryService.getEntriesCount(assetEntryQuery);

    assetEntryQuery.setEnd(end);
    assetEntryQuery.setStart(start);

    List<AssetEntry> results = _assetEntryService.getEntries(assetEntryQuery);

    return new BaseModelSearchResult<>(results, total);
}

From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java

License:Open Source License

public static BaseModelSearchResult<AssetEntry> getAssetEntries(AssetEntryQuery assetEntryQuery, Layout layout,
        PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone,
        long companyId, long scopeGroupId, long userId, Map<String, Serializable> attributes, int start,
        int end) throws Exception {

    if (isSearchWithIndex(portletName, assetEntryQuery)) {
        return _assetHelper.searchAssetEntries(assetEntryQuery, getAssetCategoryIds(portletPreferences),
                getAssetTagNames(portletPreferences), attributes, companyId, assetEntryQuery.getKeywords(),
                layout, locale, scopeGroupId, timeZone, userId, start, end);
    }//from  ww  w  .  j a  va2  s. c o m

    int total = _assetEntryService.getEntriesCount(assetEntryQuery);

    assetEntryQuery.setEnd(end);
    assetEntryQuery.setStart(start);

    List<AssetEntry> results = _assetEntryService.getEntries(assetEntryQuery);

    return new BaseModelSearchResult<>(results, total);
}

From source file:com.liferay.dynamic.data.lists.service.impl.DDLRecordLocalServiceImpl.java

License:Open Source License

/**
 * Searches for records documents indexed by the search engine.
 *
 * @param  searchContext the search context to be applied for searching
 *         documents. For more information, see <code>SearchContext</code>
 *         in the <code>portal-kernel</code> module.
 * @return BaseModelSearchResult containing the list of records that matched
 *         the search criteria/* www  .j  a  va2s . c o  m*/
 */
@Override
public BaseModelSearchResult<DDLRecord> searchDDLRecords(SearchContext searchContext) {

    try {
        Indexer<DDLRecord> indexer = getDDLRecordIndexer();

        Hits hits = indexer.search(searchContext, DDL.SELECTED_FIELD_NAMES);

        List<DDLRecord> records = getRecords(hits);

        return new BaseModelSearchResult<>(records, hits.getLength());
    } catch (Exception e) {
        throw new SystemException(e);
    }
}

From source file:com.liferay.dynamic.data.mapping.service.impl.DDMFormInstanceRecordLocalServiceImpl.java

License:Open Source License

@Override
public BaseModelSearchResult<DDMFormInstanceRecord> searchFormInstanceRecords(SearchContext searchContext) {

    try {/*from  w  ww. j a  va 2  s . co m*/
        Indexer<DDMFormInstanceRecord> indexer = getDDMFormInstanceRecordIndexer();

        Hits hits = indexer.search(searchContext, _SELECTED_FIELD_NAMES);

        List<DDMFormInstanceRecord> formInstanceRecords = getFormInstanceRecords(hits);

        return new BaseModelSearchResult<>(formInstanceRecords, hits.getLength());
    } catch (Exception e) {
        throw new SystemException(e);
    }
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

protected BaseModelSearchResult<JournalArticle> searchJournalArticles(SearchContext searchContext)
        throws PortalException {

    Indexer<JournalArticle> indexer = IndexerRegistryUtil.nullSafeGetIndexer(JournalArticle.class);

    for (int i = 0; i < 10; i++) {
        Hits hits = indexer.search(searchContext, JournalUtil.SELECTED_FIELD_NAMES);

        List<JournalArticle> articles = JournalUtil.getArticles(hits);

        if (articles != null) {
            return new BaseModelSearchResult<>(articles, hits.getLength());
        }/*w w  w. j  a  va 2s.  c om*/
    }

    throw new SearchException("Unable to fix the search index after 10 attempts");
}

From source file:com.liferay.trash.internal.service.ModularTrashEntryLocalServiceWrapper.java

License:Open Source License

@Override
public BaseModelSearchResult<TrashEntry> searchTrashEntries(long companyId, long groupId, long userId,
        String keywords, int start, int end, Sort sort) {

    BaseModelSearchResult<com.liferay.trash.model.TrashEntry> baseModelSearchResult = _trashEntryLocalService
            .searchTrashEntries(companyId, groupId, userId, keywords, start, end, sort);

    return new BaseModelSearchResult<>(
            ModelAdapterUtil.adapt(TrashEntry.class, baseModelSearchResult.getBaseModels()),
            baseModelSearchResult.getLength());
}

From source file:com.liferay.trash.service.impl.TrashEntryLocalServiceImpl.java

License:Open Source License

@Override
public BaseModelSearchResult<TrashEntry> searchTrashEntries(long companyId, long groupId, long userId,
        String keywords, int start, int end, Sort sort) {

    try {/*  w  w w .  java  2  s.  co  m*/
        Indexer<TrashEntry> indexer = IndexerRegistryUtil.nullSafeGetIndexer(TrashEntry.class);

        SearchContext searchContext = buildSearchContext(companyId, groupId, userId, keywords, start, end,
                sort);

        Hits hits = indexer.search(searchContext);

        List<TrashEntry> trashEntries = _getEntries(hits);

        return new BaseModelSearchResult<>(trashEntries, hits.getLength());
    } catch (Exception e) {
        throw new SystemException(e);
    }
}