List of usage examples for com.liferay.portal.kernel.search Field CLASS_PK
String CLASS_PK
To view the source code for com.liferay.portal.kernel.search Field CLASS_PK.
Click Source Link
From source file:com.cd.learning.hook.MBUtil.java
License:Open Source License
public static List<Object> getEntries(Hits hits) { List<Object> entries = new ArrayList<Object>(); for (Document document : hits.getDocs()) { long categoryId = GetterUtil.getLong(document.get(Field.CATEGORY_ID)); try {/*from ww w . j ava2 s.c om*/ MBCategoryLocalServiceUtil.getCategory(categoryId); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Message boards search index is stale and contains " + "category " + categoryId); } continue; } long threadId = GetterUtil.getLong(document.get("threadId")); try { MBThreadLocalServiceUtil.getThread(threadId); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Message boards search index is stale and contains " + "thread " + threadId); } continue; } String entryClassName = document.get(Field.ENTRY_CLASS_NAME); long entryClassPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK)); Object obj = null; try { if (entryClassName.equals(DLFileEntry.class.getName())) { long classPK = GetterUtil.getLong(document.get(Field.CLASS_PK)); MBMessageLocalServiceUtil.getMessage(classPK); obj = DLFileEntryLocalServiceUtil.getDLFileEntry(entryClassPK); } else if (entryClassName.equals(MBMessage.class.getName())) { obj = MBMessageLocalServiceUtil.getMessage(entryClassPK); } entries.add(obj); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Message boards search index is stale and contains " + "entry {className=" + entryClassName + ", " + "classPK=" + entryClassPK + "}"); } continue; } } return entries; }
From source file:com.liferay.calendar.search.CalendarBookingIndexer.java
License:Open Source License
@Override protected Document doGetDocument(CalendarBooking calendarBooking) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, calendarBooking); document.addKeyword(Field.CLASS_NAME_ID, _classNameLocalService.getClassNameId(Calendar.class)); document.addKeyword(Field.CLASS_PK, calendarBooking.getCalendarId()); Locale defaultLocale = LocaleUtil.getSiteDefault(); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); String[] descriptionLanguageIds = getLanguageIds(defaultLanguageId, calendarBooking.getDescription()); for (String descriptionLanguageId : descriptionLanguageIds) { String description = calendarBooking.getDescription(descriptionLanguageId); document.addText(LocalizationUtil.getLocalizedName(Field.DESCRIPTION, descriptionLanguageId), description);// w ww . java 2 s . c o m } document.addKeyword(Field.RELATED_ENTRY, true); String[] titleLanguageIds = getLanguageIds(defaultLanguageId, calendarBooking.getTitle()); for (String titleLanguageId : titleLanguageIds) { String title = calendarBooking.getTitle(titleLanguageId); document.addText(LocalizationUtil.getLocalizedName(Field.TITLE, titleLanguageId), title); } document.addKeyword(Field.VIEW_ACTION_ID, CalendarActionKeys.VIEW_BOOKING_DETAILS); String calendarBookingId = String.valueOf(calendarBooking.getCalendarBookingId()); if (calendarBooking.isInTrash()) { calendarBookingId = TrashUtil.getOriginalTitle(calendarBookingId); } document.addKeyword("calendarBookingId", calendarBookingId); document.addText("defaultLanguageId", defaultLanguageId); document.addNumber("endTime", calendarBooking.getEndTime()); document.addText("location", calendarBooking.getLocation()); document.addNumber("startTime", calendarBooking.getStartTime()); return document; }
From source file:com.liferay.calendar.search.test.CalendarBookingIndexerIndexedFieldsTest.java
License:Open Source License
protected void populateCalendarBooking(CalendarBooking calendarBooking, Map<String, String> map) { map.put(Field.CLASS_PK, String.valueOf(calendarBooking.getCalendarId())); map.put(Field.ENTRY_CLASS_NAME, calendarBooking.getModelClassName()); map.put(Field.ENTRY_CLASS_PK, String.valueOf(calendarBooking.getCalendarBookingId())); map.put("calendarBookingId", String.valueOf(calendarBooking.getCalendarBookingId())); map.put("endTime", String.valueOf(calendarBooking.getEndTime())); map.put("endTime_sortable", String.valueOf(calendarBooking.getEndTime())); map.put("startTime", String.valueOf(calendarBooking.getStartTime())); map.put("startTime_sortable", String.valueOf(calendarBooking.getStartTime())); }
From source file:com.liferay.document.library.internal.search.DLFileEntrySearchResultContributor.java
License:Open Source License
@Override public void addRelatedModel(SearchResult searchResult, Document document, Locale locale, PortletRequest portletRequest, PortletResponse portletResponse) throws PortalException { long entryClassPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK)); FileEntry fileEntry = _dlAppLocalService.getFileEntry(entryClassPK); if (fileEntry != null) { Summary summary = _summaryFactory.getSummary(document, DLFileEntry.class.getName(), fileEntry.getFileEntryId(), locale, portletRequest, portletResponse); if (Validator.isNull(summary.getContent())) { summary.setContent(fileEntry.getTitle()); }//from w w w. j a v a2 s.co m searchResult.addFileEntry(fileEntry, summary); } else { long classNameId = GetterUtil.getLong(document.get(Field.CLASS_NAME_ID)); ClassName className = _classNameLocalService.getClassName(classNameId); long classPK = GetterUtil.getLong(document.get(Field.CLASS_PK)); Summary summary = _summaryFactory.getSummary(document, className.getClassName(), classPK, locale, portletRequest, portletResponse); searchResult.setSummary(summary); } }
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; }
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.search.JournalArticleIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter, SearchContext searchContext) throws Exception { addSearchTerm(searchQuery, searchContext, Field.ARTICLE_ID, false); 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.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); }//from w w w.ja v a2 s .co m } }
From source file:com.liferay.message.boards.internal.search.MBMessageIndexer.java
License:Open Source License
public MBMessageIndexer() { setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.CLASS_NAME_ID, Field.CLASS_PK, Field.COMPANY_ID, Field.CONTENT, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.GROUP_ID, Field.MODIFIED_DATE, Field.SCOPE_GROUP_ID, Field.TITLE, Field.UID); setFilterSearch(true);//from w w w . j av a 2s. com setPermissionAware(true); }
From source file:com.liferay.message.boards.internal.search.MBThreadIndexer.java
License:Open Source License
public MBThreadIndexer() { setDefaultSelectedFieldNames(Field.CLASS_NAME_ID, Field.CLASS_PK, Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID); setFilterSearch(true);/*from ww w . ja va 2 s . c o m*/ setPermissionAware(true); }
From source file:com.liferay.portlet.documentlibrary.util.DLImpl.java
License:Open Source License
@Override public List<Object> getEntries(Hits hits) { List<Object> entries = new ArrayList<>(); for (Document document : hits.getDocs()) { String entryClassName = GetterUtil.getString(document.get(Field.ENTRY_CLASS_NAME)); long entryClassPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK)); try {// w w w .ja v a2s .c o m Object obj = null; if (entryClassName.equals(DLFileEntry.class.getName())) { obj = DLAppLocalServiceUtil.getFileEntry(entryClassPK); } else if (entryClassName.equals(MBMessage.class.getName())) { long classPK = GetterUtil.getLong(document.get(Field.CLASS_PK)); DLAppLocalServiceUtil.getFileEntry(classPK); obj = MBMessageLocalServiceUtil.getMessage(entryClassPK); } entries.add(obj); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Documents and Media search index is stale and " + "contains entry {className=" + entryClassName + ", classPK=" + entryClassPK + "}"); } } } return entries; }