List of usage examples for com.liferay.portal.kernel.search SearchContext getFolderIds
public long[] getFolderIds()
From source file:com.liferay.document.library.repository.search.internal.RepositorySearchQueryBuilderImpl.java
License:Open Source License
protected void addContext(BooleanQuery contextQuery, SearchContext searchContext) throws Exception { long[] folderIds = searchContext.getFolderIds(); if (ArrayUtil.isEmpty(folderIds)) { return;//from ww w. j a v a 2 s.c o m } if (folderIds[0] == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return; } BooleanQuery folderIdsQuery = new BooleanQueryImpl(); for (long folderId : folderIds) { try { _dlAppService.getFolder(folderId); } catch (Exception e) { continue; } folderIdsQuery.add(new TermQueryImpl(Field.FOLDER_ID, String.valueOf(folderId)), BooleanClauseOccur.SHOULD); } contextQuery.add(folderIdsQuery, BooleanClauseOccur.MUST); }
From source file:com.liferay.google.drive.repository.GoogleDriveRepository.java
License:Open Source License
@Override public List<ExtRepositorySearchResult<?>> search(SearchContext searchContext, Query query, ExtRepositoryQueryMapper extRepositoryQueryMapper) throws PortalException { try {//from w w w . j a v a2s . c o m Drive drive = getDrive(); Drive.Files driveFiles = drive.files(); Drive.Files.List driveFilesList = driveFiles.list(); String searchQuery = getSearchQuery(searchContext.getKeywords(), searchContext.getFolderIds(), extRepositoryQueryMapper); driveFilesList.setQ(searchQuery); FileList fileList = driveFilesList.execute(); List<File> files = fileList.getItems(); List<ExtRepositorySearchResult<?>> extRepositorySearchResults = new ArrayList<ExtRepositorySearchResult<?>>( files.size()); for (File file : files) { if (_FOLDER_MIME_TYPE.equals(file.getMimeType())) { GoogleDriveFolder googleDriveFolder = new GoogleDriveFolder(file, getRootFolderKey()); ExtRepositorySearchResult<GoogleDriveFolder> extRepositorySearchResult = new ExtRepositorySearchResult<GoogleDriveFolder>( googleDriveFolder, 1.0f, StringPool.BLANK); extRepositorySearchResults.add(extRepositorySearchResult); } else { GoogleDriveFileEntry googleDriveFileEntry = new GoogleDriveFileEntry(file); ExtRepositorySearchResult<GoogleDriveFileEntry> extRepositorySearchResult = new ExtRepositorySearchResult<GoogleDriveFileEntry>( googleDriveFileEntry, 1.0f, StringPool.BLANK); extRepositorySearchResults.add(extRepositorySearchResult); } } return extRepositorySearchResults; } catch (IOException ioe) { _log.error(ioe, ioe); throw new SystemException(ioe); } }
From source file:com.liferay.portlet.bookmarks.util.BookmarksIndexer.java
License:Open Source License
@Override public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext) throws Exception { long[] folderIds = searchContext.getFolderIds(); if ((folderIds != null) && (folderIds.length > 0)) { if (folderIds[0] == BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return; }//from w w w. jav a 2 s . c o m BooleanQuery folderIdsQuery = BooleanQueryFactoryUtil.create(searchContext); for (long folderId : folderIds) { try { BookmarksFolderServiceUtil.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 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 v a2 s . 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); } }