protected BaseModelSearchResult<JournalArticle> searchJournalArticles( SearchContext searchContext) throws PortalException { Indexer<JournalArticle> indexer = IndexerRegistryUtil.nullSafeGetIndexer(JournalArticle.class); for (int i = 0; i < 10; i++) { Hits hits = indexer.search( searchContext, JournalUtil.SELECTED_FIELD_NAMES); List<JournalArticle> articles = _journalHelper.getArticles(hits); if (articles != null) { return new BaseModelSearchResult<>(articles, hits.getLength()); } } throw new SearchException( "Unable to fix the search index after 10 attempts"); }
protected static List<AssetEntryResult> getAssetEntryResultsByDefault( SearchContainer searchContainer, AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, long[] classNameIds, Map<String, Serializable> attributes) throws Exception { List<AssetEntryResult> assetEntryResults = new ArrayList<>(); int end = searchContainer.getEnd(); int start = searchContainer.getStart(); assetEntryQuery.setClassNameIds(classNameIds); BaseModelSearchResult<AssetEntry> baseModelSearchResult = getAssetEntries( assetEntryQuery, layout, portletPreferences, portletName, locale, timeZone, companyId, scopeGroupId, userId, attributes, start, end); int total = baseModelSearchResult.getLength(); searchContainer.setTotal(total); List<AssetEntry> assetEntries = baseModelSearchResult.getBaseModels(); if (!assetEntries.isEmpty() && (start < total)) { assetEntryResults.add(new AssetEntryResult(assetEntries)); } return assetEntryResults; }
private List<AssetEntry> _getAssetEntries( PortletPreferences portletPreferences, Layout layout) throws PortalException { AssetPublisherWebConfiguration assetPublisherWebConfiguration = _configurationProvider.getCompanyConfiguration( AssetPublisherWebConfiguration.class, layout.getCompanyId()); AssetEntryQuery assetEntryQuery = AssetPublisherUtil.getAssetEntryQuery( portletPreferences, layout.getGroupId(), layout, null, null); assetEntryQuery.setEnd( assetPublisherWebConfiguration.dynamicSubscriptionLimit()); assetEntryQuery.setStart(0); try { SearchContext searchContext = SearchContextFactory.getInstance( new long[0], new String[0], null, layout.getCompanyId(), StringPool.BLANK, layout, LocaleThreadLocal.getSiteDefaultLocale(), layout.getGroupId(), TimeZoneThreadLocal.getDefaultTimeZone(), 0); BaseModelSearchResult<AssetEntry> baseModelSearchResult = _assetHelper.searchAssetEntries( searchContext, assetEntryQuery, 0, assetPublisherWebConfiguration.dynamicSubscriptionLimit()); return baseModelSearchResult.getBaseModels(); } catch (Exception e) { return Collections.emptyList(); } }
assetEntryQuery.getStart(), assetEntryQuery.getEnd()); assetEntries = baseModelSearchResult.getBaseModels();
@Override public BaseModelSearchResult<DDMFormInstanceRecord> searchFormInstanceRecords(SearchContext searchContext) { try { Indexer<DDMFormInstanceRecord> indexer = getDDMFormInstanceRecordIndexer(); Hits hits = indexer.search(searchContext, _SELECTED_FIELD_NAMES); List<DDMFormInstanceRecord> formInstanceRecords = getFormInstanceRecords(hits); return new BaseModelSearchResult<>( formInstanceRecords, hits.getLength()); } catch (Exception e) { throw new SystemException(e); } }
private List<AssetEntryResult> _getAssetEntryResultsByDefault( SearchContainer searchContainer, AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, long[] classNameIds, Map<String, Serializable> attributes) throws Exception { List<AssetEntryResult> assetEntryResults = new ArrayList<>(); int end = searchContainer.getEnd(); int start = searchContainer.getStart(); assetEntryQuery.setClassNameIds(classNameIds); BaseModelSearchResult<AssetEntry> baseModelSearchResult = getAssetEntries( assetEntryQuery, layout, portletPreferences, portletName, locale, timeZone, companyId, scopeGroupId, userId, attributes, start, end); int total = baseModelSearchResult.getLength(); searchContainer.setTotal(total); List<AssetEntry> assetEntries = baseModelSearchResult.getBaseModels(); if (!assetEntries.isEmpty() && (start < total)) { assetEntryResults.add(new AssetEntryResult(assetEntries)); } return assetEntryResults; }
public static BaseModelSearchResult<AssetEntry> getAssetEntries( AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, Map<String, Serializable> attributes, int start, int end) throws Exception { if (isSearchWithIndex(portletName, assetEntryQuery)) { return _assetHelper.searchAssetEntries( assetEntryQuery, getAssetCategoryIds(portletPreferences), getAssetTagNames(portletPreferences), attributes, companyId, assetEntryQuery.getKeywords(), layout, locale, scopeGroupId, timeZone, userId, start, end); } int total = _assetEntryService.getEntriesCount(assetEntryQuery); assetEntryQuery.setEnd(end); assetEntryQuery.setStart(start); List<AssetEntry> results = _assetEntryService.getEntries( assetEntryQuery); return new BaseModelSearchResult<>(results, total); }
attributes, start, end); int groupTotal = baseModelSearchResult.getLength(); baseModelSearchResult.getBaseModels();
@Override public BaseModelSearchResult<AssetEntry> getAssetEntries( AssetEntryQuery assetEntryQuery, Layout layout, PortletPreferences portletPreferences, String portletName, Locale locale, TimeZone timeZone, long companyId, long scopeGroupId, long userId, Map<String, Serializable> attributes, int start, int end) throws Exception { if (_isSearchWithIndex(portletName, assetEntryQuery)) { return _assetHelper.searchAssetEntries( assetEntryQuery, getAssetCategoryIds(portletPreferences), getAssetTagNames(portletPreferences), attributes, companyId, assetEntryQuery.getKeywords(), layout, locale, scopeGroupId, timeZone, userId, start, end); } int total = _assetEntryService.getEntriesCount(assetEntryQuery); assetEntryQuery.setEnd(end); assetEntryQuery.setStart(start); List<AssetEntry> results = _assetEntryService.getEntries( assetEntryQuery); return new BaseModelSearchResult<>(results, total); }
attributes, start, end); int groupTotal = baseModelSearchResult.getLength(); baseModelSearchResult.getBaseModels();
attributes, start, end); int groupTotal = baseModelSearchResult.getLength(); baseModelSearchResult.getBaseModels();
attributes, start, end); int groupTotal = baseModelSearchResult.getLength(); baseModelSearchResult.getBaseModels();