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

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

Introduction

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

Prototype

String SCOPE_GROUP_ID

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

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);/*ww  w . j a  va 2 s .co  m*/
    setFilterSearch(true);
    setPermissionAware(false);
}

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   w  w w .  ja va2s  .  com
    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.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);//  ww  w.jav  a2s.c om
    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  v a  2  s  .c o m*/
    setPermissionAware(true);
}

From source file:com.liferay.calendar.search.test.CalendarBookingIndexerIndexedFieldsTest.java

License:Open Source License

protected void populateCalendarResource(CalendarResource calendarResource, Map<String, String> map) {

    map.put(Field.COMPANY_ID, String.valueOf(calendarResource.getCompanyId()));
    map.put(Field.GROUP_ID, String.valueOf(calendarResource.getGroupId()));
    map.put(Field.SCOPE_GROUP_ID, String.valueOf(calendarResource.getGroupId()));
}

From source file:com.liferay.calendar.search.test.CalendarIndexerIndexedFieldsTest.java

License:Open Source License

protected void populateExpectedFieldValues(Calendar calendar, Map<String, String> map) throws Exception {

    map.put(Field.COMPANY_ID, String.valueOf(calendar.getCompanyId()));
    map.put(Field.DEFAULT_LANGUAGE_ID, calendar.getDefaultLanguageId());
    map.put(Field.ENTRY_CLASS_NAME, calendar.getModelClassName());
    map.put(Field.ENTRY_CLASS_PK, String.valueOf(calendar.getCalendarId()));
    map.put(Field.GROUP_ID, String.valueOf(calendar.getGroupId()));
    map.put(Field.SCOPE_GROUP_ID, String.valueOf(calendar.getGroupId()));
    map.put(Field.STAGING_GROUP, "false");
    map.put(Field.USER_ID, String.valueOf(calendar.getUserId()));
    map.put(Field.USER_NAME, StringUtil.toLowerCase(calendar.getUserName()));
    map.put("calendarId", String.valueOf(calendar.getCalendarId()));

    DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat("yyyyMMddHHmmss");

    populateCalendarDate(Field.CREATE_DATE, calendar.getCreateDate(), map, dateFormat);
    populateCalendarDate(Field.MODIFIED_DATE, calendar.getModifiedDate(), map, dateFormat);

    populateCalendarResource(calendar.getCalendarResource(), calendar, map);

    calendarFieldsFixture.populateGroupRoleId(map);
    calendarFieldsFixture.populateRoleId("Guest", map);
    calendarFieldsFixture.populateUID(calendar, map);
}

From source file:com.liferay.docs.guestbook.search.GuestbookEntrySearchRegistrar.java

License:Open Source License

@Activate
protected void activate(BundleContext bundleContext) {

    _serviceRegistration = modelSearchRegistrarHelper.register(GuestbookEntry.class, bundleContext,
            modelSearchDefinition -> {
                modelSearchDefinition.setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME,
                        Field.ENTRY_CLASS_PK, Field.UID, Field.SCOPE_GROUP_ID, Field.GROUP_ID);

                modelSearchDefinition.setDefaultSelectedLocalizedFieldNames(Field.TITLE, Field.CONTENT);

                modelSearchDefinition.setModelIndexWriteContributor(modelIndexWriterContributor);
                modelSearchDefinition.setModelSummaryContributor(modelSummaryContributor);
                modelSearchDefinition.setSelectAllLocales(true);

            });/*from  w w w.  jav a2  s.com*/
}

From source file:com.liferay.docs.guestbook.search.GuestbookSearchRegistrar.java

License:Open Source License

@Activate
protected void activate(BundleContext bundleContext) {

    _serviceRegistration = modelSearchRegistrarHelper.register(Guestbook.class, bundleContext,
            modelSearchDefinition -> {
                modelSearchDefinition.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);

                modelSearchDefinition.setModelIndexWriteContributor(modelIndexWriterContributor);
                modelSearchDefinition.setModelSummaryContributor(modelSummaryContributor);
            });//from  w  w  w  .j ava  2  s .  co m
}

From source file:com.liferay.journal.search.JournalArticleIndexer.java

License:Open Source License

public JournalArticleIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.ARTICLE_ID, Field.COMPANY_ID,
            Field.DEFAULT_LANGUAGE_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.GROUP_ID,
            Field.MODIFIED_DATE, Field.SCOPE_GROUP_ID, Field.VERSION, Field.UID);
    setDefaultSelectedLocalizedFieldNames(Field.CONTENT, Field.DESCRIPTION, Field.TITLE);
    setFilterSearch(true);//w  w  w  .j  av  a 2 s .  c o  m
    setPermissionAware(true);
    setSelectAllLocales(true);
}

From source file:com.liferay.journal.util.impl.JournalUtil.java

License:Open Source License

/**
 * @deprecated As of 4.0.0, with no direct replacement
 *//*from w ww  .j a va  2  s  .  c o m*/
@Deprecated
public static List<JournalArticle> getArticles(Hits hits) throws PortalException {

    List<com.liferay.portal.kernel.search.Document> documents = hits.toList();

    List<JournalArticle> articles = new ArrayList<>(documents.size());

    for (com.liferay.portal.kernel.search.Document document : documents) {
        String articleId = document.get(Field.ARTICLE_ID);
        long groupId = GetterUtil.getLong(document.get(Field.SCOPE_GROUP_ID));

        JournalArticle article = JournalArticleLocalServiceUtil.fetchLatestArticle(groupId, articleId,
                WorkflowConstants.STATUS_APPROVED);

        if (article == null) {
            articles = null;

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

            long companyId = GetterUtil.getLong(document.get(Field.COMPANY_ID));

            indexer.delete(companyId, document.getUID());
        } else if (articles != null) {
            articles.add(article);
        }
    }

    return articles;
}