Search in sources :

Example 56 with AbstractArtefact

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

the class EPArtefactManager method filterArtefactsByString.

private void filterArtefactsByString(List<AbstractArtefact> artefacts, String textFilter) {
    if (StringHelper.containsNonWhitespace(textFilter)) {
        List<AbstractArtefact> toRemove = new ArrayList<AbstractArtefact>();
        for (AbstractArtefact artefact : artefacts) {
            String textCompare = artefact.getTitle() + artefact.getDescription() + artefact.getFulltextContent();
            if (!textCompare.toLowerCase().contains(textFilter.toLowerCase())) {
                toRemove.add(artefact);
            }
        }
        artefacts.removeAll(toRemove);
    }
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) ArrayList(java.util.ArrayList)

Example 57 with AbstractArtefact

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

the class EPArtefactManager method loadArtefactsByBusinessPath.

protected List<AbstractArtefact> loadArtefactsByBusinessPath(String businessPath, Identity author) {
    if (!StringHelper.containsNonWhitespace(businessPath))
        return null;
    StringBuilder sb = new StringBuilder();
    sb.append("select artefact from ").append(AbstractArtefact.class.getName()).append(" artefact").append(" where artefact.businessPath=:bpath");
    if (author != null) {
        sb.append(" and artefact.author=:ident");
    }
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setString("bpath", businessPath);
    if (author != null) {
        query.setEntity("ident", author);
    }
    @SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
    // if not found, it is an empty list
    if (artefacts.isEmpty())
        return null;
    return artefacts;
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 58 with AbstractArtefact

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

the class EPArtefactManager method getArtefactPoolForUser.

protected List<AbstractArtefact> getArtefactPoolForUser(Identity ident) {
    long start = System.currentTimeMillis();
    StringBuilder sb = new StringBuilder();
    sb.append("select artefact from ").append(AbstractArtefact.class.getName()).append(" artefact").append(" where author=:author");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setEntity("author", ident);
    @SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
    if (artefacts.isEmpty())
        return null;
    long duration = System.currentTimeMillis() - start;
    if (isLogDebugEnabled())
        logDebug("loading the full artefact pool took " + duration + "ms");
    return artefacts;
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 59 with AbstractArtefact

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

the class EPArtefactManager method filterArtefactsByType.

private void filterArtefactsByType(List<AbstractArtefact> artefacts, List<String> type) {
    if (type != null && type.size() != 0) {
        List<AbstractArtefact> toRemove = new ArrayList<AbstractArtefact>();
        for (AbstractArtefact artefact : artefacts) {
            if (!type.contains(artefact.getResourceableTypeName())) {
                toRemove.add(artefact);
            }
        }
        artefacts.removeAll(toRemove);
    }
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) ArrayList(java.util.ArrayList)

Example 60 with AbstractArtefact

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

the class EPArtefactManager method getArtefactsAndTagCloud.

/**
 * This is an optimized method to filter a list of artefact by tags and return
 * the tags of this list of artefacts. This prevent to search two times or more the list
 * of tags of an artefact.
 * @param identity
 * @param tags
 * @return the filtered artefacts and their tags
 */
protected EPArtefactTagCloud getArtefactsAndTagCloud(Identity identity, List<String> tags) {
    List<AbstractArtefact> artefacts = getArtefactPoolForUser(identity);
    EPFilterSettings filterSettings = new EPFilterSettings();
    filterSettings.setTagFilter(tags);
    Set<String> newTags = new HashSet<String>();
    filterArtefactsByTags(artefacts, filterSettings, newTags);
    return new EPArtefactTagCloud(artefacts, newTags);
}
Also used : EPFilterSettings(org.olat.portfolio.model.EPFilterSettings) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) HashSet(java.util.HashSet)

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