Search in sources :

Example 1 with EPFilterSettings

use of org.olat.portfolio.model.EPFilterSettings in project OpenOLAT by OpenOLAT.

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)

Example 2 with EPFilterSettings

use of org.olat.portfolio.model.EPFilterSettings in project OpenOLAT by OpenOLAT.

the class EPArtefactPoolRunController method initTPAllView.

private void initTPAllView(UserRequest ureq) {
    filterSettings = new EPFilterSettings();
    List<AbstractArtefact> artefacts = ePFMgr.getArtefactPoolForUser(getIdentity());
    initMultiArtefactCtrl(ureq, artefacts);
    initFilterPanel(ureq, Filter.read_only);
    setSegmentContent(artCtrl);
    addToHistory(ureq, OresHelper.createOLATResourceableType("All"), null);
}
Also used : EPFilterSettings(org.olat.portfolio.model.EPFilterSettings) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 3 with EPFilterSettings

use of org.olat.portfolio.model.EPFilterSettings in project OpenOLAT by OpenOLAT.

the class EPSettingsManager method setSavedFilterSettings.

public void setSavedFilterSettings(Identity ident, List<EPFilterSettings> filterList) {
    Property p = propertyManager.findProperty(ident, null, null, EPORTFOLIO_CATEGORY, EPORTFOLIO_FILTER_SETTINGS);
    if (p == null) {
        p = propertyManager.createUserPropertyInstance(ident, EPORTFOLIO_CATEGORY, EPORTFOLIO_FILTER_SETTINGS, null, null, null, null);
    }
    // don't persist filters without a name
    for (Iterator<EPFilterSettings> iterator = filterList.iterator(); iterator.hasNext(); ) {
        EPFilterSettings epFilterSettings = iterator.next();
        if (!StringHelper.containsNonWhitespace(epFilterSettings.getFilterName())) {
            iterator.remove();
        }
    }
    XStream xStream = XStreamHelper.createXStreamInstance();
    xStream.aliasType("EPFilterSettings", EPFilterSettings.class);
    String filterListXML = xStream.toXML(filterList);
    p.setTextValue(filterListXML);
    propertyManager.saveProperty(p);
}
Also used : EPFilterSettings(org.olat.portfolio.model.EPFilterSettings) XStream(com.thoughtworks.xstream.XStream) Property(org.olat.properties.Property)

Example 4 with EPFilterSettings

use of org.olat.portfolio.model.EPFilterSettings in project OpenOLAT by OpenOLAT.

the class EPFilterSelectController method formInnerEvent.

/**
 * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formInnerEvent(org.olat.core.gui.UserRequest, org.olat.core.gui.components.form.flexible.FormItem, org.olat.core.gui.components.form.flexible.impl.FormEvent)
 */
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == filterSel) {
        int selFilter = filterSel.getSelected();
        EPFilterSettings selFilterSet;
        if (selFilter != 0) {
            selFilterSet = nonEmptyFilters.get(selFilter - 1);
        } else {
            // all was selected, fire an empty filter
            selFilterSet = new EPFilterSettings();
        }
        fireEvent(ureq, new PortfolioFilterChangeEvent(selFilterSet));
    } else if (source == adaptBtn) {
        // launch search view
        int selFilter = filterSel.getSelected();
        if (selFilter > 0) {
            EPFilterSettings selFilterSet = nonEmptyFilters.get(selFilter - 1);
            fireEvent(ureq, new PortfolioFilterEditEvent(selFilterSet));
        }
    }
}
Also used : EPFilterSettings(org.olat.portfolio.model.EPFilterSettings)

Example 5 with EPFilterSettings

use of org.olat.portfolio.model.EPFilterSettings in project OpenOLAT by OpenOLAT.

the class PortfolioFilterController method initFilterList.

private void initFilterList(FormItemContainer formLayout) {
    List<EPFilterSettings> existingFilters = ePFMgr.getSavedFilterSettings(getIdentity());
    for (Iterator<EPFilterSettings> existingFilterIt = existingFilters.iterator(); existingFilterIt.hasNext(); ) {
        if (existingFilterIt.next().isFilterEmpty()) {
            existingFilterIt.remove();
        }
    }
    int amount = existingFilters.size() + 1;
    nonEmptyFilters = new ArrayList<EPFilterSettings>(amount);
    String[] theKeys = new String[amount];
    String[] theValues = new String[amount];
    String presetFilterIndex = theKeys[0] = "0";
    theValues[0] = translate("filter.all");
    int i = 1;
    String presetFilterID = filterSettings.getFilterId();
    for (EPFilterSettings epFilterSettings : existingFilters) {
        theKeys[i] = epFilterSettings.getFilterId();
        theValues[i] = epFilterSettings.getFilterName();
        if (presetFilterID != null && presetFilterID.equals(epFilterSettings.getFilterId())) {
            presetFilterIndex = epFilterSettings.getFilterId();
        }
        nonEmptyFilters.add(epFilterSettings);
        i++;
    }
    // don't show anything if no filter exists
    if (!nonEmptyFilters.isEmpty()) {
        if (formLayout.getFormComponent("filter.select") == null) {
            filterSel = uifactory.addDropdownSingleselect("filter.select", formLayout, theKeys, theValues, null);
            filterSel.addActionListener(FormEvent.ONCHANGE);
        } else {
            filterSel.setKeysAndValues(theKeys, theValues, null);
            filterSel.setVisible(true);
        }
        if (presetFilterIndex != null) {
            filterSel.select(presetFilterIndex, true);
        }
    } else if (formLayout.getFormComponent("filter.select") != null) {
        formLayout.getFormComponent("filter.select").setVisible(false);
    }
}
Also used : EPFilterSettings(org.olat.portfolio.model.EPFilterSettings)

Aggregations

EPFilterSettings (org.olat.portfolio.model.EPFilterSettings)22 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)8 XStream (com.thoughtworks.xstream.XStream)4 ArrayList (java.util.ArrayList)4 Property (org.olat.properties.Property)4 Date (java.util.Date)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 Roles (org.olat.core.id.Roles)2