use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class PortfolioCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext searchResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(searchResourceContext, courseNode, NODE_TYPE);
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(document);
PortfolioCourseNode portfolioNode = (PortfolioCourseNode) courseNode;
RepositoryEntry repoEntry = portfolioNode.getReferencedRepositoryEntry();
if (repoEntry != null) {
OLATResource ores = repoEntry.getOlatResource();
PortfolioStructure element = structureManager.loadPortfolioStructure(ores);
if (element != null) {
Document pDocument = PortfolioMapDocument.createDocument(courseNodeResourceContext, element);
indexWriter.addDocument(pDocument);
}
}
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class ProjectBrokerCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE);
Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(nodeDocument);
// go further, index my projects
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
Long projectBrokerId = projectBrokerManager.getProjectBrokerId(cpm, courseNode);
if (projectBrokerId != null) {
List<Project> projects = projectBrokerManager.getProjectListBy(projectBrokerId);
for (Project project : projects) {
Document document = ProjectBrokerProjectDocument.createDocument(courseNodeResourceContext, project);
indexWriter.addDocument(document);
}
} else {
log.debug("projectBrokerId is null, courseNode=" + courseNode + " , course=" + course);
}
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class SPCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext courseResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (log.isDebug())
log.debug("Index SinglePage...");
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(courseResourceContext, courseNode, TYPE);
Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(nodeDocument);
// The root of the configured single page. Depends on the configuration
// whether to follow relative links or not. When relative links are
// followed, the root is the course folder root, if not, it is folder
// where the configured file is in
VFSContainer rootContainer;
// The filename of the configured file relative to the rootContainer
String chosenFile;
// Read the course node configuration
VFSContainer courseFolderContainer = course.getCourseEnvironment().getCourseFolderContainer();
boolean allowRelativeLinks = courseNode.getModuleConfiguration().getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS);
String fileName = (String) courseNode.getModuleConfiguration().get(SPEditController.CONFIG_KEY_FILE);
// *** IF YOU CHANGE THIS LOGIC, do also change it in SinglePageController! ***
if (allowRelativeLinks) {
// Case 1: relative links are allowed. The root is the root of the
// course, the file name is relative to the root
rootContainer = courseFolderContainer;
chosenFile = fileName;
} else {
// Case 2: relative links are NOT allowed. We have to calculate the
// new root and remove the relative path to the course folder form
// the file.
String startURI = ((fileName.charAt(0) == '/') ? fileName.substring(1) : fileName);
int sla = startURI.lastIndexOf('/');
if (sla != -1) {
// Some subfolder path is detected, create basecontainer from it
String root = startURI.substring(0, sla);
startURI = startURI.substring(sla + 1);
// Create new root folder from the relative folder path
VFSContainer newroot = (VFSContainer) courseFolderContainer.resolve(root);
newroot.setParentContainer(null);
rootContainer = newroot;
} else {
// No subpath detected, just use course base container
rootContainer = courseFolderContainer;
}
chosenFile = startURI;
}
VFSLeaf leaf = (VFSLeaf) rootContainer.resolve(chosenFile);
if (leaf != null) {
String filePath = getPathFor(leaf);
// Use inherited method from LeafIndexer for the actual indexing of the content
SearchResourceContext fileContext = new SearchResourceContext(courseNodeResourceContext);
doIndexVFSLeafByMySelf(fileContext, leaf, indexWriter, filePath);
if (!indexOnlyChosenFile) {
if (log.isDebug())
log.debug("Index sub pages in SP.");
Set<String> alreadyIndexFileNames = new HashSet<String>();
alreadyIndexFileNames.add(chosenFile);
// Check if page has links to subpages and index those as well
indexSubPages(courseNodeResourceContext, rootContainer, indexWriter, leaf, alreadyIndexFileNames, 0, filePath);
} else if (log.isDebug()) {
log.debug("Index only chosen file in SP.");
}
} else if (log.isDebug()) {
log.debug("Can not found choosen file in SP => Nothing indexed.");
}
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
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;
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class DialogCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, null);
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(document);
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
DialogElementsManager dialogElmsMgr = CoreSpringFactory.getImpl(DialogElementsManager.class);
List<DialogElement> elements = dialogElmsMgr.getDialogElements(entry, courseNode.getIdent());
for (DialogElement element : elements) {
Forum forum = element.getForum();
doIndexAllMessages(courseNodeResourceContext, forum, indexWriter);
doIndexFile(element, courseNodeResourceContext, indexWriter);
}
}
Aggregations