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

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

Introduction

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

Prototype

String LAYOUT_UUID

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

Click Source Link

Usage

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

License:Open Source License

private AssetSearcher _getAssetSearcher(SearchContext searchContext, AssetEntryQuery assetEntryQuery, int start,
        int end) throws Exception {

    Indexer<?> searcher = AssetSearcher.getInstance();

    AssetSearcher assetSearcher = (AssetSearcher) searcher;

    assetSearcher.setAssetEntryQuery(assetEntryQuery);

    Layout layout = assetEntryQuery.getLayout();

    if (layout != null) {
        searchContext.setAttribute(Field.LAYOUT_UUID, layout.getUuid());
    }/*  w  ww  . j  a v a2  s. c  o  m*/

    String ddmStructureFieldName = (String) assetEntryQuery.getAttribute("ddmStructureFieldName");
    Serializable ddmStructureFieldValue = assetEntryQuery.getAttribute("ddmStructureFieldValue");

    if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) {

        searchContext.setAttribute("ddmStructureFieldName", ddmStructureFieldName);
        searchContext.setAttribute("ddmStructureFieldValue", ddmStructureFieldValue);
    }

    String paginationType = GetterUtil.getString(assetEntryQuery.getPaginationType(), "more");

    if (!paginationType.equals("none") && !paginationType.equals("simple")) {

        searchContext.setAttribute("paginationType", paginationType);
    }

    searchContext.setClassTypeIds(assetEntryQuery.getClassTypeIds());
    searchContext.setEnd(end);
    searchContext.setGroupIds(assetEntryQuery.getGroupIds());

    if (Validator.isNull(assetEntryQuery.getKeywords())) {
        QueryConfig queryConfig = searchContext.getQueryConfig();

        queryConfig.setScoreEnabled(false);
    } else {
        searchContext.setLike(true);
    }

    searchContext.setSorts(_getSorts(assetEntryQuery, searchContext.getLocale()));
    searchContext.setStart(start);

    return assetSearcher;
}

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();
    }/*from   w  ww.  jav 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.portlet.journal.util.JournalArticleIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    JournalArticle article = (JournalArticle) obj;

    Document document = getBaseModelDocument(PORTLET_ID, article);

    long classPK = article.getId();

    if (!PropsValues.JOURNAL_ARTICLE_INDEX_ALL_VERSIONS) {
        classPK = article.getResourcePrimKey();
    }//w  w  w . j a va  2  s.  co  m

    document.addUID(PORTLET_ID, classPK);

    String articleDefaultLanguageId = LocalizationUtil.getDefaultLanguageId(article.getContent());

    Locale defaultLocale = LocaleUtil.getSiteDefault();

    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    String[] languageIds = getLanguageIds(defaultLanguageId, article.getContent());

    for (String languageId : languageIds) {
        String content = extractContent(article, languageId);

        String description = article.getDescription(languageId);

        String title = article.getTitle(languageId);

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

        document.addText(Field.CONTENT.concat(StringPool.UNDERLINE).concat(languageId), content);
        document.addText(Field.DESCRIPTION.concat(StringPool.UNDERLINE).concat(languageId), description);
        document.addText(Field.TITLE.concat(StringPool.UNDERLINE).concat(languageId), title);
    }

    document.addKeyword(Field.FOLDER_ID, article.getFolderId());
    document.addKeyword(Field.LAYOUT_UUID, article.getLayoutUuid());
    document.addKeyword(Field.TREE_PATH, StringUtil.split(article.getTreePath(), CharPool.SLASH));
    document.addKeyword(Field.TYPE, article.getType());
    document.addKeyword(Field.VERSION, article.getVersion());

    String articleId = article.getArticleId();

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

    document.addKeyword("articleId", articleId);
    document.addKeyword("ddmStructureKey", article.getStructureId());
    document.addKeyword("ddmTemplateKey", article.getTemplateId());
    document.addDate("displayDate", article.getDisplayDate());

    addDDMStructureAttributes(document, article);

    addStatusHeads(document, article);

    return document;
}