Search in sources :

Example 61 with SearchResourceContext

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

the class PortfolioArtefactIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext searchResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
    if (!portfolioModule.isEnabled())
        return;
    Identity identity = (Identity) object;
    // SearchResourceContext resourceContext = new SearchResourceContext(searchResourceContext); // dont do this way, as it would then try to open an artefact over visiting card -> not possible!
    SearchResourceContext resourceContext = new SearchResourceContext();
    resourceContext.setDocumentType(TYPE);
    resourceContext.setParentContextType(null);
    int currentPosition = 0;
    List<AbstractArtefact> artefacts;
    do {
        artefacts = frontendManager.getArtefacts(identity, currentPosition, MAX_RESULTS);
        for (AbstractArtefact artefact : artefacts) {
            OLATResourceable ores = OresHelper.createOLATResourceableInstance(AbstractArtefact.class.getSimpleName(), artefact.getKey());
            EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
            resourceContext.setBusinessControlFor(ores);
            OlatDocument doc = handler.getIndexerDocument(resourceContext, artefact, frontendManager);
            Identity author = artefact.getAuthor();
            if (author != null && author.getUser() != null) {
                doc.setReservedTo(author.getKey().toString());
            }
            if (doc != null) {
                indexerWriter.addDocument(doc.getLuceneDocument());
            }
        }
        currentPosition += artefacts.size();
    } while (artefacts.size() == MAX_RESULTS);
    super.doIndex(searchResourceContext, object, indexerWriter);
}
Also used : OlatDocument(org.olat.search.model.OlatDocument) SearchResourceContext(org.olat.search.service.SearchResourceContext) OLATResourceable(org.olat.core.id.OLATResourceable) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Identity(org.olat.core.id.Identity)

Example 62 with SearchResourceContext

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

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

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

the class ScormRepositoryIndexer method doIndex.

/**
 * @see org.olat.repository.handlers.RepositoryHandler#supportsDownload()
 */
public void doIndex(SearchResourceContext resourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    if (isLogDebugEnabled())
        logDebug("Index Scorm package...");
    RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
    OLATResource ores = repositoryEntry.getOlatResource();
    File cpRoot = FileResourceManager.getInstance().unzipFileResource(ores);
    resourceContext.setDocumentType(TYPE);
    SearchResourceContext scormContext = new SearchResourceContext(resourceContext);
    doIndex(scormContext, indexWriter, cpRoot);
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File)

Example 64 with SearchResourceContext

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

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

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

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