Search in sources :

Example 76 with SearchResourceContext

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

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)

Example 77 with SearchResourceContext

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

the class GroupPortfolioIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
    if (!portfolioModule.isEnabled())
        return;
    if (!(businessObj instanceof BusinessGroup))
        throw new AssertException("businessObj must be BusinessGroup");
    BusinessGroup businessGroup = (BusinessGroup) businessObj;
    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(businessGroup);
    Property mapKeyProperty = npm.findProperty(null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_PORTFOLIO);
    // Check if portfolio map property exist
    if (mapKeyProperty != null) {
        Long mapKey = mapKeyProperty.getLongValue();
        String version = mapKeyProperty.getStringValue();
        if (version == null || !version.equals("2")) {
            PortfolioStructure map = frontendManager.loadPortfolioStructureByKey(mapKey);
            if (map != null) {
                SearchResourceContext resourceContext = new SearchResourceContext(parentResourceContext);
                resourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLPORTFOLIO);
                resourceContext.setDocumentType(TYPE);
                resourceContext.setParentContextType(GroupDocument.TYPE);
                resourceContext.setParentContextName(businessGroup.getName());
                Document document = PortfolioMapDocument.createDocument(resourceContext, map);
                indexerWriter.addDocument(document);
            }
        }
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) SearchResourceContext(org.olat.search.service.SearchResourceContext) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) PortfolioMapDocument(org.olat.search.service.document.PortfolioMapDocument) Document(org.apache.lucene.document.Document) GroupDocument(org.olat.search.service.document.GroupDocument) Property(org.olat.properties.Property)

Example 78 with SearchResourceContext

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

the class PublicFolderIndexer method doIndex.

/**
 * @see org.olat.repository.handlers.RepositoryHandler#supportsDownload()
 */
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object parentObject, OlatFullIndexer indexWriter) {
    try {
        // get public folder for user
        Identity identity = (Identity) parentObject;
        OlatRootFolderImpl rootContainer = new OlatRootFolderImpl(FolderConfig.getUserHome(identity.getName()) + "/public", null);
        if (!rootContainer.getBasefile().exists())
            return;
        // build new resource context
        SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
        searchResourceContext.setParentContextName(identity.getName());
        searchResourceContext.setBusinessControlFor(BUSINESS_CONTROL_TYPE);
        searchResourceContext.setDocumentType(TYPE);
        // now index the folder
        doIndexVFSContainer(searchResourceContext, rootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
    } catch (Exception ex) {
        logWarn("Exception while indexing public folder of identity::" + parentObject.toString() + ". Skipping this user, try next one.", ex);
    }
    if (isLogDebugEnabled())
        logDebug("PublicFolder finished for user::" + parentObject.toString());
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) SearchResourceContext(org.olat.search.service.SearchResourceContext) Identity(org.olat.core.id.Identity)

Example 79 with SearchResourceContext

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

the class InfoCourseNodeIndexer method doIndexInfos.

private void doIndexInfos(SearchResourceContext parentResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    List<InfoMessage> messages = infoMessageManager.loadInfoMessageByResource(course, courseNode.getIdent(), 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) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument)

Example 80 with SearchResourceContext

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

the class InfoCourseNodeIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) {
    try {
        SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE);
        Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
        indexWriter.addDocument(document);
        doIndexInfos(courseNodeResourceContext, course, courseNode, indexWriter);
    } catch (Exception ex) {
        log.error("Exception indexing courseNode=" + courseNode, ex);
    } catch (Error err) {
        log.error("Error indexing courseNode=" + courseNode, err);
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) Document(org.apache.lucene.document.Document) InfoMessageDocument(org.olat.search.service.document.InfoMessageDocument) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument) IOException(java.io.IOException)

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