Search in sources :

Example 6 with WikiPage

use of org.olat.modules.wiki.WikiPage in project OpenOLAT by OpenOLAT.

the class WikiArtefactHandler method prefillArtefactAccordingToSource.

/**
 * @see org.olat.portfolio.EPAbstractHandler#prefillArtefactAccordingToSource(org.olat.portfolio.model.artefacts.AbstractArtefact, java.lang.Object)
 */
@Override
public void prefillArtefactAccordingToSource(AbstractArtefact artefact, Object source) {
    super.prefillArtefactAccordingToSource(artefact, source);
    WikiPage page = null;
    OLATResourceable ores = null;
    if (source instanceof OLATResourceable) {
        ores = (OLATResourceable) source;
        // fxdiff: FXOLAT-148 a wiki from a businessgroup needs to be wrapped accordingly!
        if (artefact.getBusinessPath().contains(BusinessGroup.class.getSimpleName())) {
            ores = OresHelper.createOLATResourceableInstance(BusinessGroup.class, ores.getResourceableId());
        }
        Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
        String pageName = getPageName(artefact.getBusinessPath());
        page = wiki.getPage(pageName, true);
    } else if (source instanceof WikiPage) {
        page = (WikiPage) source;
    }
    if (page != null) {
        artefact.setSource(getSourceInfo(artefact.getBusinessPath(), ores));
        artefact.setTitle(page.getPageName());
        artefact.setFulltextContent(page.getContent());
        artefact.setSignature(70);
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) BusinessGroup(org.olat.group.BusinessGroup) WikiPage(org.olat.modules.wiki.WikiPage) Wiki(org.olat.modules.wiki.Wiki)

Example 7 with WikiPage

use of org.olat.modules.wiki.WikiPage in project OpenOLAT by OpenOLAT.

the class WikiMediaHandler method getInformations.

@Override
public MediaInformations getInformations(Object mediaObject) {
    String title = null;
    if (mediaObject instanceof WikiPage) {
        WikiPage page = (WikiPage) mediaObject;
        title = page.getPageName();
    }
    return new Informations(title, null);
}
Also used : MediaInformations(org.olat.modules.portfolio.MediaInformations) WikiPage(org.olat.modules.wiki.WikiPage)

Example 8 with WikiPage

use of org.olat.modules.wiki.WikiPage in project OpenOLAT by OpenOLAT.

the class WikiMediaHandler method createMedia.

@Override
public Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {
    String content = null;
    if (mediaObject instanceof WikiPage) {
        WikiPage page = (WikiPage) mediaObject;
        content = page.getContent();
    }
    Media media = mediaDao.createMedia(title, description, content, WIKI_HANDLER, businessPath, null, 70, author);
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
    return media;
}
Also used : WikiPage(org.olat.modules.wiki.WikiPage) Media(org.olat.modules.portfolio.Media)

Example 9 with WikiPage

use of org.olat.modules.wiki.WikiPage 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);
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) WikiPage(org.olat.modules.wiki.WikiPage) Wiki(org.olat.modules.wiki.Wiki) RepositoryEntry(org.olat.repository.RepositoryEntry) WikiPageDocument(org.olat.search.service.document.WikiPageDocument) Document(org.apache.lucene.document.Document) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument)

Example 10 with WikiPage

use of org.olat.modules.wiki.WikiPage in project openolat by klemens.

the class WikiMediaHandler method getInformations.

@Override
public MediaInformations getInformations(Object mediaObject) {
    String title = null;
    if (mediaObject instanceof WikiPage) {
        WikiPage page = (WikiPage) mediaObject;
        title = page.getPageName();
    }
    return new Informations(title, null);
}
Also used : MediaInformations(org.olat.modules.portfolio.MediaInformations) WikiPage(org.olat.modules.wiki.WikiPage)

Aggregations

WikiPage (org.olat.modules.wiki.WikiPage)12 Wiki (org.olat.modules.wiki.Wiki)8 Document (org.apache.lucene.document.Document)6 SearchResourceContext (org.olat.search.service.SearchResourceContext)6 WikiPageDocument (org.olat.search.service.document.WikiPageDocument)6 BusinessGroup (org.olat.group.BusinessGroup)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 IOException (java.io.IOException)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 AssertException (org.olat.core.logging.AssertException)2 Media (org.olat.modules.portfolio.Media)2 MediaInformations (org.olat.modules.portfolio.MediaInformations)2 CourseNodeDocument (org.olat.search.service.document.CourseNodeDocument)2