Search in sources :

Example 61 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.

the class EPFrontendManager method filterArtefactsByFilterSettings.

/**
 * filter the provided list of artefacts with different filters
 *
 * @param allArtefacts the list to manipulate on
 * @param filterSettings Settings for the filter to work on
 * @return
 */
public List<AbstractArtefact> filterArtefactsByFilterSettings(EPFilterSettings filterSettings, Identity identity, Roles roles) {
    List<Long> artefactKeys = fulltextSearchAfterArtefacts(filterSettings, identity, roles);
    if (artefactKeys == null || artefactKeys.isEmpty()) {
        List<AbstractArtefact> allArtefacts = artefactManager.getArtefactPoolForUser(identity);
        return artefactManager.filterArtefactsByFilterSettings(allArtefacts, filterSettings);
    }
    List<AbstractArtefact> artefacts = artefactManager.getArtefacts(identity, artefactKeys, 0, 500);
    // remove the text-filter when the lucene-search got some results before
    EPFilterSettings settings = filterSettings.cloneAfterFullText();
    return artefactManager.filterArtefactsByFilterSettings(artefacts, settings);
}
Also used : EPFilterSettings(org.olat.portfolio.model.EPFilterSettings) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 62 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact 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 63 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.

the class PortfolioArtefactIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext searchResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
    if (!portfolioModule.isEnabled())
        return;
    Identity identity = (Identity) object;
    // SearchResourceContext resourceContext = new SearchResourceContext(searchResourceContext); // dont do this way, as it would then try to open an artefact over visiting card -> not possible!
    SearchResourceContext resourceContext = new SearchResourceContext();
    resourceContext.setDocumentType(TYPE);
    resourceContext.setParentContextType(null);
    int currentPosition = 0;
    List<AbstractArtefact> artefacts;
    do {
        artefacts = frontendManager.getArtefacts(identity, currentPosition, MAX_RESULTS);
        for (AbstractArtefact artefact : artefacts) {
            OLATResourceable ores = OresHelper.createOLATResourceableInstance(AbstractArtefact.class.getSimpleName(), artefact.getKey());
            EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
            resourceContext.setBusinessControlFor(ores);
            OlatDocument doc = handler.getIndexerDocument(resourceContext, artefact, frontendManager);
            Identity author = artefact.getAuthor();
            if (author != null && author.getUser() != null) {
                doc.setReservedTo(author.getKey().toString());
            }
            if (doc != null) {
                indexerWriter.addDocument(doc.getLuceneDocument());
            }
        }
        currentPosition += artefacts.size();
    } while (artefacts.size() == MAX_RESULTS);
    super.doIndex(searchResourceContext, object, indexerWriter);
}
Also used : OlatDocument(org.olat.search.model.OlatDocument) SearchResourceContext(org.olat.search.service.SearchResourceContext) OLATResourceable(org.olat.core.id.OLATResourceable) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Identity(org.olat.core.id.Identity)

Example 64 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.

the class ArtefactWizzardStepsController method prepareNewArtefact.

/**
 * @param ores
 * @param businessPath
 */
private void prepareNewArtefact() {
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(ores.getResourceableTypeName());
    AbstractArtefact artefact1 = artHandler.createArtefact();
    artefact1.setAuthor(getIdentity());
    artefact1.setCollectionDate(new Date());
    artefact1.setBusinessPath(businessPath);
    artHandler.prefillArtefactAccordingToSource(artefact1, ores);
    this.artefact = artefact1;
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Date(java.util.Date)

Example 65 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project openolat by klemens.

the class EPAddArtefactController method prepareFileArtefactWizzard.

/**
 * prepare a file artefact and open with wizzard initialized with a special
 * first step for file-artefacts
 *
 * @param ureq
 */
private void prepareFileArtefactWizzard(UserRequest ureq) {
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(FileArtefact.FILE_ARTEFACT_TYPE);
    AbstractArtefact artefact1 = artHandler.createArtefact();
    artefact1.setAuthor(getIdentity());
    artefact1.setSource(translate("file.artefact.source.info"));
    artefact1.setCollectionDate(new Date());
    artefact1.setSignature(-30);
    vfsTemp = ePFMgr.getArtefactsTempContainer(getIdentity());
    Step start = new EPCreateFileArtefactStep00(ureq, artefact1, preSelectedStruct, vfsTemp);
    StepRunnerCallback finish = new EPArtefactWizzardStepCallback(vfsTemp);
    collectStepsCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("create.file.artefact.wizzard.title"), "o_sel_artefact_add_wizard o_sel_artefact_add_file_wizard");
    listenTo(collectStepsCtrl);
    getWindowControl().pushAsModalDialog(collectStepsCtrl.getInitialComponent());
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Step(org.olat.core.gui.control.generic.wizard.Step) Date(java.util.Date) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback)

Aggregations

AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)164 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)70 Test (org.junit.Test)54 ArrayList (java.util.ArrayList)36 Date (java.util.Date)20 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)18 DBQuery (org.olat.core.commons.persistence.DBQuery)10 Link (org.olat.core.gui.components.link.Link)10 Identity (org.olat.core.id.Identity)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)10 List (java.util.List)8 EPFilterSettings (org.olat.portfolio.model.EPFilterSettings)8 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)6 Step (org.olat.core.gui.control.generic.wizard.Step)6 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)6 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)6 OLATResourceable (org.olat.core.id.OLATResourceable)6 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)6 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)6