Search in sources :

Example 6 with Document

use of com.liferay.portal.kernel.search.Document in project liferay-ide by liferay.

the class SongIndexer method doGetDocument.

@Override
protected Document doGetDocument(Object obj) throws Exception {
    Song song = (Song) obj;
    Document document = getBaseModelDocument(PORTLET_ID, song);
    document.addDate(Field.MODIFIED_DATE, song.getModifiedDate());
    document.addText(Field.TITLE, song.getName());
    Album album = AlbumLocalServiceUtil.getAlbum(song.getAlbumId());
    document.addText("album", album.getName());
    document.addKeyword("albumId", album.getAlbumId());
    Artist artist = ArtistLocalServiceUtil.getArtist(song.getArtistId());
    document.addText("artist", artist.getName());
    document.addKeyword("artistId", artist.getArtistId());
    return document;
}
Also used : Artist(org.liferay.jukebox.model.Artist) Song(org.liferay.jukebox.model.Song) Album(org.liferay.jukebox.model.Album) Document(com.liferay.portal.kernel.search.Document)

Example 7 with Document

use of com.liferay.portal.kernel.search.Document in project liferay-ide by liferay.

the class AdminIndexer method doGetDocument.

@Override
protected Document doGetDocument(Object obj) throws Exception {
    KBArticle kbArticle = (KBArticle) obj;
    Document document = getBaseModelDocument(PORTLET_ID, kbArticle);
    document.addText(Field.CONTENT, HtmlUtil.extractText(kbArticle.getContent()));
    document.addText(Field.DESCRIPTION, kbArticle.getDescription());
    document.addText(Field.TITLE, kbArticle.getTitle());
    document.addKeyword("titleKeyword", kbArticle.getTitle(), true);
    return document;
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) Document(com.liferay.portal.kernel.search.Document)

Example 8 with Document

use of com.liferay.portal.kernel.search.Document in project liferay-ide by liferay.

the class AdminIndexer method reindexKBArticles.

protected void reindexKBArticles(KBArticle kbArticle) throws Exception {
    // See KBArticlePermission#contains
    List<KBArticle> kbArticles = KBArticleLocalServiceUtil.getKBArticleAndAllDescendantKBArticles(kbArticle.getResourcePrimKey(), WorkflowConstants.STATUS_APPROVED, null);
    Collection<Document> documents = new ArrayList<Document>();
    for (KBArticle curKBArticle : kbArticles) {
        documents.add(getDocument(curKBArticle));
    }
    SearchEngineUtil.updateDocuments(getSearchEngineId(), kbArticle.getCompanyId(), documents);
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) ArrayList(java.util.ArrayList) Document(com.liferay.portal.kernel.search.Document)

Example 9 with Document

use of com.liferay.portal.kernel.search.Document in project liferay-ide by liferay.

the class AdminIndexer method reindexKBArticles.

protected void reindexKBArticles(long companyId) throws Exception {
    ActionableDynamicQuery actionableDynamicQuery = new KBArticleActionableDynamicQuery() {

        @Override
        protected void addCriteria(DynamicQuery dynamicQuery) {
            Property property = PropertyFactoryUtil.forName("status");
            dynamicQuery.add(property.eq(WorkflowConstants.STATUS_APPROVED));
        }

        @Override
        protected void performAction(Object object) throws PortalException {
            KBArticle kbArticle = (KBArticle) object;
            Document document = getDocument(kbArticle);
            addDocument(document);
        }
    };
    actionableDynamicQuery.setCompanyId(companyId);
    actionableDynamicQuery.setSearchEngineId(getSearchEngineId());
    actionableDynamicQuery.performActions();
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) KBArticleActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) KBArticleActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery) Document(com.liferay.portal.kernel.search.Document) Property(com.liferay.portal.kernel.dao.orm.Property) KBArticleActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)

Example 10 with Document

use of com.liferay.portal.kernel.search.Document in project liferay-ide by liferay.

the class AlbumIndexer method reindexEntries.

protected void reindexEntries(long companyId) throws PortalException {
    final Collection<Document> documents = new ArrayList<Document>();
    ActionableDynamicQuery actionableDynamicQuery = AlbumLocalServiceUtil.getActionableDynamicQuery();
    actionableDynamicQuery.setCompanyId(companyId);
    actionableDynamicQuery.performActions();
    SearchEngineUtil.updateDocuments(getSearchEngineId(), companyId, documents);
}
Also used : ArrayList(java.util.ArrayList) Document(com.liferay.portal.kernel.search.Document) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)

Aggregations

Document (com.liferay.portal.kernel.search.Document)13 ArrayList (java.util.ArrayList)5 Artist (org.liferay.jukebox.model.Artist)5 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)4 KBArticle (com.liferay.knowledgebase.model.KBArticle)3 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)3 Album (org.liferay.jukebox.model.Album)3 Song (org.liferay.jukebox.model.Song)3 KBArticleActionableDynamicQuery (com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery)1 Property (com.liferay.portal.kernel.dao.orm.Property)1 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)1 SearchResult (com.liferay.portal.kernel.search.SearchResult)1 Summary (com.liferay.portal.kernel.search.Summary)1 DLFileEntry (com.liferay.portlet.documentlibrary.model.DLFileEntry)1 JournalArticle (com.liferay.portlet.journal.model.JournalArticle)1 MBMessage (com.liferay.portlet.messageboards.model.MBMessage)1 ArtistActionableDynamicQuery (org.liferay.jukebox.service.persistence.ArtistActionableDynamicQuery)1 SongActionableDynamicQuery (org.liferay.jukebox.service.persistence.SongActionableDynamicQuery)1