Example usage for com.liferay.portal.kernel.search RelatedEntryIndexerRegistryUtil getRelatedEntryIndexers

List of usage examples for com.liferay.portal.kernel.search RelatedEntryIndexerRegistryUtil getRelatedEntryIndexers

Introduction

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

Prototype

public static List<RelatedEntryIndexer> getRelatedEntryIndexers(String className) 

Source Link

Usage

From source file:com.liferay.message.boards.internal.search.MBMessageIndexer.java

License:Open Source License

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

    document.addKeyword(Field.CATEGORY_ID, mbMessage.getCategoryId());
    document.addText(Field.CONTENT, processContent(mbMessage));
    document.addKeyword(Field.ROOT_ENTRY_CLASS_PK, mbMessage.getRootMessageId());
    document.addText(Field.TITLE, mbMessage.getSubject());

    if (mbMessage.isAnonymous()) {
        document.remove(Field.USER_NAME);
    }//from  w w w.  ja  v a 2 s .c  o m

    MBDiscussion discussion = mbDiscussionLocalService.fetchThreadDiscussion(mbMessage.getThreadId());

    if (discussion == null) {
        document.addKeyword("discussion", false);
    } else {
        document.addKeyword("discussion", true);
    }

    document.addKeyword("threadId", mbMessage.getThreadId());

    if (mbMessage.isDiscussion()) {
        List<RelatedEntryIndexer> relatedEntryIndexers = RelatedEntryIndexerRegistryUtil
                .getRelatedEntryIndexers(mbMessage.getClassName());

        if (relatedEntryIndexers != null) {
            for (RelatedEntryIndexer relatedEntryIndexer : relatedEntryIndexers) {

                Comment comment = commentManager.fetchComment(mbMessage.getMessageId());

                if (comment != null) {
                    relatedEntryIndexer.addRelatedEntryFields(document, comment);

                    document.addKeyword(Field.RELATED_ENTRY, true);
                }
            }
        }
    }

    return document;
}