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

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

Introduction

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

Prototype

String FOLDER_ID

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

Click Source Link

Usage

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

License:Open Source License

@Override
protected Document doGetDocument(BookmarksEntry bookmarksEntry) throws Exception {

    Document document = getBaseModelDocument(CLASS_NAME, bookmarksEntry);

    document.addText(Field.DESCRIPTION, bookmarksEntry.getDescription());
    document.addKeyword(Field.FOLDER_ID, bookmarksEntry.getFolderId());
    document.addText(Field.TITLE, bookmarksEntry.getName());
    document.addKeyword(Field.TREE_PATH, StringUtil.split(bookmarksEntry.getTreePath(), CharPool.SLASH));
    document.addText(Field.URL, bookmarksEntry.getUrl());

    return document;
}

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

License:Open Source License

@Override
protected Document doGetDocument(BookmarksFolder bookmarksFolder) throws Exception {

    if (_log.isDebugEnabled()) {
        _log.debug("Indexing folder " + bookmarksFolder);
    }/*w  w  w .  ja va  2  s . c om*/

    Document document = getBaseModelDocument(CLASS_NAME, bookmarksFolder);

    document.addText(Field.DESCRIPTION, bookmarksFolder.getDescription());
    document.addKeyword(Field.FOLDER_ID, bookmarksFolder.getParentFolderId());
    document.addText(Field.TITLE, bookmarksFolder.getName());
    document.addKeyword(Field.TREE_PATH, StringUtil.split(bookmarksFolder.getTreePath(), CharPool.SLASH));

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

    return document;
}

From source file:com.liferay.document.library.repository.cmis.search.BaseCmisSearchQueryBuilder.java

License:Open Source License

protected CMISCriterion buildFieldExpression(String field, String value,
        CMISSimpleExpressionOperator cmisSimpleExpressionOperator, QueryConfig queryConfig)
        throws SearchException {

    CMISCriterion cmisCriterion = null;//  www .ja v  a 2s. c o m

    boolean wildcard = false;

    if (CMISSimpleExpressionOperator.LIKE == cmisSimpleExpressionOperator) {
        wildcard = true;
    }

    if (field.equals(Field.FOLDER_ID)) {
        long folderId = GetterUtil.getLong(value);

        try {
            RepositoryEntry repositoryEntry = _repositoryEntryLocalService.fetchRepositoryEntry(folderId);

            if (repositoryEntry != null) {
                String objectId = repositoryEntry.getMappedId();

                objectId = CMISParameterValueUtil.formatParameterValue(field, objectId, wildcard, queryConfig);

                if (queryConfig.isSearchSubfolders()) {
                    cmisCriterion = new CMISInTreeExpression(objectId);
                } else {
                    cmisCriterion = new CMISInFolderExpression(objectId);
                }
            }
        } catch (SystemException se) {
            throw new SearchException("Unable to determine folder {folderId=" + folderId + "}", se);
        }
    } else if (field.equals(Field.USER_ID)) {
        try {
            long userId = GetterUtil.getLong(value);

            User user = _userLocalService.getUserById(userId);

            String screenName = CMISParameterValueUtil.formatParameterValue(field, user.getScreenName(),
                    wildcard, queryConfig);

            cmisCriterion = new CMISSimpleExpression(getCmisField(field), screenName,
                    cmisSimpleExpressionOperator);
        } catch (Exception e) {
            if (e instanceof SearchException) {
                throw (SearchException) e;
            }

            throw new SearchException("Unable to determine user {" + field + "=" + value + "}", e);
        }
    } else {
        value = CMISParameterValueUtil.formatParameterValue(field, value, wildcard, queryConfig);

        cmisCriterion = new CMISSimpleExpression(getCmisField(field), value, cmisSimpleExpressionOperator);
    }

    return cmisCriterion;
}

From source file:com.liferay.document.library.repository.external.ExtRepositoryQueryMapperImpl.java

License:Open Source License

@Override
public String formatParameterValue(String fieldName, String fieldValue) throws SearchException {

    if (fieldName.equals(Field.CREATE_DATE) || fieldName.equals(Field.MODIFIED_DATE)) {

        throw new SearchException(
                "Use the method formatDateParameterValue to format the date " + "field " + fieldName);
    } else if (fieldName.equals(Field.FOLDER_ID)) {
        try {//from   w  w w.j  a  va 2s .c  o m
            long folderId = GetterUtil.getLong(fieldValue);

            return _extRepositoryAdapter.getExtRepositoryObjectKey(folderId);
        } catch (PortalException pe) {
            throw new SearchException("Unable to get folder folder " + fieldValue, pe);
        } catch (SystemException se) {
            throw new SearchException("Unable to get folder folder " + fieldValue, se);
        }
    } else if (fieldName.equals(Field.USER_ID)) {
        try {
            long userId = GetterUtil.getLong(fieldValue);

            User user = UserLocalServiceUtil.getUserById(userId);

            return user.getScreenName();
        } catch (Exception e) {
            throw new SearchException("Unable to get user user " + fieldValue, e);
        }
    } else {
        return fieldValue;
    }
}

From source file:com.liferay.document.library.repository.search.internal.RepositorySearchQueryBuilderImpl.java

License:Open Source License

protected void addContext(BooleanQuery contextQuery, SearchContext searchContext) throws Exception {

    long[] folderIds = searchContext.getFolderIds();

    if (ArrayUtil.isEmpty(folderIds)) {
        return;//from  w ww.j av  a  2s . c o m
    }

    if (folderIds[0] == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        return;
    }

    BooleanQuery folderIdsQuery = new BooleanQueryImpl();

    for (long folderId : folderIds) {
        try {
            _dlAppService.getFolder(folderId);
        } catch (Exception e) {
            continue;
        }

        folderIdsQuery.add(new TermQueryImpl(Field.FOLDER_ID, String.valueOf(folderId)),
                BooleanClauseOccur.SHOULD);
    }

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

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

License:Open Source License

@Override
protected Document doGetDocument(JournalArticle journalArticle) throws Exception {

    Document document = getBaseModelDocument(CLASS_NAME, journalArticle);

    long classPK = journalArticle.getId();

    if (!isIndexAllArticleVersions()) {
        classPK = journalArticle.getResourcePrimKey();
    }/*w w  w. j av  a2 s  . c  om*/

    document.addUID(CLASS_NAME, classPK);

    String articleDefaultLanguageId = LocalizationUtil.getDefaultLanguageId(journalArticle.getDocument());

    String[] languageIds = LocalizationUtil.getAvailableLanguageIds(journalArticle.getDocument());

    for (String languageId : languageIds) {
        String content = extractDDMContent(journalArticle, languageId);

        String description = journalArticle.getDescription(languageId);

        String title = journalArticle.getTitle(languageId);

        if (languageId.equals(articleDefaultLanguageId)) {
            document.addText(Field.CONTENT, content);
            document.addText(Field.DESCRIPTION, description);
            document.addText("defaultLanguageId", languageId);
        }

        document.addText(LocalizationUtil.getLocalizedName(Field.CONTENT, languageId), content);
        document.addText(LocalizationUtil.getLocalizedName(Field.DESCRIPTION, languageId), description);
        document.addText(LocalizationUtil.getLocalizedName(Field.TITLE, languageId), title);
    }

    document.addKeyword(Field.FOLDER_ID, journalArticle.getFolderId());

    String articleId = journalArticle.getArticleId();

    if (journalArticle.isInTrash()) {
        articleId = TrashUtil.getOriginalTitle(articleId);
    }

    document.addKeywordSortable(Field.ARTICLE_ID, articleId);

    document.addKeyword(Field.LAYOUT_UUID, journalArticle.getLayoutUuid());
    document.addKeyword(Field.TREE_PATH, StringUtil.split(journalArticle.getTreePath(), CharPool.SLASH));
    document.addKeyword(Field.VERSION, journalArticle.getVersion());

    document.addKeyword("ddmStructureKey", journalArticle.getDDMStructureKey());
    document.addKeyword("ddmTemplateKey", journalArticle.getDDMTemplateKey());
    document.addDate("displayDate", journalArticle.getDisplayDate());
    document.addKeyword("head", JournalUtil.isHead(journalArticle));

    boolean headListable = JournalUtil.isHeadListable(journalArticle);

    document.addKeyword("headListable", headListable);

    // Scheduled listable articles should be visible in asset browser

    if (journalArticle.isScheduled() && headListable) {
        boolean visible = GetterUtil.getBoolean(document.get("visible"));

        if (!visible) {
            document.addKeyword("visible", true);
        }
    }

    addDDMStructureAttributes(document, journalArticle);

    return document;
}

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

License:Open Source License

@Override
protected Document doGetDocument(JournalFolder journalFolder) throws Exception {

    if (_log.isDebugEnabled()) {
        _log.debug("Indexing journalFolder " + journalFolder);
    }/*from   www .j  a  va  2 s.c o m*/

    Document document = getBaseModelDocument(CLASS_NAME, journalFolder);

    document.addText(Field.DESCRIPTION, journalFolder.getDescription());
    document.addKeyword(Field.FOLDER_ID, journalFolder.getParentFolderId());

    String title = journalFolder.getName();

    if (journalFolder.isInTrash()) {
        title = TrashUtil.getOriginalTitle(title);
    }

    document.addText(Field.TITLE, title);

    document.addKeyword(Field.TREE_PATH, StringUtil.split(journalFolder.getTreePath(), CharPool.SLASH));

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

    return document;
}

From source file:com.liferay.mail.util.FolderIndexer.java

License:Open Source License

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

    ExpandoBridge expandoBridge = folder.getExpandoBridge();

    document.addKeyword(Field.FOLDER_ID, folder.getFolderId());
    document.addText(Field.NAME, folder.getDisplayName());

    document.addKeyword("accountId", folder.getAccountId());

    ExpandoBridgeIndexerUtil.addAttributes(document, expandoBridge);

    return document;
}

From source file:com.liferay.mail.util.MessageIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    Message message = (Message) obj;// www. j av  a2  s.  c  o m

    Document document = getBaseModelDocument(PORTLET_ID, message);

    ExpandoBridge expandoBridge = message.getExpandoBridge();

    document.addText(Field.CONTENT, HtmlUtil.extractText(message.getBody()));
    document.addKeyword(Field.FOLDER_ID, message.getFolderId());
    document.addText(Field.TITLE, message.getSubject());

    document.addKeyword("accountId", message.getAccountId());
    document.addKeyword("remoteMessageId", message.getRemoteMessageId());

    ExpandoBridgeIndexerUtil.addAttributes(document, expandoBridge);

    return document;
}

From source file:com.liferay.portlet.bookmarks.util.BookmarksIndexer.java

License:Open Source License

@Override
public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext) throws Exception {

    long[] folderIds = searchContext.getFolderIds();

    if ((folderIds != null) && (folderIds.length > 0)) {
        if (folderIds[0] == BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

            return;
        }//from w w w .  ja va2 s.  c  o  m

        BooleanQuery folderIdsQuery = BooleanQueryFactoryUtil.create(searchContext);

        for (long folderId : folderIds) {
            try {
                BookmarksFolderServiceUtil.getFolder(folderId);
            } catch (Exception e) {
                continue;
            }

            folderIdsQuery.addTerm(Field.FOLDER_ID, folderId);
        }

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