Example usage for com.liferay.portal.kernel.search Field ENTRY_CLASS_NAME

List of usage examples for com.liferay.portal.kernel.search Field ENTRY_CLASS_NAME

Introduction

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

Prototype

String ENTRY_CLASS_NAME

To view the source code for com.liferay.portal.kernel.search Field ENTRY_CLASS_NAME.

Click Source Link

Usage

From source file:ca.efendi.datafeeds.search.CJProductIndexer.java

License:Apache License

public CJProductIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.COMPANY_ID, Field.CONTENT, Field.ENTRY_CLASS_NAME,
            Field.ENTRY_CLASS_PK, Field.GROUP_ID, Field.MODIFIED_DATE, Field.SCOPE_GROUP_ID, Field.TITLE,
            Field.UID);//from  w  w w .  j a  va  2 s.c  om
    setFilterSearch(true);
    setPermissionAware(false);
}

From source file:com.cd.learning.hook.MBUtil.java

License:Open Source License

public static List<Object> getEntries(Hits hits) {
    List<Object> entries = new ArrayList<Object>();

    for (Document document : hits.getDocs()) {
        long categoryId = GetterUtil.getLong(document.get(Field.CATEGORY_ID));

        try {//  www.jav a  2s  . c om
            MBCategoryLocalServiceUtil.getCategory(categoryId);
        } catch (Exception e) {
            if (_log.isWarnEnabled()) {
                _log.warn("Message boards search index is stale and contains " + "category " + categoryId);
            }

            continue;
        }

        long threadId = GetterUtil.getLong(document.get("threadId"));

        try {
            MBThreadLocalServiceUtil.getThread(threadId);
        } catch (Exception e) {
            if (_log.isWarnEnabled()) {
                _log.warn("Message boards search index is stale and contains " + "thread " + threadId);
            }

            continue;
        }

        String entryClassName = document.get(Field.ENTRY_CLASS_NAME);
        long entryClassPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

        Object obj = null;

        try {
            if (entryClassName.equals(DLFileEntry.class.getName())) {
                long classPK = GetterUtil.getLong(document.get(Field.CLASS_PK));

                MBMessageLocalServiceUtil.getMessage(classPK);

                obj = DLFileEntryLocalServiceUtil.getDLFileEntry(entryClassPK);
            } else if (entryClassName.equals(MBMessage.class.getName())) {
                obj = MBMessageLocalServiceUtil.getMessage(entryClassPK);
            }

            entries.add(obj);
        } catch (Exception e) {
            if (_log.isWarnEnabled()) {
                _log.warn("Message boards search index is stale and contains " + "entry {className="
                        + entryClassName + ", " + "classPK=" + entryClassPK + "}");
            }

            continue;
        }
    }

    return entries;
}

From source file:com.ext.portlet.Activity.ActivityUtil.java

License:Open Source License

private static Hits getAggregatedActivitySearchResults(long userId, int start, int end) throws SearchException {
    SearchContext context = new SearchContext();
    context.setCompanyId(DEFAULT_COMPANY_ID);
    BooleanQuery query = BooleanQueryFactoryUtil.create(context);
    query.addRequiredTerm(Field.ENTRY_CLASS_NAME, SocialActivity.class.getName());

    BooleanQuery subQuery = BooleanQueryFactoryUtil.create(context);
    subQuery.addExactTerm("userId", userId);

    try {/*from   ww w. j a  v a2  s.  c om*/
        query.add(subQuery, BooleanClauseOccur.MUST);
    } catch (ParseException e) {
        _log.error(e);
    }

    Sort sort = SortFactoryUtil.create("createDate", Sort.FLOAT_TYPE, true);
    return SearchEngineUtil.search(SearchEngineUtil.getDefaultSearchEngineId(), context.getCompanyId(), query,
            sort, start, end);
}

From source file:com.ext.portlet.Activity.ActivityUtil.java

License:Open Source License

private static Hits getAggregatedActivitySearchResultsExcludingUsers(List<Long> excludedUserIds, int start,
        int end) throws SearchException {
    SearchContext context = new SearchContext();
    context.setCompanyId(DEFAULT_COMPANY_ID);
    BooleanQuery query = BooleanQueryFactoryUtil.create(context);
    query.addRequiredTerm(Field.ENTRY_CLASS_NAME, SocialActivity.class.getName());

    BooleanQuery excludeQuery = BooleanQueryFactoryUtil.create(context);
    for (Long excludedUserId : excludedUserIds) {
        excludeQuery.addExactTerm("userId", excludedUserId);
    }/*from w w w. j  a va2 s  . com*/

    try {
        query.add(excludeQuery, BooleanClauseOccurImpl.MUST_NOT);
    } catch (ParseException e) {
        _log.error(e);
    }

    Sort sort = SortFactoryUtil.create("createDate", Sort.FLOAT_TYPE, true);
    return SearchEngineUtil.search(SearchEngineUtil.getDefaultSearchEngineId(), context.getCompanyId(), query,
            sort, start, end);
}

From source file:com.inkwell.internet.slogan.search.SloganIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {

    Slogan slogan = (Slogan) obj;//from   www.jav a 2s  . c om
    long companyId = slogan.getCompanyId();
    long groupId = getParentGroupId(slogan.getGroupId());
    long scopeGroupId = slogan.getGroupId();
    long userId = slogan.getUserId();
    long resourcePrimKey = slogan.getPrimaryKey();
    String title = slogan.getSloganText();
    String content = slogan.getSloganText();
    String description = slogan.getSloganText();
    Date modifiedDate = slogan.getSloganDate();

    long[] assetCategoryIds = AssetCategoryLocalServiceUtil.getCategoryIds(Slogan.class.getName(),
            resourcePrimKey);

    List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getCategories(Slogan.class.getName(),
            resourcePrimKey);

    String[] assetCategoryNames = StringUtil.split(ListUtil.toString(categories, "name"));

    // EE lets you do this quicker: 

    // String[] assetCategoryNames =
    //     AssetCategoryLocalServiceUtil.getCategoryNames(
    //         Slogan.class.getName(), resourcePrimKey);

    String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(Slogan.class.getName(), resourcePrimKey);

    Document document = new DocumentImpl();

    document.addUID(PORTLET_ID, resourcePrimKey);

    document.addModifiedDate(modifiedDate);

    document.addKeyword(Field.COMPANY_ID, companyId);
    document.addKeyword(Field.PORTLET_ID, PORTLET_ID);
    document.addKeyword(Field.GROUP_ID, groupId);
    document.addKeyword(Field.SCOPE_GROUP_ID, scopeGroupId);
    document.addKeyword(Field.USER_ID, userId);
    document.addText(Field.TITLE, title);
    document.addText(Field.CONTENT, content);
    document.addText(Field.DESCRIPTION, description);
    document.addKeyword(Field.ASSET_CATEGORY_IDS, assetCategoryIds);
    document.addKeyword("assetCategoryNames", assetCategoryNames);
    //document.addKeyword(Field.ASSET_CATEGORY_NAMES, assetCategoryNames);
    document.addKeyword(Field.ASSET_TAG_NAMES, assetTagNames);

    document.addKeyword(Field.ENTRY_CLASS_NAME, Slogan.class.getName());
    document.addKeyword(Field.ENTRY_CLASS_PK, resourcePrimKey);

    return document;
}

From source file:com.liferay.asset.internal.search.AssetEntryIndexer.java

License:Open Source License

public AssetEntryIndexer() {
    setDefaultSelectedFieldNames(Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID);
}

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

License:Open Source License

@Override
public List<AssetEntry> getAssetEntries(Hits hits) {
    if (hits.getDocs() == null) {
        return Collections.emptyList();
    }/*from ww  w. jav  a 2 s  .  c om*/

    List<AssetEntry> assetEntries = new ArrayList<>();

    for (Document document : hits.getDocs()) {
        String className = GetterUtil.getString(document.get(Field.ENTRY_CLASS_NAME));
        long classPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

        AssetEntry assetEntry = _assetEntryLocalService.fetchEntry(className, classPK);

        if (assetEntry != null) {
            assetEntries.add(assetEntry);
        }
    }

    return assetEntries;
}

From source file:com.liferay.blogs.internal.search.BlogsEntryIndexer.java

License:Open Source License

public BlogsEntryIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.COMPANY_ID, Field.CONTENT, Field.ENTRY_CLASS_NAME,
            Field.ENTRY_CLASS_PK, Field.GROUP_ID, Field.MODIFIED_DATE, Field.SCOPE_GROUP_ID, Field.TITLE,
            Field.UID);/*from w  ww  .  j ava2 s  . c  o  m*/
    setFilterSearch(true);
    setPermissionAware(true);
}

From source file:com.liferay.bookmarks.search.BookmarksEntryIndexer.java

License:Open Source License

public BookmarksEntryIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.COMPANY_ID, Field.ENTRY_CLASS_NAME,
            Field.ENTRY_CLASS_PK, Field.GROUP_ID, Field.MODIFIED_DATE, Field.SCOPE_GROUP_ID, Field.TITLE,
            Field.UID, Field.URL);
    setFilterSearch(true);//from  w ww  .  ja va  2 s.  co  m
    setPermissionAware(true);
}

From source file:com.liferay.bookmarks.search.BookmarksFolderIndexer.java

License:Open Source License

public BookmarksFolderIndexer() {
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.TITLE,
            Field.UID);//from w ww. j  a  v  a 2s. c o  m
    setFilterSearch(true);
    setPermissionAware(true);
}