Search in sources :

Example 96 with PortfolioStructure

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

the class EPStructureManager method loadStructureChildren.

/**
 * @param structure
 * @param firstResult
 * @param maxResults
 * @return
 */
protected List<PortfolioStructure> loadStructureChildren(PortfolioStructure structure, int firstResult, int maxResults) {
    if (structure == null)
        throw new NullPointerException();
    StringBuilder sb = new StringBuilder();
    sb.append("select link.child from ").append(EPStructureToStructureLink.class.getName()).append(" link").append(" where link.parent=:structureEl order by link.order");
    DBQuery query = dbInstance.createQuery(sb.toString());
    if (firstResult > 0) {
        query.setFirstResult(firstResult);
    }
    if (maxResults > 0) {
        query.setMaxResults(maxResults);
    }
    query.setEntity("structureEl", structure);
    @SuppressWarnings("unchecked") List<PortfolioStructure> resources = query.list();
    return resources;
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPStructureToStructureLink(org.olat.portfolio.model.structel.EPStructureToStructureLink) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 97 with PortfolioStructure

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

the class EPXStreamHandler method copy.

public static final PortfolioStructure copy(PortfolioStructure structure) {
    String stringuified = myStream.toXML(structure);
    PortfolioStructure newStructure = (PortfolioStructure) myStream.fromXML(stringuified);
    return newStructure;
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 98 with PortfolioStructure

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

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

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

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

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

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);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) SearchResourceContext(org.olat.search.service.SearchResourceContext) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) PortfolioMapDocument(org.olat.search.service.document.PortfolioMapDocument) Document(org.apache.lucene.document.Document)

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