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

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

Introduction

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

Prototype

String TYPE

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

Click Source Link

Usage

From source file:com.liferay.exportimport.search.ExportImportConfigurationIndexer.java

License:Open Source License

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

    addStatus(contextBooleanFilter, searchContext);

    contextBooleanFilter.addRequiredTerm(Field.COMPANY_ID, searchContext.getCompanyId());
    contextBooleanFilter.addRequiredTerm(Field.GROUP_ID,
            GetterUtil.getLong(searchContext.getAttribute(Field.GROUP_ID)));

    Serializable type = searchContext.getAttribute(Field.TYPE);

    if (type != null) {
        contextBooleanFilter.addRequiredTerm(Field.TYPE, GetterUtil.getInteger(type));
    }//ww w.j  a va2 s .c o m
}

From source file:com.liferay.exportimport.search.ExportImportConfigurationIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(ExportImportConfiguration exportImportConfiguration) throws Exception {

    Document document = getBaseModelDocument(CLASS_NAME, exportImportConfiguration);

    document.addText(Field.DESCRIPTION, exportImportConfiguration.getDescription());
    document.addText(Field.NAME, exportImportConfiguration.getName());
    document.addKeyword(Field.TYPE, exportImportConfiguration.getType());
    document.addNumber("exportImportConfigurationId",
            exportImportConfiguration.getExportImportConfigurationId());

    Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap();

    populateDates(document, settingsMap);
    populateLayoutIds(document, settingsMap);
    populateLocale(document, settingsMap);
    populateParameterMap(document, settingsMap);
    populateSiteInformation(document, settingsMap);
    populateTimeZone(document, settingsMap);

    document.addKeyword(_PREFIX_SETTING + Field.USER_ID, MapUtil.getLong(settingsMap, "userId"));

    return document;
}

From source file:com.liferay.portlet.calendar.util.CalIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    CalEvent event = (CalEvent) obj;//from   ww  w.  j av  a2s. c o  m

    Document document = getBaseModelDocument(PORTLET_ID, event);

    document.addText(Field.DESCRIPTION, HtmlUtil.extractText(event.getDescription()));
    document.addText(Field.TITLE, event.getTitle());
    document.addKeyword(Field.TYPE, event.getType());

    return document;
}

From source file:com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

public Hits search(long companyId, long groupId, long classNameId, String articleId, String title,
        String description, String content, String type, String status, String structureId, String templateId,
        LinkedHashMap<String, Object> params, boolean andSearch, int start, int end, Sort sort)
        throws SystemException {

    try {//from w  w  w . j a  va 2 s.  c o  m
        Map<String, Serializable> attributes = new HashMap<String, Serializable>();

        attributes.put(Field.CLASS_NAME_ID, classNameId);
        attributes.put(Field.CONTENT, content);
        attributes.put(Field.DESCRIPTION, description);
        attributes.put(Field.STATUS, status);
        attributes.put(Field.TITLE, title);
        attributes.put(Field.TYPE, type);
        attributes.put("articleId", articleId);
        attributes.put("params", params);
        attributes.put("structureId", structureId);
        attributes.put("templateId", templateId);

        SearchContext searchContext = new SearchContext();

        searchContext.setAndSearch(andSearch);
        searchContext.setAttributes(attributes);
        searchContext.setCompanyId(companyId);
        searchContext.setGroupIds(new long[] { groupId });
        searchContext.setEnd(end);

        String keywords = (String) params.remove("keywords");

        if (Validator.isNotNull(keywords)) {
            searchContext.setKeywords(keywords);
        }

        searchContext.setSorts(new Sort[] { sort });

        QueryConfig queryConfig = new QueryConfig();

        queryConfig.setHighlightEnabled(false);
        queryConfig.setScoreEnabled(false);

        searchContext.setQueryConfig(queryConfig);

        searchContext.setStart(start);

        Indexer indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class);

        return indexer.search(searchContext);
    } catch (Exception e) {
        throw new SystemException(e);
    }
}

From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java

License:Open Source License

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

    Long classNameId = (Long) searchContext.getAttribute(Field.CLASS_NAME_ID);

    if ((classNameId != null) && (classNameId.longValue() != 0)) {
        contextQuery.addRequiredTerm("classNameId", classNameId.toString());
    }//from   w w  w . ja  va2s .  c  om

    addStatus(contextQuery, searchContext);

    addSearchClassTypeIds(contextQuery, searchContext);

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

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

        String[] ddmStructureFieldNameParts = StringUtil.split(ddmStructureFieldName, StringPool.SLASH);

        DDMStructure structure = DDMStructureLocalServiceUtil
                .getStructure(GetterUtil.getLong(ddmStructureFieldNameParts[1]));

        String fieldName = StringUtil.replaceLast(ddmStructureFieldNameParts[2],
                StringPool.UNDERLINE.concat(LocaleUtil.toLanguageId(searchContext.getLocale())),
                StringPool.BLANK);

        try {
            ddmStructureFieldValue = DDMUtil.getIndexedFieldValue(ddmStructureFieldValue,
                    structure.getFieldType(fieldName));
        } catch (StructureFieldException sfe) {
        }

        contextQuery.addRequiredTerm(ddmStructureFieldName,
                StringPool.QUOTE + ddmStructureFieldValue + StringPool.QUOTE);
    }

    String articleType = (String) searchContext.getAttribute("articleType");

    if (Validator.isNotNull(articleType)) {
        contextQuery.addRequiredTerm(Field.TYPE, articleType);
    }

    String ddmStructureKey = (String) searchContext.getAttribute("ddmStructureKey");

    if (Validator.isNotNull(ddmStructureKey)) {
        contextQuery.addRequiredTerm("ddmStructureKey", ddmStructureKey);
    }

    String ddmTemplateKey = (String) searchContext.getAttribute("ddmTemplateKey");

    if (Validator.isNotNull(ddmTemplateKey)) {
        contextQuery.addRequiredTerm("ddmTemplateKey", ddmTemplateKey);
    }
}

From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java

License:Open Source License

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

    addSearchTerm(searchQuery, searchContext, Field.CLASS_PK, false);
    addSearchLocalizedTerm(searchQuery, searchContext, Field.CONTENT, false);
    addSearchLocalizedTerm(searchQuery, searchContext, Field.DESCRIPTION, false);
    addSearchTerm(searchQuery, searchContext, Field.ENTRY_CLASS_PK, false);
    addSearchLocalizedTerm(searchQuery, searchContext, Field.TITLE, false);
    addSearchTerm(searchQuery, searchContext, Field.TYPE, false);
    //        addSearchTerm(searchQuery, searchContext, Field.USER_NAME, false);

    addSearchTerm(searchQuery, searchContext, "articleId", 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  w  w.ja v a2s.  c om
    }
}

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 v  a2 s .c  om

    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;
}

From source file:com.liferay.portlet.journal.util.JournalIndexer.java

License:Open Source License

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

    Long classNameId = (Long) searchContext.getAttribute(Field.CLASS_NAME_ID);

    if (classNameId != null) {
        contextQuery.addRequiredTerm("classNameId", classNameId.toString());
    }/* www. j a v a2  s. co m*/

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

    if (status != WorkflowConstants.STATUS_ANY) {
        contextQuery.addRequiredTerm(Field.STATUS, status);
    }

    String articleType = (String) searchContext.getAttribute("articleType");

    if (Validator.isNotNull(articleType)) {
        contextQuery.addRequiredTerm(Field.TYPE, articleType);
    }

    String structureId = (String) searchContext.getAttribute("structureId");

    if (Validator.isNotNull(structureId)) {
        contextQuery.addRequiredTerm("structureId", structureId);
    }

    String templateId = (String) searchContext.getAttribute("templateId");

    if (Validator.isNotNull(templateId)) {
        contextQuery.addRequiredTerm("templateId", templateId);
    }
}

From source file:com.liferay.portlet.journal.util.JournalIndexer.java

License:Open Source License

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

    addSearchTerm(searchQuery, searchContext, Field.CLASS_PK, false);
    addLocalizedSearchTerm(searchQuery, searchContext, Field.CONTENT, false);
    addLocalizedSearchTerm(searchQuery, searchContext, Field.DESCRIPTION, false);
    addSearchTerm(searchQuery, searchContext, Field.ENTRY_CLASS_PK, false);
    addLocalizedSearchTerm(searchQuery, searchContext, Field.TITLE, false);
    addSearchTerm(searchQuery, searchContext, Field.TYPE, false);
    addSearchTerm(searchQuery, searchContext, Field.USER_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  w  w  .ja  va 2 s. c  o  m
    }
}

From source file:com.liferay.portlet.journal.util.JournalIndexer.java

License:Open Source License

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

    Document document = getBaseModelDocument(PORTLET_ID, article);

    document.addUID(PORTLET_ID, article.getGroupId(), article.getArticleId());

    Locale defaultLocale = LocaleUtil.getDefault();

    String defaultLangaugeId = LocaleUtil.toLanguageId(defaultLocale);

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

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

        if (languageId.equals(defaultLangaugeId)) {
            document.addText(Field.CONTENT, content);
        }/*from   w w w.j a v  a2s .  c  om*/

        document.addText(Field.CONTENT.concat(StringPool.UNDERLINE).concat(languageId), content);
    }

    document.addLocalizedText(Field.DESCRIPTION, article.getDescriptionMap());
    document.addLocalizedText(Field.TITLE, article.getTitleMap());
    document.addKeyword(Field.TYPE, article.getType());
    document.addKeyword(Field.VERSION, article.getVersion());

    document.addKeyword("articleId", article.getArticleId());
    document.addDate("displayDate", article.getDisplayDate());
    document.addKeyword("layoutUuid", article.getLayoutUuid());
    document.addKeyword("structureId", article.getStructureId());
    document.addKeyword("templateId", article.getTemplateId());

    JournalStructure structure = null;

    if (Validator.isNotNull(article.getStructureId())) {
        try {
            structure = JournalStructureLocalServiceUtil.getStructure(article.getGroupId(),
                    article.getStructureId());
        } catch (NoSuchStructureException nsse1) {
            Group group = GroupLocalServiceUtil.getCompanyGroup(article.getCompanyId());

            try {
                structure = JournalStructureLocalServiceUtil.getStructure(group.getGroupId(),
                        article.getStructureId());
            } catch (NoSuchStructureException nsse2) {
            }
        }
    }

    processStructure(structure, document, article.getContent());

    return document;
}