List of usage examples for com.liferay.portal.kernel.search Document addLocalizedText
public void addLocalizedText(String name, Map<Locale, String> values);
From source file:com.liferay.calendar.util.CalendarIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object object) throws Exception { Calendar calendar = (Calendar) object; Document document = getBaseModelDocument(CLASS_NAME, calendar); document.addLocalizedText(Field.DESCRIPTION, calendar.getDescriptionMap()); document.addLocalizedText(Field.NAME, calendar.getNameMap()); document.addKeyword("calendarId", calendar.getCalendarId()); Locale defaultLocale = LocaleUtil.getSiteDefault(); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); document.addText("defaultLanguageId", defaultLanguageId); CalendarResource calendarResource = calendar.getCalendarResource(); document.addLocalizedText("resourceName", calendarResource.getNameMap()); return document; }
From source file:com.liferay.configuration.admin.web.internal.search.ConfigurationModelIndexer.java
License:Open Source License
@Override protected Document doGetDocument(ConfigurationModel configurationModel) throws Exception { Document document = newDocument(); document.addUID(ConfigurationAdminPortletKeys.SYSTEM_SETTINGS, configurationModel.getID()); document.addKeyword(FieldNames.CONFIGURATION_MODEL_FACTORY_PID, configurationModel.getFactoryPid()); document.addKeyword(FieldNames.CONFIGURATION_MODEL_ID, configurationModel.getID()); document.addKeyword(Field.COMPANY_ID, CompanyConstants.SYSTEM); ResourceBundleLoader resourceBundleLoader = _resourceBundleLoaderProvider .getResourceBundleLoader(configurationModel.getBundleSymbolicName()); document.addLocalizedText(Field.DESCRIPTION, _translate(resourceBundleLoader, GetterUtil.getString(configurationModel.getDescription()))); document.addKeyword(Field.ENTRY_CLASS_NAME, getClassName()); AttributeDefinition[] requiredAttributeDefinitions = configurationModel .getAttributeDefinitions(ObjectClassDefinition.ALL); List<String> attributeNames = new ArrayList<>(requiredAttributeDefinitions.length); List<String> attributeDescriptions = new ArrayList<>(requiredAttributeDefinitions.length); for (AttributeDefinition attributeDefinition : requiredAttributeDefinitions) { attributeNames.add(attributeDefinition.getName()); attributeDescriptions.add(attributeDefinition.getDescription()); }/*from w ww. ja v a 2 s . c o m*/ document.addKeyword(FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_NAME, attributeNames.toArray(new String[attributeNames.size()])); document.addText(FieldNames.CONFIGURATION_MODEL_ATTRIBUTE_DESCRIPTION, attributeDescriptions.toArray(new String[attributeDescriptions.size()])); document.addLocalizedText(Field.TITLE, _translate(resourceBundleLoader, GetterUtil.getString(configurationModel.getName()))); return document; }
From source file:com.liferay.content.targeting.util.CampaignIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { Campaign campaign = (Campaign) obj;/*ww w . j a va 2 s. c om*/ if (_log.isDebugEnabled()) { _log.debug("Indexing campaign " + campaign); } Document document = getBaseModelDocument(PORTLET_ID, campaign); document.addLocalizedText(Field.DESCRIPTION, campaign.getDescriptionMap()); document.addLocalizedText(Field.NAME, campaign.getNameMap()); document.addKeyword("campaignId", campaign.getCampaignId()); if (_log.isDebugEnabled()) { _log.debug("Campaign " + campaign + " indexed successfully"); } return document; }
From source file:com.liferay.content.targeting.util.UserSegmentIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { UserSegment userSegment = (UserSegment) obj; if (_log.isDebugEnabled()) { _log.debug("Indexing user segment " + userSegment); }/*from ww w .ja va 2 s.c o m*/ Document document = getBaseModelDocument(PORTLET_ID, userSegment); document.addLocalizedText(Field.DESCRIPTION, userSegment.getDescriptionMap()); document.addLocalizedText(Field.NAME, userSegment.getNameMap()); document.addKeyword("userSegmentId", userSegment.getUserSegmentId()); if (_log.isDebugEnabled()) { _log.debug("User segment " + userSegment + " indexed successfully"); } return document; }
From source file:com.liferay.hook.indexer.MBMessageIndexerPostProcessor.java
License:Open Source License
@Override public void postProcessDocument(Document document, Object object) throws Exception { MBMessage mbMessage = (MBMessage) object; Map<Locale, String> contentsMap = new HashMap<Locale, String>(); Map<Locale, String> titleMap = new HashMap<Locale, String>(); // Get all avilable languages of this site to create indexs for all of // them.//w w w . j a va 2 s. c o m // // To get Site Language, use LocaleThreadLocal.getSiteDefaultLocale() // To get Display language, use // LocaleThreadLocal.getThemeDisplayLocale() Long groupId = mbMessage.getGroupId(); Locale locales[] = LanguageUtil.getAvailableLocales(groupId); String content = document.get(Field.CONTENT); String title = document.get(Field.TITLE); if (content.length() <= 0) { return; } for (int i = 0; i < locales.length; i++) { contentsMap.put(locales[i], content); titleMap.put(locales[i], title); } document.addLocalizedText(Field.TITLE, titleMap); document.addLocalizedText(Field.CONTENT, contentsMap); }
From source file:com.liferay.portlet.journal.util.JournalIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { JournalArticle article = (JournalArticle) obj; Document document = getBaseModelDocument(PORTLET_ID, article); document.addUID(PORTLET_ID, article.getGroupId(), article.getArticleId()); Locale defaultLocale = LocaleUtil.getDefault(); String defaultLangaugeId = LocaleUtil.toLanguageId(defaultLocale); String[] languageIds = getLanguageIds(defaultLangaugeId, article.getContent()); for (String languageId : languageIds) { String content = extractContent(article.getContentByLocale(languageId)); if (languageId.equals(defaultLangaugeId)) { document.addText(Field.CONTENT, content); }/*from ww w .j a v a2 s.co m*/ document.addText(Field.CONTENT.concat(StringPool.UNDERLINE).concat(languageId), content); } document.addLocalizedText(Field.DESCRIPTION, article.getDescriptionMap()); document.addLocalizedText(Field.TITLE, article.getTitleMap()); document.addKeyword(Field.TYPE, article.getType()); document.addKeyword(Field.VERSION, article.getVersion()); document.addKeyword("articleId", article.getArticleId()); document.addDate("displayDate", article.getDisplayDate()); document.addKeyword("layoutUuid", article.getLayoutUuid()); document.addKeyword("structureId", article.getStructureId()); document.addKeyword("templateId", article.getTemplateId()); JournalStructure structure = null; if (Validator.isNotNull(article.getStructureId())) { try { structure = JournalStructureLocalServiceUtil.getStructure(article.getGroupId(), article.getStructureId()); } catch (NoSuchStructureException nsse1) { Group group = GroupLocalServiceUtil.getCompanyGroup(article.getCompanyId()); try { structure = JournalStructureLocalServiceUtil.getStructure(group.getGroupId(), article.getStructureId()); } catch (NoSuchStructureException nsse2) { } } } processStructure(structure, document, article.getContent()); return document; }