use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class ForumIndexer method doIndexAllMessages.
public void doIndexAllMessages(SearchResourceContext parentResourceContext, Forum forum, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (forum == null) {
logWarn("tried to index a forum that could not be found! skipping. context: " + parentResourceContext.getResourceUrl(), null);
return;
}
// 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);
Document document = ForumMessageDocument.createDocument(searchResourceContext, message);
indexWriter.addDocument(document);
}
}
use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class AbstractPortfolioMapIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
SearchResourceContext resourceContext = new SearchResourceContext();
int firstResult = 0;
List<PortfolioStructure> structures = null;
do {
structures = frontendManager.getStructureElements(firstResult, 500, getElementType());
for (PortfolioStructure structure : structures) {
if (structure instanceof PortfolioStructureMap) {
PortfolioStructureMap map = (PortfolioStructureMap) structure;
if (accept(map)) {
resourceContext.setDocumentType(getDocumentType());
resourceContext.setBusinessControlFor(map.getOlatResource());
Document document = PortfolioMapDocument.createDocument(resourceContext, map);
indexerWriter.addDocument(document);
}
}
}
firstResult += structures.size();
} while (structures != null && structures.size() == BATCH_SIZE);
}
use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
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);
}
}
use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class TACourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, null);
Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(nodeDocument);
// Index Task
File fTaskfolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFolderPathRelToFolderRoot(course.getCourseEnvironment(), courseNode));
VFSContainer taskRootContainer = new LocalFolderImpl(fTaskfolder);
courseNodeResourceContext.setDocumentType(TYPE_TASK);
doIndexVFSContainer(courseNodeResourceContext, taskRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
// Index Dropbox
String dropboxFilePath = FolderConfig.getCanonicalRoot() + DropboxController.getDropboxPathRelToFolderRoot(course.getCourseEnvironment(), courseNode);
File fDropboxFolder = new File(dropboxFilePath);
VFSContainer dropboxRootContainer = new LocalFolderImpl(fDropboxFolder);
courseNodeResourceContext.setDocumentType(TYPE_DROPBOX);
doIndexVFSContainer(courseNodeResourceContext, dropboxRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
// Index Returnbox
String returnboxFilePath = FolderConfig.getCanonicalRoot() + ReturnboxController.getReturnboxPathRelToFolderRoot(course.getCourseEnvironment(), courseNode);
File fResturnboxFolder = new File(returnboxFilePath);
VFSContainer returnboxRootContainer = new LocalFolderImpl(fResturnboxFolder);
courseNodeResourceContext.setDocumentType(TYPE_RETURNBOX);
doIndexVFSContainer(courseNodeResourceContext, returnboxRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
// Index Solutionbox
String solutionFilePath = FolderConfig.getCanonicalRoot() + SolutionController.getSolutionPathRelToFolderRoot(course.getCourseEnvironment(), courseNode);
File fSolutionFolder = new File(solutionFilePath);
VFSContainer solutionRootContainer = new LocalFolderImpl(fSolutionFolder);
courseNodeResourceContext.setDocumentType(TYPE_SOLUTIONBOX);
doIndexVFSContainer(courseNodeResourceContext, solutionRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
}
use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class CourseNodeIndexer method createSearchResourceContext.
public default SearchResourceContext createSearchResourceContext(SearchResourceContext courseResourceContext, CourseNode node, String type) {
SearchResourceContext courseNodeResourceContext = new SearchResourceContext(courseResourceContext);
courseNodeResourceContext.setBusinessControlFor(node);
courseNodeResourceContext.setDocumentType(type);
if (StringHelper.containsNonWhitespace(node.getShortTitle())) {
courseNodeResourceContext.setTitle(node.getShortTitle());
} else if (StringHelper.containsNonWhitespace(node.getLongTitle())) {
courseNodeResourceContext.setTitle(node.getLongTitle());
}
return courseNodeResourceContext;
}
Aggregations