Search in sources :

Example 1 with FeedItemDocument

use of org.olat.modules.webFeed.search.document.FeedItemDocument in project openolat by klemens.

the class LiveBlogArtefactHandler method getContent.

@Override
protected void getContent(AbstractArtefact artefact, StringBuilder sb, SearchResourceContext context, EPFrontendManager ePFManager) {
    String businessPath = artefact.getBusinessPath();
    if (StringHelper.containsNonWhitespace(businessPath)) {
        manager = FeedManager.getInstance();
        String oresId = businessPath.substring(LIVEBLOG.length(), businessPath.length() - 1);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(BlogFileResource.TYPE_NAME, Long.parseLong(oresId));
        Feed feed = manager.loadFeed(ores);
        List<Item> publishedItems = manager.loadPublishedItems(feed);
        for (Item item : publishedItems) {
            OlatDocument itemDoc = new FeedItemDocument(item, context);
            String content = itemDoc.getContent();
            sb.append(content);
        }
    }
}
Also used : Item(org.olat.modules.webFeed.Item) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) OLATResourceable(org.olat.core.id.OLATResourceable) Feed(org.olat.modules.webFeed.Feed)

Example 2 with FeedItemDocument

use of org.olat.modules.webFeed.search.document.FeedItemDocument in project openolat by klemens.

the class FeedCourseNodeIndexer method doIndex.

/**
 * @see org.olat.search.service.indexer.Indexer#doIndex(org.olat.search.service.SearchResourceContext,
 *      java.lang.Object, org.olat.search.service.indexer.OlatFullIndexer)
 */
@Override
public void doIndex(SearchResourceContext courseResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexer) throws IOException, InterruptedException {
    SearchResourceContext courseNodeResourceContext = createSearchResourceContext(courseResourceContext, courseNode, getDocumentType());
    Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
    indexer.addDocument(document);
    RepositoryEntry repositoryEntry = courseNode.getReferencedRepositoryEntry();
    if (repositoryEntry != null) {
        // used for log messages
        String repoEntryName = "*name not available*";
        try {
            repoEntryName = repositoryEntry.getDisplayname();
            if (log.isDebug()) {
                log.info("Indexing: " + repoEntryName);
            }
            Feed feed = FeedManager.getInstance().loadFeed(repositoryEntry.getOlatResource());
            List<Item> publishedItems = FeedManager.getInstance().loadPublishedItems(feed);
            // Create the olatDocument for the feed course node itself
            OlatDocument feedNodeDoc = new FeedNodeDocument(feed, courseNodeResourceContext);
            indexer.addDocument(feedNodeDoc.getLuceneDocument());
            // Only index items. FeedImpl itself is indexed by RepositoryEntryIndexer.
            for (Item item : publishedItems) {
                OlatDocument itemDoc = new FeedItemDocument(item, courseNodeResourceContext);
                indexer.addDocument(itemDoc.getLuceneDocument());
            }
        } catch (NullPointerException e) {
            log.error("Error indexing feed:" + repoEntryName, e);
        }
    }
}
Also used : Item(org.olat.modules.webFeed.Item) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) SearchResourceContext(org.olat.search.service.SearchResourceContext) FeedNodeDocument(org.olat.modules.webFeed.search.document.FeedNodeDocument) RepositoryEntry(org.olat.repository.RepositoryEntry) FeedNodeDocument(org.olat.modules.webFeed.search.document.FeedNodeDocument) Document(org.apache.lucene.document.Document) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument) Feed(org.olat.modules.webFeed.Feed)

Example 3 with FeedItemDocument

use of org.olat.modules.webFeed.search.document.FeedItemDocument in project openolat by klemens.

the class FeedRepositoryIndexer method doIndex.

/**
 * @see org.olat.search.service.indexer.Indexer#doIndex(org.olat.search.service.SearchResourceContext,
 *      java.lang.Object, org.olat.search.service.indexer.OlatFullIndexer)
 */
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object parentObject, OlatFullIndexer indexer) throws IOException, InterruptedException {
    RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
    // used for log messages
    String repoEntryName = "*name not available*";
    try {
        repoEntryName = repositoryEntry.getDisplayname();
        if (isLogDebugEnabled()) {
            logDebug("Indexing: " + repoEntryName);
        }
        Feed feed = FeedManager.getInstance().loadFeed(repositoryEntry.getOlatResource());
        if (feed != null) {
            // Only index items. Feed itself is indexed by RepositoryEntryIndexer.
            List<Item> publishedItems = FeedManager.getInstance().loadPublishedItems(feed);
            if (isLogDebugEnabled()) {
                logDebug("PublishedItems size=" + publishedItems.size());
            }
            for (Item item : publishedItems) {
                SearchResourceContext feedContext = new SearchResourceContext(searchResourceContext);
                feedContext.setDocumentType(getDocumentType());
                OlatDocument itemDoc = new FeedItemDocument(item, feedContext);
                indexer.addDocument(itemDoc.getLuceneDocument());
            }
        }
    } catch (NullPointerException e) {
        logError("Error indexing feed:" + repoEntryName, e);
    }
}
Also used : Item(org.olat.modules.webFeed.Item) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) SearchResourceContext(org.olat.search.service.SearchResourceContext) RepositoryEntry(org.olat.repository.RepositoryEntry) Feed(org.olat.modules.webFeed.Feed)

Example 4 with FeedItemDocument

use of org.olat.modules.webFeed.search.document.FeedItemDocument in project OpenOLAT by OpenOLAT.

the class LiveBlogArtefactHandler method getContent.

@Override
protected void getContent(AbstractArtefact artefact, StringBuilder sb, SearchResourceContext context, EPFrontendManager ePFManager) {
    String businessPath = artefact.getBusinessPath();
    if (StringHelper.containsNonWhitespace(businessPath)) {
        manager = FeedManager.getInstance();
        String oresId = businessPath.substring(LIVEBLOG.length(), businessPath.length() - 1);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(BlogFileResource.TYPE_NAME, Long.parseLong(oresId));
        Feed feed = manager.loadFeed(ores);
        List<Item> publishedItems = manager.loadPublishedItems(feed);
        for (Item item : publishedItems) {
            OlatDocument itemDoc = new FeedItemDocument(item, context);
            String content = itemDoc.getContent();
            sb.append(content);
        }
    }
}
Also used : Item(org.olat.modules.webFeed.Item) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) OLATResourceable(org.olat.core.id.OLATResourceable) Feed(org.olat.modules.webFeed.Feed)

Example 5 with FeedItemDocument

use of org.olat.modules.webFeed.search.document.FeedItemDocument in project OpenOLAT by OpenOLAT.

the class FeedRepositoryIndexer method doIndex.

/**
 * @see org.olat.search.service.indexer.Indexer#doIndex(org.olat.search.service.SearchResourceContext,
 *      java.lang.Object, org.olat.search.service.indexer.OlatFullIndexer)
 */
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object parentObject, OlatFullIndexer indexer) throws IOException, InterruptedException {
    RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
    // used for log messages
    String repoEntryName = "*name not available*";
    try {
        repoEntryName = repositoryEntry.getDisplayname();
        if (isLogDebugEnabled()) {
            logDebug("Indexing: " + repoEntryName);
        }
        Feed feed = FeedManager.getInstance().loadFeed(repositoryEntry.getOlatResource());
        if (feed != null) {
            // Only index items. Feed itself is indexed by RepositoryEntryIndexer.
            List<Item> publishedItems = FeedManager.getInstance().loadPublishedItems(feed);
            if (isLogDebugEnabled()) {
                logDebug("PublishedItems size=" + publishedItems.size());
            }
            for (Item item : publishedItems) {
                SearchResourceContext feedContext = new SearchResourceContext(searchResourceContext);
                feedContext.setDocumentType(getDocumentType());
                OlatDocument itemDoc = new FeedItemDocument(item, feedContext);
                indexer.addDocument(itemDoc.getLuceneDocument());
            }
        }
    } catch (NullPointerException e) {
        logError("Error indexing feed:" + repoEntryName, e);
    }
}
Also used : Item(org.olat.modules.webFeed.Item) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) SearchResourceContext(org.olat.search.service.SearchResourceContext) RepositoryEntry(org.olat.repository.RepositoryEntry) Feed(org.olat.modules.webFeed.Feed)

Aggregations

Feed (org.olat.modules.webFeed.Feed)6 Item (org.olat.modules.webFeed.Item)6 FeedItemDocument (org.olat.modules.webFeed.search.document.FeedItemDocument)6 OlatDocument (org.olat.search.model.OlatDocument)6 RepositoryEntry (org.olat.repository.RepositoryEntry)4 SearchResourceContext (org.olat.search.service.SearchResourceContext)4 Document (org.apache.lucene.document.Document)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 FeedNodeDocument (org.olat.modules.webFeed.search.document.FeedNodeDocument)2 CourseNodeDocument (org.olat.search.service.document.CourseNodeDocument)2