use of com.liferay.portal.kernel.search.Summary in project liferay-ide by liferay.
the class AlbumIndexer method doGetSummary.
@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletRequest portletRequest, PortletResponse portletResponse) throws Exception {
Summary summary = createSummary(document);
summary.setMaxContentLength(200);
return summary;
}
use of com.liferay.portal.kernel.search.Summary in project liferay-ide by liferay.
the class AlbumIndexer method doGetSummary.
@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) {
Summary summary = createSummary(document);
summary.setMaxContentLength(200);
return summary;
}
use of com.liferay.portal.kernel.search.Summary in project liferay-ide by liferay.
the class ArtistIndexer method doGetSummary.
@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) {
Summary summary = createSummary(document);
summary.setMaxContentLength(200);
String title = document.get(Field.TITLE);
String content = snippet;
if (Validator.isNull(snippet)) {
content = StringUtil.shorten(document.get("bio"), 200);
}
portletURL.setParameter("jspPage", "/html/artists/view_artist.jsp");
portletURL.setParameter("artistId", document.get(Field.CLASS_PK));
return new Summary(title, content, portletURL);
}
use of com.liferay.portal.kernel.search.Summary in project liferay-ide by liferay.
the class SongIndexer method doGetSummary.
@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) {
Summary summary = createSummary(document);
summary.setMaxContentLength(200);
return summary;
}
use of com.liferay.portal.kernel.search.Summary in project liferay-ide by liferay.
the class SearchResultTest method getSearchResults.
public static List<SearchResult> getSearchResults(Hits hits, Locale locale, PortletURL portletURL) {
List<SearchResult> searchResults = new ArrayList<SearchResult>();
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 {
String className = entryClassName;
long classPK = entryClassPK;
FileEntry fileEntry = null;
MBMessage mbMessage = null;
if (entryClassName.equals(DLFileEntry.class.getName()) || entryClassName.equals(MBMessage.class.getName())) {
classPK = GetterUtil.getLong(document.get(Field.CLASS_PK));
long classNameId = GetterUtil.getLong(document.get(Field.CLASS_NAME_ID));
if ((classPK > 0) && (classNameId > 0)) {
className = PortalUtil.getClassName(classNameId);
if (entryClassName.equals(DLFileEntry.class.getName())) {
fileEntry = DLAppLocalServiceUtil.getFileEntry(entryClassPK);
} else if (entryClassName.equals(MBMessage.class.getName())) {
mbMessage = MBMessageLocalServiceUtil.getMessage(entryClassPK);
}
} else {
className = entryClassName;
classPK = entryClassPK;
}
}
SearchResult searchResult = new SearchResult(className, classPK);
int index = searchResults.indexOf(searchResult);
if (index < 0) {
searchResults.add(searchResult);
} else {
searchResult = searchResults.get(index);
}
if (fileEntry != null) {
Summary summary = getSummary(document, DLFileEntry.class.getName(), fileEntry.getFileEntryId(), locale, portletURL);
searchResult.addFileEntry(fileEntry, summary);
}
if (mbMessage != null) {
searchResult.addMBMessage(mbMessage);
searchResult.getMBMessages();
searchResult.getFileEntryTuples();
}
if (entryClassName.equals(JournalArticle.class.getName())) {
String version = document.get(Field.VERSION);
searchResult.addVersion(version);
}
if ((mbMessage == null) && (fileEntry == null)) {
Summary summary = getSummary(document, className, classPK, locale, portletURL);
searchResult.setSummary(summary);
} else {
if (searchResult.getSummary() == null) {
Summary summary = getSummary(className, classPK, locale, portletURL);
searchResult.setSummary(summary);
}
}
} catch (Exception e) {
if (_log.isWarnEnabled()) {
_log.warn("Search index is stale and contains entry {" + entryClassPK + "}");
}
}
}
return searchResults;
}
Aggregations