Search in sources :

Example 46 with SearchResourceContext

use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.

the class QuestionItemIndexer method indexDocument.

@Override
public void indexDocument(List<Long> keyList, LifeFullIndexer indexWriter) {
    QuestionItemDocumentFactory docFactory = CoreSpringFactory.getImpl(QuestionItemDocumentFactory.class);
    List<Document> docs = new ArrayList<>(keyList.size());
    for (Long key : keyList) {
        SearchResourceContext ctxt = new SearchResourceContext();
        Document doc = docFactory.createDocument(ctxt, key);
        docs.add(doc);
    }
    indexWriter.addDocuments(docs);
}
Also used : QuestionItemDocumentFactory(org.olat.modules.qpool.manager.QuestionItemDocumentFactory) SearchResourceContext(org.olat.search.service.SearchResourceContext) ArrayList(java.util.ArrayList) Document(org.apache.lucene.document.Document) QItemDocument(org.olat.modules.qpool.model.QItemDocument)

Example 47 with SearchResourceContext

use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.

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 48 with SearchResourceContext

use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.

the class GroupForumIndexer method doIndex.

/**
 * Index a forum in a group.
 * @param parentResourceContext
 * @param businessGroup
 * @param indexWriter
 * @throws IOException
 */
@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;
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(businessGroup);
    ForumManager fom = ForumManager.getInstance();
    Property forumKeyProperty = npm.findProperty(null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_FORUM);
    // Check if forum-property exist
    if (forumKeyProperty != null) {
        Long forumKey = forumKeyProperty.getLongValue();
        Forum forum = fom.loadForum(forumKey);
        SearchResourceContext forumSearchResourceContext = new SearchResourceContext(parentResourceContext);
        forumSearchResourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLFORUM);
        forumSearchResourceContext.setDocumentType(TYPE);
        forumSearchResourceContext.setParentContextType(GroupDocument.TYPE);
        forumSearchResourceContext.setParentContextName(businessGroup.getName());
        if (forum == null) {
            // fxdiff: FXOLAT-104 warn about missing forums
            logError("found a forum-key " + forumKey + " for businessgroup " + businessGroup.getName() + " [" + businessGroup.getKey() + "] to index a forum that could not be " + "found by key! skip indexing, check if forum should still be enabled. context: " + forumSearchResourceContext.getResourceUrl(), null);
            return;
        }
        doIndexAllMessages(forumSearchResourceContext, forum, indexWriter);
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) ForumManager(org.olat.modules.fo.manager.ForumManager) SearchResourceContext(org.olat.search.service.SearchResourceContext) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property) Forum(org.olat.modules.fo.Forum)

Example 49 with SearchResourceContext

use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.

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 50 with SearchResourceContext

use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.

the class GroupInfoIndexer method doIndexInfos.

private void doIndexInfos(SearchResourceContext parentResourceContext, BusinessGroup businessGroup, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    List<InfoMessage> messages = infoMessageManager.loadInfoMessageByResource(businessGroup, InfoMessageFrontendManager.businessGroupResSubPath, null, null, null, 0, -1);
    for (InfoMessage message : messages) {
        SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(InfoMessage.class, message.getKey());
        searchResourceContext.setBusinessControlFor(ores);
        Document document = InfoMessageDocument.createDocument(searchResourceContext, message);
        indexWriter.addDocument(document);
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) OLATResourceable(org.olat.core.id.OLATResourceable) InfoMessage(org.olat.commons.info.InfoMessage) Document(org.apache.lucene.document.Document) InfoMessageDocument(org.olat.search.service.document.InfoMessageDocument)

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