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: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 ww w. j av a 2s .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 . ja v a2 s . com*/ * 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); }/*w w w . j a v a 2 s.co m*/ 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 a v a2s . c o m*/ 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.BaseAlloyIndexer.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 www . j a v a 2 s . c o m }
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 ww. ja v a 2s .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.calendar.search.test.CalendarBookingIndexerIndexedFieldsTest.java
License:Open Source License
@Test public void testIndexedFields() throws Exception { String originalTitle = "entity title"; String translatedTitle = "entitas neve"; String description = StringUtil.toLowerCase(RandomTestUtil.randomString()); CalendarBooking calendarBooking = addCalendarBooking(new LocalizedValuesMap() { {//from w w w .jav a 2s .c o m put(LocaleUtil.US, originalTitle); put(LocaleUtil.HUNGARY, translatedTitle); } }, new LocalizedValuesMap() { { put(LocaleUtil.US, originalTitle); put(LocaleUtil.HUNGARY, translatedTitle); } }, new LocalizedValuesMap() { { put(LocaleUtil.US, description); put(LocaleUtil.HUNGARY, description); } }); Map<String, String> map = new HashMap<>(); map.put(Field.CLASS_NAME_ID, String.valueOf(portal.getClassNameId(Calendar.class))); map.put(Field.EXPIRATION_DATE, "99950812133000"); map.put(Field.EXPIRATION_DATE.concat("_sortable"), "9223372036854775807"); map.put(Field.PRIORITY, "0.0"); map.put(Field.PUBLISH_DATE, "19700101000000"); map.put(Field.PUBLISH_DATE.concat("_sortable"), "0"); map.put(Field.RELATED_ENTRY, "true"); map.put(Field.STAGING_GROUP, "false"); map.put(Field.STATUS, "0"); map.put("viewActionId", CalendarActionKeys.VIEW_BOOKING_DETAILS); populateTitle(originalTitle, map); populateTranslatedTitle(translatedTitle, map); CalendarResource calendarResource = calendarBooking.getCalendarResource(); populateCalendarResource(calendarResource, map); Calendar calendar = calendarResource.getDefaultCalendar(); populateCalendar(calendar, map); populateCalendarBooking(calendarBooking, map); DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat("yyyyMMddHHmm"); populateCalendarDate(Field.CREATE_DATE, calendar.getCreateDate(), dateFormat, map); populateCalendarDate(Field.MODIFIED_DATE, calendar.getModifiedDate(), dateFormat, map); calendarFieldsFixture.populateGroupRoleId(map); calendarFieldsFixture.populateRoleId("Owner", map); calendarFieldsFixture.populateUID(calendarBooking, map); String keywords = "nev"; Document document = calendarSearchFixture.searchOnlyOne(keywords, LocaleUtil.HUNGARY); adjustDatePrecision(Field.CREATE_DATE, document, dateFormat); adjustDatePrecision(Field.MODIFIED_DATE, document, dateFormat); FieldValuesAssert.assertFieldValues(map, document, keywords); }
From source file:com.liferay.dynamic.data.lists.form.web.internal.display.context.DDLFormViewRecordsDisplayContext.java
License:Open Source License
protected void updateSearchContainerResults() { List<DDLRecord> results = null; int total = 0; DisplayTerms displayTerms = _recordSearchContainer.getDisplayTerms(); int status = WorkflowConstants.STATUS_ANY; if (Validator.isNull(displayTerms.getKeywords())) { results = _ddlRecordLocalService.getRecords(_ddlRecordSet.getRecordSetId(), status, _recordSearchContainer.getStart(), _recordSearchContainer.getEnd(), _recordSearchContainer.getOrderByComparator()); total = _ddlRecordLocalService.getRecordsCount(_ddlRecordSet.getRecordSetId(), status); } else {/*from ww w .ja v a 2 s .c o m*/ SearchContext searchContext = SearchContextFactory .getInstance(PortalUtil.getHttpServletRequest(_renderRequest)); searchContext.setAttribute(Field.STATUS, status); searchContext.setAttribute("recordSetId", _ddlRecordSet.getRecordSetId()); searchContext.setAttribute("recordSetScope", _ddlRecordSet.getScope()); searchContext.setEnd(_recordSearchContainer.getEnd()); searchContext.setKeywords(displayTerms.getKeywords()); searchContext.setStart(_recordSearchContainer.getStart()); BaseModelSearchResult<DDLRecord> baseModelSearchResult = _ddlRecordLocalService .searchDDLRecords(searchContext); results = baseModelSearchResult.getBaseModels(); total = baseModelSearchResult.getLength(); } _recordSearchContainer.setResults(results); _recordSearchContainer.setTotal(total); }
From source file:com.liferay.dynamic.data.lists.internal.search.DDLRecordIndexer.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 w w.j a v a2 s . c o m long recordSetId = GetterUtil.getLong(searchContext.getAttribute("recordSetId")); if (recordSetId > 0) { contextBooleanFilter.addRequiredTerm("recordSetId", recordSetId); } long recordSetScope = GetterUtil.getLong(searchContext.getAttribute("recordSetScope"), DDLRecordSetConstants.SCOPE_DYNAMIC_DATA_LISTS); contextBooleanFilter.addRequiredTerm("recordSetScope", recordSetScope); 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.lists.internal.search.DDLRecordIndexer.java
License:Open Source License
@Override protected Document doGetDocument(DDLRecord ddlRecord) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, ddlRecord); DDLRecordVersion recordVersion = ddlRecord.getRecordVersion(); DDLRecordSet recordSet = recordVersion.getRecordSet(); document.addKeyword(Field.CLASS_NAME_ID, classNameLocalService.getClassNameId(DDLRecordSet.class)); document.addKeyword(Field.CLASS_PK, recordSet.getRecordSetId()); document.addKeyword(Field.CLASS_TYPE_ID, recordVersion.getRecordSetId()); document.addKeyword(Field.RELATED_ENTRY, true); document.addKeyword(Field.STATUS, recordVersion.getStatus()); document.addKeyword(Field.VERSION, recordVersion.getVersion()); document.addText("ddmContent", extractDDMContent(recordVersion, LocaleUtil.getSiteDefault())); document.addKeyword("recordSetId", recordSet.getRecordSetId()); document.addKeyword("recordSetScope", recordSet.getScope()); DDMStructure ddmStructure = recordSet.getDDMStructure(); DDMFormValues ddmFormValues = storageEngine.getDDMFormValues(recordVersion.getDDMStorageId()); ddmIndexer.addAttributes(document, ddmStructure, ddmFormValues); return document; }