Search in sources :

Example 31 with SearchResourceContext

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

the class BCCourseNodeIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    if (isLogDebugEnabled())
        logDebug("Index Briefcase...");
    BCCourseNode bcNode = (BCCourseNode) courseNode;
    SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, bcNode, TYPE);
    Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, bcNode);
    indexWriter.addDocument(document);
    VFSContainer bcContainer = null;
    if (bcNode.getModuleConfiguration().getBooleanSafe(BCCourseNodeEditController.CONFIG_AUTO_FOLDER)) {
        bcContainer = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment());
    } else {
        String subpath = courseNode.getModuleConfiguration().getStringValue(BCCourseNodeEditController.CONFIG_SUBPATH);
        if (subpath != null) {
            VFSItem item = course.getCourseEnvironment().getCourseFolderContainer().resolve(subpath);
            if (item instanceof VFSContainer) {
                bcContainer = new NamedContainerImpl(courseNode.getShortTitle(), (VFSContainer) item);
            }
        }
    }
    if (bcContainer != null) {
        doIndexVFSContainer(courseNodeResourceContext, bcContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
    }
}
Also used : BCCourseNode(org.olat.course.nodes.BCCourseNode) SearchResourceContext(org.olat.search.service.SearchResourceContext) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Document(org.apache.lucene.document.Document) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl)

Example 32 with SearchResourceContext

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

the class CPCourseNodeIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE);
    Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
    indexWriter.addDocument(document);
    RepositoryEntry re = CPEditController.getCPReference(courseNode.getModuleConfiguration(), false);
    if (re != null) {
        File cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
        if (cpRoot != null) {
            VFSContainer rootContainer = new LocalFolderImpl(cpRoot);
            doIndexVFSContainer(courseNodeResourceContext, rootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
        }
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) Document(org.apache.lucene.document.Document) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 33 with SearchResourceContext

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

the class GroupFolderIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    if (!(businessObj instanceof BusinessGroup))
        throw new AssertException("businessObj must be BusinessGroup");
    BusinessGroup businessGroup = (BusinessGroup) businessObj;
    String path = collaborationManager.getFolderRelPath(businessGroup);
    OlatRootFolderImpl rootContainer = new OlatRootFolderImpl(path, null);
    SearchResourceContext forumSearchResourceContext = new SearchResourceContext(parentResourceContext);
    forumSearchResourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLFOLDER);
    forumSearchResourceContext.setDocumentType(TYPE);
    forumSearchResourceContext.setParentContextType(GroupDocument.TYPE);
    forumSearchResourceContext.setParentContextName(businessGroup.getName());
    doIndexVFSContainer(forumSearchResourceContext, rootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
}
Also used : AssertException(org.olat.core.logging.AssertException) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) BusinessGroup(org.olat.group.BusinessGroup) SearchResourceContext(org.olat.search.service.SearchResourceContext)

Example 34 with SearchResourceContext

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

the class GroupInfoIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext searchResourceContext, Object businessObject, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
    if (!(businessObject instanceof BusinessGroup))
        throw new AssertException("businessObject must be BusinessGroup");
    BusinessGroup businessGroup = (BusinessGroup) businessObject;
    try {
        SearchResourceContext messagesGroupResourceContext = new SearchResourceContext(searchResourceContext);
        messagesGroupResourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLMSG);
        messagesGroupResourceContext.setDocumentType(TYPE);
        doIndexInfos(messagesGroupResourceContext, businessGroup, indexerWriter);
    } catch (Exception ex) {
        log.error("Exception indexing businessGroup=" + businessGroup, ex);
    } catch (Error err) {
        log.error("Error indexing businessGroup=" + businessGroup, err);
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) SearchResourceContext(org.olat.search.service.SearchResourceContext) AssertException(org.olat.core.logging.AssertException) IOException(java.io.IOException)

Example 35 with SearchResourceContext

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

the class DialogCourseNodeIndexer method doIndexAllMessages.

private void doIndexAllMessages(SearchResourceContext parentResourceContext, Forum forum, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    // loop over all messages of a forum
    List<Message> messages = ForumManager.getInstance().getMessagesByForum(forum);
    for (Message message : messages) {
        SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
        searchResourceContext.setBusinessControlFor(message);
        searchResourceContext.setDocumentType(TYPE_MESSAGE);
        Document document = ForumMessageDocument.createDocument(searchResourceContext, message);
        indexWriter.addDocument(document);
    }
}
Also used : Message(org.olat.modules.fo.Message) SearchResourceContext(org.olat.search.service.SearchResourceContext) Document(org.apache.lucene.document.Document) ForumMessageDocument(org.olat.search.service.document.ForumMessageDocument) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument)

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