Search in sources :

Example 1 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class PortfolioMapDocument method getContent.

private static String getContent(PortfolioStructure map, SearchResourceContext resourceContext, StringBuilder sb, Filter filter) {
    sb.append(' ').append(map.getTitle());
    if (StringHelper.containsNonWhitespace(map.getDescription())) {
        sb.append(' ').append(filter.filter(map.getDescription()));
    }
    for (PortfolioStructure child : ePFMgr.loadStructureChildren(map)) {
        getContent(child, resourceContext, sb, filter);
    }
    for (AbstractArtefact artefact : ePFMgr.getArtefacts(map)) {
        String reflexion = artefact.getReflexion();
        if (StringHelper.containsNonWhitespace(reflexion)) {
            sb.append(' ').append(filter.filter(reflexion));
        }
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(AbstractArtefact.class.getSimpleName(), artefact.getKey());
        EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
        SearchResourceContext artefactResourceContext = new SearchResourceContext(resourceContext);
        artefactResourceContext.setBusinessControlFor(ores);
        OlatDocument doc = handler.getIndexerDocument(artefactResourceContext, artefact, ePFMgr);
        sb.append(' ').append(doc.getContent());
    }
    return sb.toString();
}
Also used : OlatDocument(org.olat.search.model.OlatDocument) OLATResourceable(org.olat.core.id.OLATResourceable) SearchResourceContext(org.olat.search.service.SearchResourceContext) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 2 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

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 3 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class PortfolioRepositoryIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext resourceContext, Object object, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    if (!portfolioModule.isEnabled())
        return;
    if (isLogDebugEnabled())
        logDebug("Index portfolio templates...");
    RepositoryEntry repositoryEntry = (RepositoryEntry) object;
    OLATResource ores = repositoryEntry.getOlatResource();
    PortfolioStructure element = structureManager.loadPortfolioStructure(ores);
    // only index templates
    if (element instanceof EPStructuredMapTemplate) {
        resourceContext.setDocumentType(TYPE);
        resourceContext.setParentContextType(TYPE);
        resourceContext.setParentContextName(repositoryEntry.getDisplayname());
        resourceContext.setFilePath(element.getKey().toString());
        Document document = PortfolioMapDocument.createDocument(resourceContext, element);
        indexWriter.addDocument(document);
    }
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) PortfolioMapDocument(org.olat.search.service.document.PortfolioMapDocument) Document(org.apache.lucene.document.Document)

Example 4 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

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);
        }
    }
}
Also used : PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) SearchResourceContext(org.olat.search.service.SearchResourceContext) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) PortfolioMapDocument(org.olat.search.service.document.PortfolioMapDocument) Document(org.apache.lucene.document.Document) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument)

Example 5 with PortfolioStructure

use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.

the class EPFrontendManagerTest method testCopyMap.

@Test
public void testCopyMap() {
    // create two artefacts
    AbstractArtefact artefact1 = epFrontendManager.createAndPersistArtefact(ident1, "text");
    assertNotNull(artefact1);
    AbstractArtefact artefact2 = epFrontendManager.createAndPersistArtefact(ident1, "bc");
    assertNotNull(artefact2);
    dbInstance.commitAndCloseSession();
    // create a map with a page and the page has two artefacts
    PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title", "Description");
    PortfolioStructure newPage = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
    boolean successfullLink1 = epFrontendManager.addArtefactToStructure(ident1, artefact1, newPage);
    assertTrue(successfullLink1);
    boolean successfullLink2 = epFrontendManager.addArtefactToStructure(ident1, artefact2, newPage);
    assertTrue(successfullLink2);
    dbInstance.commitAndCloseSession();
    // 1 test: copy the map one shoot
    PortfolioStructureMap copyMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title copy", "Description copy");
    epFrontendManager.copyStructureRecursively(originalMap, copyMap, true);
    assertNotNull(copyMap.getKey());
    dbInstance.commitAndCloseSession();
    // 2 test: copy the map two shoota
    PortfolioStructureMap copyMap2 = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title copy 2", "Description copy 2");
    dbInstance.commitAndCloseSession();
    assertNotNull(copyMap2.getKey());
    epFrontendManager.copyStructureRecursively(originalMap, copyMap2, true);
    dbInstance.commitAndCloseSession();
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Test(org.junit.Test)

Aggregations

PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)236 Test (org.junit.Test)90 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)70 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)54 ArrayList (java.util.ArrayList)40 OLATResource (org.olat.resource.OLATResource)30 Identity (org.olat.core.id.Identity)26 RepositoryEntry (org.olat.repository.RepositoryEntry)24 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)22 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)16 EPPage (org.olat.portfolio.model.structel.EPPage)16 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)12 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)12 DBQuery (org.olat.core.commons.persistence.DBQuery)10 EPFrontendManager (org.olat.portfolio.manager.EPFrontendManager)10 Date (java.util.Date)8 Document (org.apache.lucene.document.Document)8 Link (org.olat.core.gui.components.link.Link)8 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)8 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)8