List of usage examples for com.liferay.portal.kernel.search Field ASSET_CATEGORY_IDS
String ASSET_CATEGORY_IDS
To view the source code for com.liferay.portal.kernel.search Field ASSET_CATEGORY_IDS.
Click Source Link
From source file:com.inkwell.internet.slogan.search.SloganIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { Slogan slogan = (Slogan) obj;/* www. j a v a2 s . c om*/ long companyId = slogan.getCompanyId(); long groupId = getParentGroupId(slogan.getGroupId()); long scopeGroupId = slogan.getGroupId(); long userId = slogan.getUserId(); long resourcePrimKey = slogan.getPrimaryKey(); String title = slogan.getSloganText(); String content = slogan.getSloganText(); String description = slogan.getSloganText(); Date modifiedDate = slogan.getSloganDate(); long[] assetCategoryIds = AssetCategoryLocalServiceUtil.getCategoryIds(Slogan.class.getName(), resourcePrimKey); List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getCategories(Slogan.class.getName(), resourcePrimKey); String[] assetCategoryNames = StringUtil.split(ListUtil.toString(categories, "name")); // EE lets you do this quicker: // String[] assetCategoryNames = // AssetCategoryLocalServiceUtil.getCategoryNames( // Slogan.class.getName(), resourcePrimKey); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(Slogan.class.getName(), resourcePrimKey); Document document = new DocumentImpl(); document.addUID(PORTLET_ID, resourcePrimKey); document.addModifiedDate(modifiedDate); document.addKeyword(Field.COMPANY_ID, companyId); document.addKeyword(Field.PORTLET_ID, PORTLET_ID); document.addKeyword(Field.GROUP_ID, groupId); document.addKeyword(Field.SCOPE_GROUP_ID, scopeGroupId); document.addKeyword(Field.USER_ID, userId); document.addText(Field.TITLE, title); document.addText(Field.CONTENT, content); document.addText(Field.DESCRIPTION, description); document.addKeyword(Field.ASSET_CATEGORY_IDS, assetCategoryIds); document.addKeyword("assetCategoryNames", assetCategoryNames); //document.addKeyword(Field.ASSET_CATEGORY_NAMES, assetCategoryNames); document.addKeyword(Field.ASSET_TAG_NAMES, assetTagNames); document.addKeyword(Field.ENTRY_CLASS_NAME, Slogan.class.getName()); document.addKeyword(Field.ENTRY_CLASS_PK, resourcePrimKey); return document; }
From source file:com.liferay.portlet.documentlibrary.util.DLIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { DLFileEntry dlFileEntry = (DLFileEntry) obj; if (_log.isDebugEnabled()) { _log.debug("Indexing document " + dlFileEntry); }//from w w w. j ava2s. c o m boolean indexContent = true; InputStream is = null; try { if (PropsValues.DL_FILE_INDEXING_MAX_SIZE == 0) { indexContent = false; } else if (PropsValues.DL_FILE_INDEXING_MAX_SIZE != -1) { if (dlFileEntry.getSize() > PropsValues.DL_FILE_INDEXING_MAX_SIZE) { indexContent = false; } } if (indexContent) { String[] ignoreExtensions = PrefsPropsUtil .getStringArray(PropsKeys.DL_FILE_INDEXING_IGNORE_EXTENSIONS, StringPool.COMMA); if (ArrayUtil.contains(ignoreExtensions, StringPool.PERIOD + dlFileEntry.getExtension())) { indexContent = false; } } if (indexContent) { is = dlFileEntry.getFileVersion().getContentStream(false); } } catch (Exception e) { } if (indexContent && (is == null)) { if (_log.isDebugEnabled()) { _log.debug("Document " + dlFileEntry + " does not have any content"); } return null; } try { Document document = new DocumentImpl(); long fileEntryId = dlFileEntry.getFileEntryId(); document.addUID(PORTLET_ID, fileEntryId); List<AssetCategory> assetCategories = AssetCategoryLocalServiceUtil .getCategories(DLFileEntry.class.getName(), fileEntryId); long[] assetCategoryIds = StringUtil .split(ListUtil.toString(assetCategories, AssetCategory.CATEGORY_ID_ACCESSOR), 0L); document.addKeyword(Field.ASSET_CATEGORY_IDS, assetCategoryIds); String[] assetCategoryNames = StringUtil .split(ListUtil.toString(assetCategories, AssetCategory.NAME_ACCESSOR)); document.addKeyword(Field.ASSET_CATEGORY_NAMES, assetCategoryNames); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(DLFileEntry.class.getName(), fileEntryId); document.addKeyword(Field.ASSET_TAG_NAMES, assetTagNames); document.addKeyword(Field.COMPANY_ID, dlFileEntry.getCompanyId()); if (indexContent) { try { document.addFile(Field.CONTENT, is, dlFileEntry.getTitle()); } catch (IOException ioe) { throw new SearchException("Cannot extract text from file" + dlFileEntry); } } document.addText(Field.DESCRIPTION, dlFileEntry.getDescription()); document.addKeyword(Field.ENTRY_CLASS_NAME, DLFileEntry.class.getName()); document.addKeyword(Field.ENTRY_CLASS_PK, fileEntryId); document.addKeyword(Field.FOLDER_ID, dlFileEntry.getFolderId()); document.addKeyword(Field.GROUP_ID, getParentGroupId(dlFileEntry.getGroupId())); document.addDate(Field.MODIFIED_DATE, dlFileEntry.getModifiedDate()); document.addKeyword(Field.PORTLET_ID, PORTLET_ID); document.addText(Field.PROPERTIES, dlFileEntry.getLuceneProperties()); document.addKeyword(Field.SCOPE_GROUP_ID, dlFileEntry.getGroupId()); DLFileVersion dlFileVersion = dlFileEntry.getFileVersion(); document.addKeyword(Field.STATUS, dlFileVersion.getStatus()); document.addText(Field.TITLE, dlFileEntry.getTitle()); long userId = dlFileEntry.getUserId(); document.addKeyword(Field.USER_ID, userId); document.addKeyword(Field.USER_NAME, PortalUtil.getUserName(userId, dlFileEntry.getUserName()), true); document.addKeyword("dataRepositoryId", dlFileEntry.getDataRepositoryId()); document.addKeyword("extension", dlFileEntry.getExtension()); document.addKeyword("fileEntryTypeId", dlFileEntry.getFileEntryTypeId()); document.addKeyword("path", dlFileEntry.getTitle()); ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(dlFileEntry.getCompanyId(), DLFileEntry.class.getName(), dlFileVersion.getFileVersionId()); ExpandoBridgeIndexerUtil.addAttributes(document, expandoBridge); addFileEntryTypeAttributes(document, dlFileVersion); if (_log.isDebugEnabled()) { _log.debug("Document " + dlFileEntry + " indexed successfully"); } return document; } finally { if (is != null) { try { is.close(); } catch (IOException ioe) { } } } }