List of usage examples for com.liferay.portal.kernel.search Field STATUS
String STATUS
To view the source code for com.liferay.portal.kernel.search Field STATUS.
Click Source Link
From source file:com.liferay.dynamic.data.mapping.form.web.internal.display.context.DDMFormViewFormInstanceRecordsDisplayContext.java
License:Open Source License
protected void updateSearchContainerResults() { List<DDMFormInstanceRecord> results = null; int total = 0; DisplayTerms displayTerms = _ddmFormInstanceRecordSearchContainer.getDisplayTerms(); int status = WorkflowConstants.STATUS_ANY; if (Validator.isNull(displayTerms.getKeywords())) { results = _ddmFormInstanceRecordLocalService.getFormInstanceRecords( _ddmFormInstance.getFormInstanceId(), status, _ddmFormInstanceRecordSearchContainer.getStart(), _ddmFormInstanceRecordSearchContainer.getEnd(), _ddmFormInstanceRecordSearchContainer.getOrderByComparator()); total = _ddmFormInstanceRecordLocalService .getFormInstanceRecordsCount(_ddmFormInstance.getFormInstanceId(), status); } else {/*www. j av a 2 s. c o m*/ SearchContext searchContext = SearchContextFactory .getInstance(PortalUtil.getHttpServletRequest(_renderRequest)); searchContext.setAttribute(Field.STATUS, status); searchContext.setAttribute("formInstanceId", _ddmFormInstance.getFormInstanceId()); searchContext.setEnd(_ddmFormInstanceRecordSearchContainer.getEnd()); searchContext.setKeywords(displayTerms.getKeywords()); searchContext.setStart(_ddmFormInstanceRecordSearchContainer.getStart()); BaseModelSearchResult<DDMFormInstanceRecord> baseModelSearchResult = _ddmFormInstanceRecordLocalService .searchFormInstanceRecords(searchContext); results = baseModelSearchResult.getBaseModels(); total = baseModelSearchResult.getLength(); } _ddmFormInstanceRecordSearchContainer.setResults(results); _ddmFormInstanceRecordSearchContainer.setTotal(total); }
From source file:com.liferay.dynamic.data.mapping.internal.search.DDMFormInstanceRecordIndexer.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 ww w . j a va 2 s .c o m*/ long ddmFormInstanceId = GetterUtil.getLong(searchContext.getAttribute("ddmFormInstanceId")); if (ddmFormInstanceId > 0) { contextBooleanFilter.addRequiredTerm("ddmFormInstanceId", ddmFormInstanceId); } addSearchClassTypeIds(contextBooleanFilter, searchContext); String ddmStructureFieldName = (String) searchContext.getAttribute("ddmStructureFieldName"); Serializable ddmStructureFieldValue = searchContext.getAttribute("ddmStructureFieldValue"); if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) { QueryFilter queryFilter = ddmIndexer.createFieldValueQueryFilter(ddmStructureFieldName, ddmStructureFieldValue, searchContext.getLocale()); contextBooleanFilter.add(queryFilter, BooleanClauseOccur.MUST); } }
From source file:com.liferay.dynamic.data.mapping.internal.search.DDMFormInstanceRecordIndexer.java
License:Open Source License
@Override protected Document doGetDocument(DDMFormInstanceRecord ddmFormInstanceRecord) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, ddmFormInstanceRecord); DDMFormInstanceRecordVersion ddmFormInstanceRecordVersion = ddmFormInstanceRecord .getFormInstanceRecordVersion(); DDMFormInstance ddmFormInstance = ddmFormInstanceRecordVersion.getFormInstance(); document.addKeyword(Field.CLASS_NAME_ID, classNameLocalService.getClassNameId(DDMFormInstance.class)); document.addKeyword(Field.CLASS_PK, ddmFormInstance.getFormInstanceId()); document.addKeyword(Field.CLASS_TYPE_ID, ddmFormInstanceRecordVersion.getFormInstanceId()); document.addKeyword(Field.RELATED_ENTRY, true); document.addKeyword(Field.STATUS, ddmFormInstanceRecordVersion.getStatus()); document.addKeyword(Field.VERSION, ddmFormInstanceRecordVersion.getVersion()); document.addKeyword("formInstanceId", ddmFormInstance.getFormInstanceId()); DDMStructure ddmStructure = ddmFormInstance.getStructure(); DDMFormValues ddmFormValues = storageEngine.getDDMFormValues(ddmFormInstanceRecordVersion.getStorageId()); addContent(ddmFormInstanceRecordVersion, ddmFormValues, document); ddmIndexer.addAttributes(document, ddmStructure, ddmFormValues); return document; }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected SearchContext buildSearchContext(long companyId, long groupId, List<Long> folderIds, long classNameId, String articleId, String title, String description, String content, int status, String ddmStructureKey, String ddmTemplateKey, LinkedHashMap<String, Object> params, boolean andSearch, int start, int end, Sort sort) {//from w w w. j av a 2s . c om SearchContext searchContext = new SearchContext(); searchContext.setAndSearch(andSearch); Map<String, Serializable> attributes = new HashMap<>(); attributes.put(Field.ARTICLE_ID, articleId); 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("ddmStructureKey", ddmStructureKey); attributes.put("ddmTemplateKey", ddmTemplateKey); attributes.put("params", params); searchContext.setAttributes(attributes); searchContext.setCompanyId(companyId); searchContext.setEnd(end); searchContext.setFolderIds(folderIds); searchContext.setGroupIds(new long[] { groupId }); if (params != null) { searchContext.setIncludeDiscussions(GetterUtil.getBoolean(params.get("includeDiscussions"))); String keywords = (String) params.remove("keywords"); if (Validator.isNotNull(keywords)) { searchContext.setKeywords(keywords); } } QueryConfig queryConfig = new QueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); searchContext.setQueryConfig(queryConfig); if (sort != null) { searchContext.setSorts(sort); } searchContext.setStart(start); return searchContext; }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected SearchContext buildSearchContext(long groupId, long userId, long creatorUserId, int status, int start, int end) throws PortalException { SearchContext searchContext = new SearchContext(); searchContext.setAttribute(Field.STATUS, status); searchContext.setAttribute("paginationType", "none"); if (creatorUserId > 0) { searchContext.setAttribute(Field.USER_ID, String.valueOf(creatorUserId)); }// www . j av a 2 s .c om Group group = groupLocalService.getGroup(groupId); searchContext.setCompanyId(group.getCompanyId()); searchContext.setEnd(end); searchContext.setGroupIds(new long[] { groupId }); searchContext.setSorts(new Sort(Field.MODIFIED_DATE, true)); searchContext.setStart(start); searchContext.setUserId(userId); return searchContext; }
From source file:com.liferay.journal.service.test.JournalArticleIndexVersionsTest.java
License:Open Source License
protected void assertSearchCount(long expectedCount, boolean head) throws Exception { Indexer<JournalArticle> indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class); SearchContext searchContext = SearchContextTestUtil.getSearchContext(_group.getGroupId()); if (!head) {// w w w. j av a 2s .c o m searchContext.setAttribute(Field.STATUS, WorkflowConstants.STATUS_ANY); searchContext.setAttribute("head", Boolean.FALSE); } searchContext.setGroupIds(new long[] { _group.getGroupId() }); Hits results = indexer.search(searchContext); Assert.assertEquals(results.toString(), expectedCount, results.getLength()); }
From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java
License:Open Source License
protected SearchContext buildSearchContext(long companyId, long groupId, List<java.lang.Long> folderIds, long classNameId, String ddmStructureKey, String ddmTemplateKey, String keywords, LinkedHashMap<String, Object> params, int start, int end, Sort sort, boolean showVersions) { String articleId = null;//from w ww .j av a 2 s. c om String title = null; String description = null; String content = null; boolean andOperator = false; if (Validator.isNotNull(keywords)) { articleId = keywords; title = keywords; description = keywords; content = keywords; } else { andOperator = true; } if (params != null) { params.put("keywords", keywords); } SearchContext searchContext = new SearchContext(); searchContext.setAndSearch(andOperator); Map<String, Serializable> attributes = new HashMap<>(); attributes.put(Field.ARTICLE_ID, articleId); attributes.put(Field.CLASS_NAME_ID, classNameId); attributes.put(Field.CONTENT, content); attributes.put(Field.DESCRIPTION, description); attributes.put(Field.STATUS, getStatus()); attributes.put(Field.TITLE, title); attributes.put("ddmStructureKey", ddmStructureKey); attributes.put("ddmTemplateKey", ddmTemplateKey); attributes.put("params", params); searchContext.setAttributes(attributes); searchContext.setCompanyId(companyId); searchContext.setEnd(end); searchContext.setFolderIds(folderIds); searchContext.setGroupIds(new long[] { groupId }); searchContext.setIncludeDiscussions(GetterUtil.getBoolean(params.get("includeDiscussions"), true)); if (params != null) { keywords = (String) params.remove("keywords"); if (Validator.isNotNull(keywords)) { searchContext.setKeywords(keywords); } } searchContext.setAttribute("head", !showVersions); searchContext.setAttribute("params", params); searchContext.setEnd(end); searchContext.setFolderIds(folderIds); searchContext.setStart(start); QueryConfig queryConfig = new QueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); searchContext.setQueryConfig(queryConfig); if (sort != null) { searchContext.setSorts(sort); } searchContext.setStart(start); return searchContext; }
From source file:com.liferay.portlet.documentlibrary.util.DLIndexer.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_APPROVED); if (status != WorkflowConstants.STATUS_ANY) { contextQuery.addRequiredTerm(Field.STATUS, status); }/*from w w w . j a va 2s.c om*/ long[] folderIds = searchContext.getFolderIds(); if ((folderIds != null) && (folderIds.length > 0)) { if (folderIds[0] == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return; } BooleanQuery folderIdsQuery = BooleanQueryFactoryUtil.create(searchContext); for (long folderId : folderIds) { try { DLFolderServiceUtil.getFolder(folderId); } catch (Exception e) { continue; } folderIdsQuery.addTerm(Field.FOLDER_ID, folderId); } contextQuery.add(folderIdsQuery, BooleanClauseOccur.MUST); } }
From source file:com.liferay.portlet.documentlibrary.util.DLIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { DLFileEntry dlFileEntry = (DLFileEntry) obj; if (_log.isDebugEnabled()) { _log.debug("Indexing document " + dlFileEntry); }/*w w w . j a v a 2s . co m*/ boolean indexContent = true; InputStream is = null; try { if (PropsValues.DL_FILE_INDEXING_MAX_SIZE == 0) { indexContent = false; } else if (PropsValues.DL_FILE_INDEXING_MAX_SIZE != -1) { if (dlFileEntry.getSize() > PropsValues.DL_FILE_INDEXING_MAX_SIZE) { indexContent = false; } } if (indexContent) { String[] ignoreExtensions = PrefsPropsUtil .getStringArray(PropsKeys.DL_FILE_INDEXING_IGNORE_EXTENSIONS, StringPool.COMMA); if (ArrayUtil.contains(ignoreExtensions, StringPool.PERIOD + dlFileEntry.getExtension())) { indexContent = false; } } if (indexContent) { is = dlFileEntry.getFileVersion().getContentStream(false); } } catch (Exception e) { } if (indexContent && (is == null)) { if (_log.isDebugEnabled()) { _log.debug("Document " + dlFileEntry + " does not have any content"); } return null; } try { Document document = new DocumentImpl(); long fileEntryId = dlFileEntry.getFileEntryId(); document.addUID(PORTLET_ID, fileEntryId); List<AssetCategory> assetCategories = AssetCategoryLocalServiceUtil .getCategories(DLFileEntry.class.getName(), fileEntryId); long[] assetCategoryIds = StringUtil .split(ListUtil.toString(assetCategories, AssetCategory.CATEGORY_ID_ACCESSOR), 0L); document.addKeyword(Field.ASSET_CATEGORY_IDS, assetCategoryIds); String[] assetCategoryNames = StringUtil .split(ListUtil.toString(assetCategories, AssetCategory.NAME_ACCESSOR)); document.addKeyword(Field.ASSET_CATEGORY_NAMES, assetCategoryNames); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(DLFileEntry.class.getName(), fileEntryId); document.addKeyword(Field.ASSET_TAG_NAMES, assetTagNames); document.addKeyword(Field.COMPANY_ID, dlFileEntry.getCompanyId()); if (indexContent) { try { document.addFile(Field.CONTENT, is, dlFileEntry.getTitle()); } catch (IOException ioe) { throw new SearchException("Cannot extract text from file" + dlFileEntry); } } document.addText(Field.DESCRIPTION, dlFileEntry.getDescription()); document.addKeyword(Field.ENTRY_CLASS_NAME, DLFileEntry.class.getName()); document.addKeyword(Field.ENTRY_CLASS_PK, fileEntryId); document.addKeyword(Field.FOLDER_ID, dlFileEntry.getFolderId()); document.addKeyword(Field.GROUP_ID, getParentGroupId(dlFileEntry.getGroupId())); document.addDate(Field.MODIFIED_DATE, dlFileEntry.getModifiedDate()); document.addKeyword(Field.PORTLET_ID, PORTLET_ID); document.addText(Field.PROPERTIES, dlFileEntry.getLuceneProperties()); document.addKeyword(Field.SCOPE_GROUP_ID, dlFileEntry.getGroupId()); DLFileVersion dlFileVersion = dlFileEntry.getFileVersion(); document.addKeyword(Field.STATUS, dlFileVersion.getStatus()); document.addText(Field.TITLE, dlFileEntry.getTitle()); long userId = dlFileEntry.getUserId(); document.addKeyword(Field.USER_ID, userId); document.addKeyword(Field.USER_NAME, PortalUtil.getUserName(userId, dlFileEntry.getUserName()), true); document.addKeyword("dataRepositoryId", dlFileEntry.getDataRepositoryId()); document.addKeyword("extension", dlFileEntry.getExtension()); document.addKeyword("fileEntryTypeId", dlFileEntry.getFileEntryTypeId()); document.addKeyword("path", dlFileEntry.getTitle()); ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(dlFileEntry.getCompanyId(), DLFileEntry.class.getName(), dlFileVersion.getFileVersionId()); ExpandoBridgeIndexerUtil.addAttributes(document, expandoBridge); addFileEntryTypeAttributes(document, dlFileVersion); if (_log.isDebugEnabled()) { _log.debug("Document " + dlFileEntry + " indexed successfully"); } return document; } finally { if (is != null) { try { is.close(); } catch (IOException ioe) { } } } }
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 ww w. j a v a 2s.c om*/ 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); } }