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

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

Introduction

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

Prototype

String ENTRY_CLASS_NAME

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

Click Source Link

Usage

From source file:com.liferay.configuration.admin.web.internal.search.ConfigurationModelIndexer.java

License:Open Source License

@Override
public BooleanQuery getFullQuery(SearchContext searchContext) throws SearchException {

    try {// w  ww  .  j  a v a  2 s.  c  o  m
        BooleanFilter fullQueryBooleanFilter = new BooleanFilter();

        fullQueryBooleanFilter.addRequiredTerm(Field.ENTRY_CLASS_NAME, getClassName());

        BooleanQuery fullQuery = createFullQuery(fullQueryBooleanFilter, searchContext);

        fullQuery.setQueryConfig(searchContext.getQueryConfig());

        return fullQuery;
    } catch (SearchException se) {
        throw se;
    } catch (Exception e) {
        throw new SearchException(e);
    }
}

From source file:com.liferay.configuration.admin.web.internal.search.ConfigurationModelIndexer.java

License:Open Source License

@Activate
protected void activate(BundleContext bundleContext) {
    setCommitImmediately(false);/* ww w. j  a va  2 s  .  c o  m*/
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.DESCRIPTION, Field.ENTRY_CLASS_NAME, Field.TITLE,
            Field.UID, FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_DESCRIPTION,
            FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_NAME, FieldNames.CONFIGURATION_MODEL_FACTORY_PID,
            FieldNames.CONFIGURATION_MODEL_ID);
    setFilterSearch(false);
    setPermissionAware(false);
    setSelectAllLocales(false);
    setStagingAware(false);
}

From source file:com.liferay.configuration.admin.web.internal.search.ConfigurationModelIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(ConfigurationModel configurationModel) throws Exception {

    Document document = newDocument();

    document.addUID(ConfigurationAdminPortletKeys.SYSTEM_SETTINGS, configurationModel.getID());
    document.addKeyword(FieldNames.CONFIGURATION_MODEL_FACTORY_PID, configurationModel.getFactoryPid());
    document.addKeyword(FieldNames.CONFIGURATION_MODEL_ID, configurationModel.getID());
    document.addKeyword(Field.COMPANY_ID, CompanyConstants.SYSTEM);

    ResourceBundleLoader resourceBundleLoader = _resourceBundleLoaderProvider
            .getResourceBundleLoader(configurationModel.getBundleSymbolicName());

    document.addLocalizedText(Field.DESCRIPTION,
            _translate(resourceBundleLoader, GetterUtil.getString(configurationModel.getDescription())));

    document.addKeyword(Field.ENTRY_CLASS_NAME, getClassName());

    AttributeDefinition[] requiredAttributeDefinitions = configurationModel
            .getAttributeDefinitions(ObjectClassDefinition.ALL);

    List<String> attributeNames = new ArrayList<>(requiredAttributeDefinitions.length);

    List<String> attributeDescriptions = new ArrayList<>(requiredAttributeDefinitions.length);

    for (AttributeDefinition attributeDefinition : requiredAttributeDefinitions) {

        attributeNames.add(attributeDefinition.getName());
        attributeDescriptions.add(attributeDefinition.getDescription());
    }//from w  w  w .  j a va 2s .  c  om

    document.addKeyword(FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_NAME,
            attributeNames.toArray(new String[attributeNames.size()]));
    document.addText(FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_DESCRIPTION,
            attributeDescriptions.toArray(new String[attributeDescriptions.size()]));

    document.addLocalizedText(Field.TITLE,
            _translate(resourceBundleLoader, GetterUtil.getString(configurationModel.getName())));

    return document;
}

From source file:com.liferay.docs.guestbook.search.GuestbookEntrySearchRegistrar.java

License:Open Source License

@Activate
protected void activate(BundleContext bundleContext) {

    _serviceRegistration = modelSearchRegistrarHelper.register(GuestbookEntry.class, bundleContext,
            modelSearchDefinition -> {
                modelSearchDefinition.setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME,
                        Field.ENTRY_CLASS_PK, Field.UID, Field.SCOPE_GROUP_ID, Field.GROUP_ID);

                modelSearchDefinition.setDefaultSelectedLocalizedFieldNames(Field.TITLE, Field.CONTENT);

                modelSearchDefinition.setModelIndexWriteContributor(modelIndexWriterContributor);
                modelSearchDefinition.setModelSummaryContributor(modelSummaryContributor);
                modelSearchDefinition.setSelectAllLocales(true);

            });//from   w w w .j  a v  a 2s. c  om
}

From source file:com.liferay.docs.guestbook.search.GuestbookSearchRegistrar.java

License:Open Source License

@Activate
protected void activate(BundleContext bundleContext) {

    _serviceRegistration = modelSearchRegistrarHelper.register(Guestbook.class, bundleContext,
            modelSearchDefinition -> {
                modelSearchDefinition.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);

                modelSearchDefinition.setModelIndexWriteContributor(modelIndexWriterContributor);
                modelSearchDefinition.setModelSummaryContributor(modelSummaryContributor);
            });/*from  ww w. j ava2s .  com*/
}

From source file:com.liferay.document.library.internal.trash.DLFileEntryTrashHandler.java

License:Open Source License

@Override
public Filter getExcludeFilter(SearchContext searchContext) {
    BooleanFilter excludeBooleanFilter = new BooleanFilter();

    excludeBooleanFilter.addRequiredTerm(Field.ENTRY_CLASS_NAME, DLFileEntryConstants.getClassName());
    excludeBooleanFilter.addRequiredTerm(Field.HIDDEN, true);

    return excludeBooleanFilter;
}

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

License:Open Source License

@Override
public Hits search(SearchContext searchContext, Query query) throws SearchException {

    long startTime = System.currentTimeMillis();

    List<ExtRepositorySearchResult<?>> extRepositorySearchResults = null;

    try {// www.ja  v a  2s . c  o m
        extRepositorySearchResults = _extRepository.search(searchContext, query,
                new ExtRepositoryQueryMapperImpl(this));
    } catch (PortalException | SystemException e) {
        throw new SearchException("Unable to perform search", e);
    }

    QueryConfig queryConfig = searchContext.getQueryConfig();

    List<Document> documents = new ArrayList<>();
    List<String> snippets = new ArrayList<>();
    List<Float> scores = new ArrayList<>();

    int total = 0;

    for (ExtRepositorySearchResult<?> extRepositorySearchResult : extRepositorySearchResults) {

        try {
            ExtRepositoryObjectAdapter<?> extRepositoryEntryAdapter = _toExtRepositoryObjectAdapter(
                    ExtRepositoryObjectAdapterType.OBJECT, extRepositorySearchResult.getObject());

            Document document = new DocumentImpl();

            document.addKeyword(Field.ENTRY_CLASS_NAME, extRepositoryEntryAdapter.getModelClassName());
            document.addKeyword(Field.ENTRY_CLASS_PK, extRepositoryEntryAdapter.getPrimaryKey());
            document.addKeyword(Field.TITLE, extRepositoryEntryAdapter.getName());

            documents.add(document);

            if (queryConfig.isScoreEnabled()) {
                scores.add(extRepositorySearchResult.getScore());
            } else {
                scores.add(1.0F);
            }

            snippets.add(extRepositorySearchResult.getSnippet());

            total++;
        } catch (PortalException | SystemException e) {
            if (_log.isWarnEnabled()) {
                _log.warn("Invalid entry returned from search", e);
            }
        }
    }

    float searchTime = (float) (System.currentTimeMillis() - startTime) / Time.SECOND;

    Hits hits = new HitsImpl();

    hits.setDocs(documents.toArray(new Document[documents.size()]));
    hits.setLength(total);
    hits.setQueryTerms(new String[0]);
    hits.setScores(ArrayUtil.toFloatArray(scores));
    hits.setSearchTime(searchTime);
    hits.setSnippets(snippets.toArray(new String[snippets.size()]));
    hits.setStart(startTime);

    return hits;
}

From source file:com.liferay.dynamic.data.lists.internal.search.DDLRecordIndexer.java

License:Open Source License

public DDLRecordIndexer() {
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID);
    setDefaultSelectedLocalizedFieldNames(Field.DESCRIPTION, Field.TITLE);
    setPermissionAware(true);//w  ww  .j  a  v a  2s.c o m
}

From source file:com.liferay.dynamic.data.lists.internal.search.DDLRecordIndexer.java

License:Open Source License

@Override
public BooleanFilter getFacetBooleanFilter(String className, SearchContext searchContext) throws Exception {

    BooleanFilter facetBooleanFilter = new BooleanFilter();

    facetBooleanFilter.addTerm(Field.ENTRY_CLASS_NAME, DDLRecord.class.getName());

    if (searchContext.getUserId() > 0) {
        facetBooleanFilter = searchPermissionChecker.getPermissionBooleanFilter(searchContext.getCompanyId(),
                searchContext.getGroupIds(), searchContext.getUserId(), DDLRecordSet.class.getName(),
                facetBooleanFilter, searchContext);
    }//from w  ww.j  av  a 2 s  .  c o  m

    return facetBooleanFilter;
}

From source file:com.liferay.dynamic.data.lists.internal.search.DDLRecordSetIndexer.java

License:Open Source License

public DDLRecordSetIndexer() {
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID);
    setPermissionAware(true);
}