List of usage examples for com.liferay.portal.kernel.search SearchContext setStart
public void setStart(int start)
From source file:ch.inofix.contact.service.impl.ContactLocalServiceImpl.java
License:Open Source License
protected SearchContext buildSearchContext(long userId, long groupId, long ownerUserId, String company, String fullName, int status, LinkedHashMap<String, Object> params, boolean andSearch, int start, int end, Sort sort) throws PortalException { SearchContext searchContext = new SearchContext(); searchContext.setAttribute(Field.STATUS, status); if (Validator.isNotNull(company)) { searchContext.setAttribute("company", company); }/*from w w w.j a v a2s . co m*/ if (Validator.isNotNull(fullName)) { searchContext.setAttribute("fullName", fullName); } searchContext.setAttribute("paginationType", "more"); Group group = GroupLocalServiceUtil.getGroup(groupId); searchContext.setCompanyId(group.getCompanyId()); if (ownerUserId > 0) { searchContext.setOwnerUserId(ownerUserId); } searchContext.setEnd(end); if (groupId > 0) { searchContext.setGroupIds(new long[] { groupId }); } searchContext.setSorts(sort); searchContext.setStart(start); searchContext.setUserId(userId); searchContext.setAndSearch(andSearch); if (params != null) { 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:ch.inofix.referencemanager.service.impl.BibliographyServiceImpl.java
License:Open Source License
/** * @param userId//from w w w . j a v a 2 s . c om * the userId of the current user * @param groupId * the scopeGroupId of the bibliography. 0 means: any scope. * @param ownerUserId * the userId of the bibliography owner. -1 means: ignore * ownerUserId parameter. * @param keywords * @param start * @param end * @param sort * @return the hits for the given parameters * @since 1.0.0 * @throws PortalException */ public Hits search(long userId, long groupId, long ownerUserId, String keywords, int start, int end, Sort sort) throws PortalException { if (sort == null) { sort = new Sort(Field.MODIFIED_DATE, true); } Indexer<Bibliography> indexer = IndexerRegistryUtil.getIndexer(Bibliography.class.getName()); SearchContext searchContext = new SearchContext(); searchContext.setAttribute(Field.STATUS, WorkflowConstants.STATUS_ANY); searchContext.setAttribute("paginationType", "more"); User user = UserLocalServiceUtil.getUser(userId); searchContext.setCompanyId(user.getCompanyId()); searchContext.setEnd(end); if (groupId > 0) { searchContext.setGroupIds(new long[] { groupId }); } searchContext.setSorts(sort); searchContext.setStart(start); searchContext.setUserId(userId); searchContext.setOwnerUserId(ownerUserId); return indexer.search(searchContext); }
From source file:ch.inofix.referencemanager.service.impl.ReferenceLocalServiceImpl.java
License:Open Source License
protected SearchContext buildSearchContext(long userId, long groupId, long bibliographyId, String author, String title, String year, int status, LinkedHashMap<String, Object> params, boolean andSearch, int start, int end, Sort sort) throws PortalException { SearchContext searchContext = new SearchContext(); searchContext.setAttribute(Field.STATUS, status); if (Validator.isNotNull(author)) { searchContext.setAttribute("author", author); }//from w ww . java 2s. com if (bibliographyId > 0) { searchContext.setAttribute("bibliographyId", bibliographyId); } if (Validator.isNotNull(title)) { searchContext.setAttribute("title", title); } if (Validator.isNotNull(year)) { searchContext.setAttribute("year", year); } searchContext.setAttribute("paginationType", "more"); Group group = GroupLocalServiceUtil.getGroup(groupId); searchContext.setCompanyId(group.getCompanyId()); searchContext.setEnd(end); if (groupId > 0) { searchContext.setGroupIds(new long[] { groupId }); } searchContext.setSorts(sort); searchContext.setStart(start); searchContext.setUserId(userId); searchContext.setAndSearch(andSearch); if (params != null) { 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:ch.inofix.timetracker.service.impl.TaskRecordLocalServiceImpl.java
License:Open Source License
@Override public Hits search(long userId, long groupId, String keywords, int start, int end, Sort sort) throws PortalException { if (sort == null) { sort = new Sort(Field.MODIFIED_DATE, true); }// w w w. j av a 2 s .c om Indexer<TaskRecord> indexer = IndexerRegistryUtil.getIndexer(TaskRecord.class.getName()); SearchContext searchContext = new SearchContext(); searchContext.setAttribute(Field.STATUS, WorkflowConstants.STATUS_ANY); searchContext.setAttribute("paginationType", "more"); Group group = GroupLocalServiceUtil.getGroup(groupId); searchContext.setCompanyId(group.getCompanyId()); searchContext.setEnd(end); if (groupId > 0) { searchContext.setGroupIds(new long[] { groupId }); } searchContext.setSorts(sort); searchContext.setStart(start); searchContext.setUserId(userId); searchContext.setKeywords(keywords); return indexer.search(searchContext); }
From source file:com.liferay.alloy.mvc.BaseAlloyControllerImpl.java
License:Open Source License
protected AlloySearchResult search(Indexer indexer, AlloyServiceInvoker alloyServiceInvoker, HttpServletRequest request, PortletRequest portletRequest, SearchContainer<? extends BaseModel<?>> searchContainer, Map<String, Serializable> attributes, String keywords, Sort[] sorts) throws Exception { if (indexer == null) { throw new Exception("No indexer found for " + controllerPath); }//from www . j a v a2 s .c om AlloySearchResult alloySearchResult = new AlloySearchResult(); alloySearchResult.setAlloyServiceInvoker(alloyServiceInvoker); if (searchContainer == null) { searchContainer = new SearchContainer<BaseModel<?>>(portletRequest, portletURL, null, null); } SearchContext searchContext = SearchContextFactory.getInstance(request); boolean andOperator = ParamUtil.getBoolean(request, "andOperator"); searchContext.setAndSearch(andOperator); if ((attributes != null) && !attributes.isEmpty()) { searchContext.setAttributes(attributes); } searchContext.setEnd(searchContainer.getEnd()); Class<?> indexerClass = Class.forName(indexer.getClassNames()[0]); if (!GroupedModel.class.isAssignableFrom(indexerClass)) { searchContext.setGroupIds(null); } else if (searchContext.getAttribute(Field.GROUP_ID) != null) { long groupId = GetterUtil.getLong(searchContext.getAttribute(Field.GROUP_ID)); searchContext.setGroupIds(new long[] { groupId }); } if (Validator.isNotNull(keywords)) { searchContext.setKeywords(keywords); } if (ArrayUtil.isNotEmpty(sorts)) { searchContext.setSorts(sorts); } searchContext.setStart(searchContainer.getStart()); Hits hits = indexer.search(searchContext); alloySearchResult.setHits(hits); alloySearchResult.setPortletURL(portletURL, searchContext.getAttributes()); alloySearchResult.afterPropertiesSet(); return alloySearchResult; }
From source file:com.liferay.asset.internal.util.AssetHelperImpl.java
License:Open Source License
private AssetSearcher _getAssetSearcher(SearchContext searchContext, AssetEntryQuery assetEntryQuery, int start, int end) throws Exception { Indexer<?> searcher = AssetSearcher.getInstance(); AssetSearcher assetSearcher = (AssetSearcher) searcher; assetSearcher.setAssetEntryQuery(assetEntryQuery); Layout layout = assetEntryQuery.getLayout(); if (layout != null) { searchContext.setAttribute(Field.LAYOUT_UUID, layout.getUuid()); }/*from w ww. j a v a 2s. c o m*/ String ddmStructureFieldName = (String) assetEntryQuery.getAttribute("ddmStructureFieldName"); Serializable ddmStructureFieldValue = assetEntryQuery.getAttribute("ddmStructureFieldValue"); if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) { searchContext.setAttribute("ddmStructureFieldName", ddmStructureFieldName); searchContext.setAttribute("ddmStructureFieldValue", ddmStructureFieldValue); } String paginationType = GetterUtil.getString(assetEntryQuery.getPaginationType(), "more"); if (!paginationType.equals("none") && !paginationType.equals("simple")) { searchContext.setAttribute("paginationType", paginationType); } searchContext.setClassTypeIds(assetEntryQuery.getClassTypeIds()); searchContext.setEnd(end); searchContext.setGroupIds(assetEntryQuery.getGroupIds()); if (Validator.isNull(assetEntryQuery.getKeywords())) { QueryConfig queryConfig = searchContext.getQueryConfig(); queryConfig.setScoreEnabled(false); } else { searchContext.setLike(true); } searchContext.setSorts(_getSorts(assetEntryQuery, searchContext.getLocale())); searchContext.setStart(start); return assetSearcher; }
From source file:com.liferay.bookmarks.service.impl.BookmarksEntryLocalServiceImpl.java
License:Open Source License
@Override public Hits search(long groupId, long userId, long creatorUserId, int status, int start, int end) throws PortalException { Indexer<BookmarksEntry> indexer = IndexerRegistryUtil.getIndexer(BookmarksEntry.class.getName()); SearchContext searchContext = new SearchContext(); searchContext.setAttribute(Field.STATUS, status); if (creatorUserId > 0) { searchContext.setAttribute(Field.USER_ID, String.valueOf(creatorUserId)); }// w w w .j ava 2 s . c om searchContext.setAttribute("paginationType", "none"); 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); QueryConfig queryConfig = searchContext.getQueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false); return indexer.search(searchContext); }
From source file:com.liferay.bookmarks.service.test.BookmarksFolderServiceTest.java
License:Open Source License
@Test public void testSearchRange() throws Exception { BookmarksEntry entry = BookmarksTestUtil.addEntry(_group.getGroupId(), true); BookmarksTestUtil.addEntry(_group.getGroupId(), true); BookmarksTestUtil.addEntry(_group.getGroupId(), true); BookmarksTestUtil.addEntry(_group.getGroupId(), true); SearchContext searchContext = BookmarksTestUtil.getSearchContext(_group.getCompanyId(), _group.getGroupId(), entry.getFolderId(), "test"); Indexer<BookmarksEntry> indexer = IndexerRegistryUtil.getIndexer(BookmarksEntry.class); searchContext.setEnd(3);//from w w w . j av a2 s . c o m searchContext.setFolderIds((long[]) null); searchContext.setStart(1); Hits hits = indexer.search(searchContext); Assert.assertEquals(4, hits.getLength()); Document[] documents = hits.getDocs(); Assert.assertEquals(2, documents.length); }
From source file:com.liferay.calendar.web.internal.portlet.CalendarPortlet.java
License:Open Source License
protected Hits search(ThemeDisplay themeDisplay, String keywords) throws Exception { SearchContext searchContext = new SearchContext(); keywords = StringUtil.toLowerCase(keywords); searchContext.setAttribute(Field.NAME, keywords); searchContext.setAttribute("resourceName", keywords); searchContext.setCompanyId(themeDisplay.getCompanyId()); searchContext.setEnd(SearchContainer.DEFAULT_DELTA); searchContext.setGroupIds(new long[0]); Group group = themeDisplay.getScopeGroup(); searchContext.setIncludeStagingGroups(group.isStagingGroup()); searchContext.setStart(0); searchContext.setUserId(themeDisplay.getUserId()); Indexer<?> indexer = CalendarSearcher.getInstance(); return indexer.search(searchContext); }
From source file:com.liferay.content.targeting.service.impl.CampaignLocalServiceImpl.java
License:Open Source License
protected SearchContext buildSearchContext(long groupId, String keywords, int start, int end) throws PortalException, SystemException { SearchContext searchContext = new SearchContext(); Group group = GroupLocalServiceUtil.getGroup(groupId); searchContext.setCompanyId(group.getCompanyId()); searchContext.setEnd(end);//from ww w . ja v a2 s.com searchContext.setGroupIds(new long[] { groupId }); searchContext.setKeywords(keywords); searchContext.setStart(start); return searchContext; }