Example usage for com.liferay.portal.kernel.search SearchContext getAttribute

List of usage examples for com.liferay.portal.kernel.search SearchContext getAttribute

Introduction

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

Prototype

public Serializable getAttribute(String name) 

Source Link

Usage

From source file:com.liferay.portlet.usersadmin.util.UserIndexer.java

License:Open Source License

@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, SearchContext searchContext) throws Exception {

    addSearchTerm(searchQuery, searchContext, "city", false);
    addSearchTerm(searchQuery, searchContext, "country", false);
    addSearchTerm(searchQuery, searchContext, "emailAddress", false);
    addSearchTerm(searchQuery, searchContext, "firstName", false);
    addSearchTerm(searchQuery, searchContext, "fullName", false);
    addSearchTerm(searchQuery, searchContext, "lastName", false);
    addSearchTerm(searchQuery, searchContext, "middleName", false);
    addSearchTerm(searchQuery, searchContext, "region", false);
    addSearchTerm(searchQuery, searchContext, "screenName", false);
    addSearchTerm(searchQuery, searchContext, "street", false);
    addSearchTerm(searchQuery, searchContext, "zip", false);

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params != null) {
        String expandoAttributes = (String) params.get("expandoAttributes");

        if (Validator.isNotNull(expandoAttributes)) {
            addSearchExpando(searchQuery, searchContext, expandoAttributes);
        }//from   w  w w  .ja  v a2  s .  c o m
    }
}

From source file:com.liferay.portlet.wiki.util.WikiIndexer.java

License:Open Source License

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

    int status = GetterUtil.getInteger(searchContext.getAttribute(Field.STATUS), WorkflowConstants.STATUS_ANY);

    if (status != WorkflowConstants.STATUS_ANY) {
        contextQuery.addRequiredTerm(Field.STATUS, status);
    }//from w  ww . j a v  a2s  . c  om

    long[] nodeIds = searchContext.getNodeIds();

    if ((nodeIds != null) && (nodeIds.length > 0)) {
        BooleanQuery nodeIdsQuery = BooleanQueryFactoryUtil.create(searchContext);

        for (long nodeId : nodeIds) {
            try {
                WikiNodeServiceUtil.getNode(nodeId);
            } catch (Exception e) {
                continue;
            }

            nodeIdsQuery.addTerm(Field.NODE_ID, nodeId);
        }

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

From source file:com.liferay.so.hook.indexer.UserIndexerPostProcessor.java

License:Open Source License

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

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params != null) {
        Object projectTitles = params.get("projectTitles");

        if (Validator.isNotNull(projectTitles)) {
            contextQuery.addRequiredTerm("projectTitles", String.valueOf(projectTitles), true);
        }/*from  w ww  .  ja  v  a2  s  . c o  m*/

        Object socialRelationType = params.get("socialRelationType");

        if (Validator.isNotNull(socialRelationType)) {
            Long[] socialRelationTypeValues = (Long[]) socialRelationType;

            contextQuery.addRequiredTerm("socialRelationships", socialRelationTypeValues[0]);
        }
    }
}

From source file:com.liferay.user.groups.admin.web.internal.search.UserGroupIndexer.java

License:Open Source License

@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
        SearchContext searchContext) throws Exception {

    addSearchTerm(searchQuery, searchContext, "description", false);
    addSearchTerm(searchQuery, searchContext, "name", false);

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params != null) {
        String expandoAttributes = (String) params.get("expandoAttributes");

        if (Validator.isNotNull(expandoAttributes)) {
            addSearchExpando(searchQuery, searchContext, expandoAttributes);
        }/*  w ww .j  av a2  s  .  co m*/
    }
}

From source file:com.liferay.users.admin.internal.search.UserIndexer.java

License:Open Source License

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

    int status = GetterUtil.getInteger(searchContext.getAttribute(Field.STATUS),
            WorkflowConstants.STATUS_APPROVED);

    if (status != WorkflowConstants.STATUS_ANY) {
        contextBooleanFilter.addRequiredTerm(Field.STATUS, status);
    }//from  w  ww . j  av  a  2 s. com

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params == null) {
        return;
    }

    for (Map.Entry<String, Object> entry : params.entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();

        if (value == null) {
            continue;
        }

        Class<?> clazz = value.getClass();

        if (clazz.isArray()) {
            Object[] values = (Object[]) value;

            if (values.length == 0) {
                continue;
            }
        }

        addContextQueryParams(contextBooleanFilter, searchContext, key, value);
    }
}

From source file:com.liferay.users.admin.internal.search.UserIndexer.java

License:Open Source License

@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
        SearchContext searchContext) throws Exception {

    addHighlightFieldNames(searchContext);

    addSearchTerm(searchQuery, searchContext, "city", false);
    addSearchTerm(searchQuery, searchContext, "country", false);
    addSearchTerm(searchQuery, searchContext, "emailAddress", false);
    addSearchTerm(searchQuery, searchContext, "firstName", false);
    addSearchTerm(searchQuery, searchContext, "fullName", false);
    addSearchTerm(searchQuery, searchContext, "lastName", false);
    addSearchTerm(searchQuery, searchContext, "middleName", false);
    addSearchTerm(searchQuery, searchContext, "region", false);
    addSearchTerm(searchQuery, searchContext, "screenName", false);
    addSearchTerm(searchQuery, searchContext, "street", false);
    addSearchTerm(searchQuery, searchContext, "zip", false);

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params != null) {
        String expandoAttributes = (String) params.get("expandoAttributes");

        if (Validator.isNotNull(expandoAttributes)) {
            addSearchExpando(searchQuery, searchContext, expandoAttributes);
        }/*from   w w w . j a  v a  2 s  .  com*/
    }
}

From source file:org.liferay.jukebox.util.ArtistIndexer.java

License:Open Source License

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

    addStatus(contextQuery, searchContext);

    int artistId = GetterUtil.getInteger(searchContext.getAttribute("artistId"));

    if (artistId != 0) {
        contextQuery.addRequiredTerm("artistId", artistId);
    }//from   www  . j a  v a  2 s . com
}