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

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

Introduction

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

Prototype

String ASSET_VOCABULARY_ID

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

Click Source Link

Usage

From source file:com.liferay.asset.categories.internal.search.AssetCategoryIndexer.java

License:Open Source License

@Override
public void postProcessContextBooleanFilter(BooleanFilter contextBooleanFilter, SearchContext searchContext)
        throws Exception {

    long[] parentCategoryIds = (long[]) searchContext.getAttribute(Field.ASSET_PARENT_CATEGORY_IDS);

    if (!ArrayUtil.isEmpty(parentCategoryIds)) {
        TermsFilter parentCategoryTermsFilter = new TermsFilter(Field.ASSET_PARENT_CATEGORY_ID);

        parentCategoryTermsFilter.addValues(ArrayUtil.toStringArray(parentCategoryIds));

        contextBooleanFilter.add(parentCategoryTermsFilter, BooleanClauseOccur.MUST);
    }//from www .  j  ava  2s  . c  o  m

    long[] vocabularyIds = (long[]) searchContext.getAttribute(Field.ASSET_VOCABULARY_IDS);

    if (!ArrayUtil.isEmpty(vocabularyIds)) {
        TermsFilter vocabularyTermsFilter = new TermsFilter(Field.ASSET_VOCABULARY_ID);

        vocabularyTermsFilter.addValues(ArrayUtil.toStringArray(vocabularyIds));

        contextBooleanFilter.add(vocabularyTermsFilter, BooleanClauseOccur.MUST);
    }
}

From source file:com.liferay.asset.categories.internal.search.AssetCategoryIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(AssetCategory assetCategory) throws Exception {

    if (_log.isDebugEnabled()) {
        _log.debug("Indexing asset category " + assetCategory);
    }// w  w w  .j  a  v  a2  s.c  o m

    Document document = getBaseModelDocument(CLASS_NAME, assetCategory);

    document.addKeyword(Field.ASSET_CATEGORY_ID, assetCategory.getCategoryId());

    List<AssetCategory> categories = new ArrayList<>(1);

    categories.add(assetCategory);

    addSearchAssetCategoryTitles(document, Field.ASSET_CATEGORY_TITLE, categories);

    document.addKeyword(Field.ASSET_PARENT_CATEGORY_ID, assetCategory.getParentCategoryId());
    document.addKeyword(Field.ASSET_VOCABULARY_ID, assetCategory.getVocabularyId());

    Locale siteDefaultLocale = _portal.getSiteDefaultLocale(assetCategory.getGroupId());

    addLocalizedField(document, Field.DESCRIPTION, siteDefaultLocale, assetCategory.getDescriptionMap());

    document.addText(Field.NAME, assetCategory.getName());
    addLocalizedField(document, Field.TITLE, siteDefaultLocale, assetCategory.getTitleMap());
    document.addKeyword("leftCategoryId", assetCategory.getLeftCategoryId());

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

    return document;
}

From source file:com.liferay.asset.categories.internal.search.AssetVocabularyIndexer.java

License:Open Source License

public AssetVocabularyIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_VOCABULARY_ID, Field.COMPANY_ID, Field.GROUP_ID, Field.UID);
    setFilterSearch(true);
    setPermissionAware(true);
}

From source file:com.liferay.asset.categories.internal.search.AssetVocabularyIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(AssetVocabulary assetVocabulary) throws Exception {

    if (_log.isDebugEnabled()) {
        _log.debug("Indexing asset vocabulary " + assetVocabulary);
    }/* w  w  w. j  a v  a 2s  .com*/

    Document document = getBaseModelDocument(CLASS_NAME, assetVocabulary);

    document.addKeyword(Field.ASSET_VOCABULARY_ID, assetVocabulary.getVocabularyId());

    Locale siteDefaultLocale = _portal.getSiteDefaultLocale(assetVocabulary.getGroupId());

    addLocalizedField(document, Field.DESCRIPTION, siteDefaultLocale, assetVocabulary.getDescriptionMap());

    document.addText(Field.NAME, assetVocabulary.getName());
    addLocalizedField(document, Field.TITLE, siteDefaultLocale, assetVocabulary.getTitleMap());

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

    return document;
}