Search in sources :

Example 91 with SearchResourceContext

use of org.olat.search.service.SearchResourceContext in project openolat by klemens.

the class WikiCourseNodeIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) {
    String repoEntryName = "*name not available*";
    try {
        SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE);
        Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
        indexWriter.addDocument(nodeDocument);
        RepositoryEntry repositoryEntry = courseNode.getReferencedRepositoryEntry();
        if (repositoryEntry == null)
            return;
        repoEntryName = repositoryEntry.getDisplayname();
        Wiki wiki = WikiManager.getInstance().getOrLoadWiki(repositoryEntry.getOlatResource());
        // loop over all wiki pages
        List<WikiPage> wikiPageList = wiki.getAllPagesWithContent();
        for (WikiPage wikiPage : wikiPageList) {
            try {
                courseNodeResourceContext.setFilePath(wikiPage.getPageName());
                Document document = WikiPageDocument.createDocument(courseNodeResourceContext, wikiPage);
                indexWriter.addDocument(document);
            } catch (Exception e) {
                log.error("Error indexing wiki page:" + (wikiPage == null ? "null" : wikiPage.getPageName()), e);
            }
        }
    } catch (Exception e) {
        log.error("Error indexing wiki:" + repoEntryName, e);
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) WikiPage(org.olat.modules.wiki.WikiPage) Wiki(org.olat.modules.wiki.Wiki) RepositoryEntry(org.olat.repository.RepositoryEntry) WikiPageDocument(org.olat.search.service.document.WikiPageDocument) Document(org.apache.lucene.document.Document) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument)

Example 92 with SearchResourceContext

use of org.olat.search.service.SearchResourceContext in project openolat by klemens.

the class DocumentPoolIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext parentResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
    String taxonomyTreeKey = documentPoolModule.getTaxonomyTreeKey();
    if (StringHelper.isLong(taxonomyTreeKey)) {
        Long taxonomyKey = new Long(taxonomyTreeKey);
        Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(taxonomyKey));
        OLATResourceable docPoolOres = OresHelper.createOLATResourceableInstanceWithoutCheck(getSupportedTypeName(), 0l);
        SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
        searchResourceContext.setBusinessControlFor(docPoolOres);
        searchResourceContext.setTitle(taxonomy.getDisplayName());
        searchResourceContext.setDescription(taxonomy.getDescription());
        searchResourceContext.setLastModified(taxonomy.getLastModified());
        searchResourceContext.setCreatedDate(taxonomy.getCreationDate());
        doIndexTaxonomyLibrary(searchResourceContext, taxonomy, indexerWriter);
    }
}
Also used : TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) Taxonomy(org.olat.modules.taxonomy.Taxonomy) OLATResourceable(org.olat.core.id.OLATResourceable) SearchResourceContext(org.olat.search.service.SearchResourceContext)

Aggregations

SearchResourceContext (org.olat.search.service.SearchResourceContext)92 Document (org.apache.lucene.document.Document)60 CourseNodeDocument (org.olat.search.service.document.CourseNodeDocument)32 RepositoryEntry (org.olat.repository.RepositoryEntry)26 IOException (java.io.IOException)18 VFSContainer (org.olat.core.util.vfs.VFSContainer)18 File (java.io.File)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 BusinessGroup (org.olat.group.BusinessGroup)12 AssertException (org.olat.core.logging.AssertException)10 OlatDocument (org.olat.search.model.OlatDocument)10 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)8 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)8 IndexWriter (org.apache.lucene.index.IndexWriter)6 Identity (org.olat.core.id.Identity)6 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 OLATResource (org.olat.resource.OLATResource)6 InfoMessageDocument (org.olat.search.service.document.InfoMessageDocument)6 PortfolioMapDocument (org.olat.search.service.document.PortfolioMapDocument)6