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:com.liferay.message.boards.internal.search.MBMessageIndexer.java

License:Open Source License

public MBMessageIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.CLASS_NAME_ID, Field.CLASS_PK, 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);
    setFilterSearch(true);//from w  w  w  .  j a v a  2s  . c o m
    setPermissionAware(true);
}

From source file:com.liferay.polls.internal.search.PollsQuestionIndexer.java

License:Open Source License

public PollsQuestionIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.CREATE_DATE, Field.COMPANY_ID, Field.DESCRIPTION,
            Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.GROUP_ID, Field.SCOPE_GROUP_ID, Field.TITLE,
            Field.UID);//from w w w.  j a va  2s . c o m
    setFilterSearch(true);
}

From source file:com.liferay.portlet.documentlibrary.store.DLStoreImpl.java

License:Open Source License

public Hits search(long companyId, long userId, String portletId, long groupId, long[] repositoryIds,
        String keywords, int start, int end) throws SystemException {

    try {// w w w.j a v a2 s . co m
        SearchContext searchContext = new SearchContext();

        searchContext.setCompanyId(companyId);
        searchContext.setEnd(end);
        searchContext.setEntryClassNames(new String[] { DLFileEntryConstants.getClassName() });
        searchContext.setGroupIds(new long[] { groupId });

        Indexer indexer = IndexerRegistryUtil.getIndexer(DLFileEntryConstants.getClassName());

        searchContext.setSearchEngineId(indexer.getSearchEngineId());

        searchContext.setStart(start);
        searchContext.setUserId(userId);

        BooleanQuery contextQuery = BooleanQueryFactoryUtil.create(searchContext);

        contextQuery.addRequiredTerm(Field.PORTLET_ID, portletId);

        if (groupId > 0) {
            Group group = groupLocalService.getGroup(groupId);

            if (group.isLayout()) {
                contextQuery.addRequiredTerm(Field.SCOPE_GROUP_ID, groupId);

                groupId = group.getParentGroupId();
            }

            contextQuery.addRequiredTerm(Field.GROUP_ID, groupId);
        }

        if ((repositoryIds != null) && (repositoryIds.length > 0)) {
            BooleanQuery repositoryIdsQuery = BooleanQueryFactoryUtil.create(searchContext);

            for (long repositoryId : repositoryIds) {
                try {
                    if (userId > 0) {
                        PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

                        DLFolderPermission.check(permissionChecker, groupId, repositoryId, ActionKeys.VIEW);
                    }

                    if (repositoryId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

                        repositoryId = groupId;
                    }

                    TermQuery termQuery = TermQueryFactoryUtil.create(searchContext, "repositoryId",
                            repositoryId);

                    repositoryIdsQuery.add(termQuery, BooleanClauseOccur.SHOULD);
                } catch (Exception e) {
                }
            }

            contextQuery.add(repositoryIdsQuery, BooleanClauseOccur.MUST);
        }

        BooleanQuery searchQuery = BooleanQueryFactoryUtil.create(searchContext);

        searchQuery.addTerms(_KEYWORDS_FIELDS, keywords);

        BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext);

        fullQuery.add(contextQuery, BooleanClauseOccur.MUST);

        if (searchQuery.clauses().size() > 0) {
            fullQuery.add(searchQuery, BooleanClauseOccur.MUST);
        }

        return SearchEngineUtil.search(searchContext, fullQuery);
    } catch (Exception e) {
        throw new SystemException(e);
    }
}

From source file:com.liferay.portlet.documentlibrary.util.DLIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    DLFileEntry dlFileEntry = (DLFileEntry) obj;

    if (_log.isDebugEnabled()) {
        _log.debug("Indexing document " + dlFileEntry);
    }// ww  w .  jav  a  2 s .  c  om

    boolean indexContent = true;

    InputStream is = null;

    try {
        if (PropsValues.DL_FILE_INDEXING_MAX_SIZE == 0) {
            indexContent = false;
        } else if (PropsValues.DL_FILE_INDEXING_MAX_SIZE != -1) {
            if (dlFileEntry.getSize() > PropsValues.DL_FILE_INDEXING_MAX_SIZE) {

                indexContent = false;
            }
        }

        if (indexContent) {
            String[] ignoreExtensions = PrefsPropsUtil
                    .getStringArray(PropsKeys.DL_FILE_INDEXING_IGNORE_EXTENSIONS, StringPool.COMMA);

            if (ArrayUtil.contains(ignoreExtensions, StringPool.PERIOD + dlFileEntry.getExtension())) {

                indexContent = false;
            }
        }

        if (indexContent) {
            is = dlFileEntry.getFileVersion().getContentStream(false);
        }
    } catch (Exception e) {
    }

    if (indexContent && (is == null)) {
        if (_log.isDebugEnabled()) {
            _log.debug("Document " + dlFileEntry + " does not have any content");
        }

        return null;
    }

    try {
        Document document = new DocumentImpl();

        long fileEntryId = dlFileEntry.getFileEntryId();

        document.addUID(PORTLET_ID, fileEntryId);

        List<AssetCategory> assetCategories = AssetCategoryLocalServiceUtil
                .getCategories(DLFileEntry.class.getName(), fileEntryId);

        long[] assetCategoryIds = StringUtil
                .split(ListUtil.toString(assetCategories, AssetCategory.CATEGORY_ID_ACCESSOR), 0L);

        document.addKeyword(Field.ASSET_CATEGORY_IDS, assetCategoryIds);

        String[] assetCategoryNames = StringUtil
                .split(ListUtil.toString(assetCategories, AssetCategory.NAME_ACCESSOR));

        document.addKeyword(Field.ASSET_CATEGORY_NAMES, assetCategoryNames);

        String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(DLFileEntry.class.getName(), fileEntryId);

        document.addKeyword(Field.ASSET_TAG_NAMES, assetTagNames);

        document.addKeyword(Field.COMPANY_ID, dlFileEntry.getCompanyId());

        if (indexContent) {
            try {
                document.addFile(Field.CONTENT, is, dlFileEntry.getTitle());
            } catch (IOException ioe) {
                throw new SearchException("Cannot extract text from file" + dlFileEntry);
            }
        }

        document.addText(Field.DESCRIPTION, dlFileEntry.getDescription());
        document.addKeyword(Field.ENTRY_CLASS_NAME, DLFileEntry.class.getName());
        document.addKeyword(Field.ENTRY_CLASS_PK, fileEntryId);
        document.addKeyword(Field.FOLDER_ID, dlFileEntry.getFolderId());
        document.addKeyword(Field.GROUP_ID, getParentGroupId(dlFileEntry.getGroupId()));
        document.addDate(Field.MODIFIED_DATE, dlFileEntry.getModifiedDate());
        document.addKeyword(Field.PORTLET_ID, PORTLET_ID);
        document.addText(Field.PROPERTIES, dlFileEntry.getLuceneProperties());
        document.addKeyword(Field.SCOPE_GROUP_ID, dlFileEntry.getGroupId());

        DLFileVersion dlFileVersion = dlFileEntry.getFileVersion();

        document.addKeyword(Field.STATUS, dlFileVersion.getStatus());
        document.addText(Field.TITLE, dlFileEntry.getTitle());

        long userId = dlFileEntry.getUserId();

        document.addKeyword(Field.USER_ID, userId);
        document.addKeyword(Field.USER_NAME, PortalUtil.getUserName(userId, dlFileEntry.getUserName()), true);

        document.addKeyword("dataRepositoryId", dlFileEntry.getDataRepositoryId());
        document.addKeyword("extension", dlFileEntry.getExtension());
        document.addKeyword("fileEntryTypeId", dlFileEntry.getFileEntryTypeId());
        document.addKeyword("path", dlFileEntry.getTitle());

        ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(dlFileEntry.getCompanyId(),
                DLFileEntry.class.getName(), dlFileVersion.getFileVersionId());

        ExpandoBridgeIndexerUtil.addAttributes(document, expandoBridge);

        addFileEntryTypeAttributes(document, dlFileVersion);

        if (_log.isDebugEnabled()) {
            _log.debug("Document " + dlFileEntry + " indexed successfully");
        }

        return document;
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException ioe) {
            }
        }
    }
}

From source file:com.liferay.users.admin.internal.search.UserIndexer.java

License:Open Source License

public UserIndexer() {
    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.UID,
            Field.USER_ID);//from   www.j a va 2  s  .  co m
    setPermissionAware(true);
    setStagingAware(false);
}

From source file:com.liferay.users.admin.internal.search.UserIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(User user) throws Exception {
    Document document = getBaseModelDocument(CLASS_NAME, user);

    long[] organizationIds = user.getOrganizationIds();

    document.addKeyword(Field.COMPANY_ID, user.getCompanyId());
    document.addKeyword(Field.GROUP_ID, getActiveGroupIds(user.getUserId()));
    document.addDate(Field.MODIFIED_DATE, user.getModifiedDate());
    document.addKeyword(Field.SCOPE_GROUP_ID, user.getGroupIds());
    document.addKeyword(Field.STATUS, user.getStatus());
    document.addKeyword(Field.USER_ID, user.getUserId());
    document.addKeyword(Field.USER_NAME, user.getFullName(), true);
    document.addKeyword("ancestorOrganizationIds", getAncestorOrganizationIds(user.getOrganizationIds()));
    document.addText("emailAddress", user.getEmailAddress());
    document.addText("firstName", user.getFirstName());
    document.addText("fullName", user.getFullName());
    document.addKeyword("groupIds", user.getGroupIds());
    document.addText("jobTitle", user.getJobTitle());
    document.addText("lastName", user.getLastName());
    document.addText("middleName", user.getMiddleName());
    document.addKeyword("organizationIds", organizationIds);
    document.addKeyword("organizationCount", String.valueOf(organizationIds.length));
    document.addKeyword("roleIds", user.getRoleIds());
    document.addText("screenName", user.getScreenName());
    document.addKeyword("teamIds", user.getTeamIds());
    document.addKeyword("userGroupIds", user.getUserGroupIds());

    populateAddresses(document, user.getAddresses(), 0, 0);

    return document;
}

From source file:com.liferay.wiki.search.WikiPageIndexer.java

License:Open Source License

public WikiPageIndexer() {
    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);/*w ww.ja  v  a 2s.  c om*/
    setFilterSearch(true);
    setPermissionAware(true);
}

From source file:jorgediazest.indexchecker.model.IndexCheckerModel.java

License:Open Source License

public BooleanQuery getIndexQuery(long groupId, SearchContext searchContext) {

    BooleanQuery contextQuery = BooleanQueryFactoryUtil.create(searchContext);
    contextQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, this.getClassName());

    if (groupId != 0) {
        contextQuery.addRequiredTerm(Field.SCOPE_GROUP_ID, groupId);
    }// w w w  . ja  v a2s  .  c  om

    return contextQuery;
}

From source file:jorgediazest.indexchecker.model.IndexCheckerModelQuery.java

License:Open Source License

public BooleanQuery getIndexQuery(List<Long> groupIds, SearchContext searchContext) throws ParseException {

    BooleanQuery query = BooleanQueryFactoryUtil.create(searchContext);
    query.addRequiredTerm(Field.ENTRY_CLASS_NAME, getModel().getClassName());

    if (getModel().hasAttribute("groupId") && (groupIds != null)) {
        BooleanQuery groupQuery = BooleanQueryFactoryUtil.create(searchContext);

        for (Long groupId : groupIds) {
            groupQuery.addTerm(Field.SCOPE_GROUP_ID, groupId);
        }//  w  ww .j  av  a 2s  .  c o m

        query.add(groupQuery, BooleanClauseOccur.MUST);
    }

    return query;
}

From source file:org.opencps.dossiermgt.search.DossierFileIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    // TODO Auto-generated method stub
    DossierFile dossierFile = (DossierFile) obj;

    Document document = getBaseModelDocument(PORTLET_ID, dossierFile);

    if (dossierFile.getDisplayName() != null && !Validator.isBlank(dossierFile.getDisplayName())) {
        Field field = new Field(DossierFileDisplayTerms.DISPLAY_NAME,
                dossierFile.getDisplayName().toLowerCase().split("\\s+"));
        field.setBoost(5);/*from   ww w . j  ava  2  s  . co m*/
        document.add(field);
    }

    if (dossierFile.getModifiedDate() != null) {
        document.addDate(Field.MODIFIED_DATE, dossierFile.getModifiedDate());
    }
    if (dossierFile.getFormData() != null && !Validator.isBlank(dossierFile.getFormData())) {
        document.addText(DossierFileDisplayTerms.FORM_DATA,
                dossierFile.getFormData().toLowerCase().split("\\s+"));
    }
    if (dossierFile.getDossierFileNo() != null && !Validator.isBlank(dossierFile.getDossierFileNo())) {
        document.addText(DossierFileDisplayTerms.DOSSIER_FILE_NO, dossierFile.getDossierFileNo());
    }
    document.addNumber(DossierFileDisplayTerms.DOSSIER_FILE_ID, dossierFile.getDossierFileId());
    document.addKeyword(Field.GROUP_ID, getSiteGroupId(dossierFile.getGroupId()));
    document.addKeyword(Field.SCOPE_GROUP_ID, dossierFile.getGroupId());

    return document;
}