Search in sources :

Example 31 with AbstractArtefact

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

the class EPMultipleArtefactPreviewController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    OLATResourceable ores = entries.get(0).getOLATResourceable();
    if ("AbstractArtefact".equals(ores.getResourceableTypeName())) {
        Long resId = ores.getResourceableId();
        int index = 0;
        for (AbstractArtefact artefact : artefactsFullList) {
            if (artefact.getKey().equals(resId) || artefact.getResourceableId().equals(resId)) {
                int rest = (index % artefactsPerPage);
                int page = (index - rest) / artefactsPerPage;
                preparePaging(ureq, page + 1);
                break;
            }
            index++;
        }
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 32 with AbstractArtefact

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

the class EPMultipleArtefactsAsTableController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    OLATResourceable ores = entries.get(0).getOLATResourceable();
    if ("AbstractArtefact".equals(ores.getResourceableTypeName())) {
        Long resId = ores.getResourceableId();
        ArtefactTableDataModel model = (ArtefactTableDataModel) artefactListTblCtrl.getTableDataModel();
        for (int i = 0; i < model.getRowCount(); i++) {
            AbstractArtefact artefact = model.getObject(i);
            if (artefact.getKey().equals(resId)) {
                int artefactsPerPage = artefactListTblCtrl.getPageSize();
                int rest = (i % artefactsPerPage);
                int page = (i - rest) / artefactsPerPage;
                artefactListTblCtrl.setPage(new Integer(page + 1));
                break;
            }
        }
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 33 with AbstractArtefact

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

the class EPTagBrowseController method getRealArtefactTags.

// filter available tags for such of non-existing artefacts
private List<String> getRealArtefactTags() {
    allUsersArtefacts = ePFMgr.getArtefactPoolForUser(getIdentity());
    if (allUsersArtefacts == null)
        return new ArrayList<String>();
    HashSet<String> realTags = new HashSet<String>();
    for (AbstractArtefact abstractArtefact : allUsersArtefacts) {
        List<String> thisTags = ePFMgr.getArtefactTags(abstractArtefact);
        realTags.addAll(thisTags);
    }
    List<String> res = new ArrayList<String>();
    res.addAll(realTags);
    return res;
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 34 with AbstractArtefact

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

the class EPTagBrowseController method recalculateTagCloud.

private List<AbstractArtefact> recalculateTagCloud() {
    List<String> selectedTags = getSelectedTags();
    if (selectedTags.isEmpty()) {
        for (Link tagLink : tagLinks) {
            TagWrapper tagWrapper = (TagWrapper) tagLink.getUserObject();
            tagLink.setCustomEnabledLinkCSS(inactiveCSS);
            tagLink.setEnabled(true);
            tagWrapper.setState(TagState.possible);
        }
        return allUsersArtefacts;
    }
    EPArtefactTagCloud artefactsAndTags = ePFMgr.getArtefactsAndTagCloud(getIdentity(), selectedTags);
    List<AbstractArtefact> filteredArtefacts = artefactsAndTags.getArtefacts();
    Set<String> newTags = artefactsAndTags.getTags();
    if (newTags != null && !newTags.isEmpty()) {
        for (Link tagLink : tagLinks) {
            TagWrapper tagWrapper = (TagWrapper) tagLink.getUserObject();
            String tag = tagWrapper.getTag();
            switch(tagWrapper.getState()) {
                case selected:
                    tagLink.setCustomEnabledLinkCSS(activeCSS);
                    tagLink.setEnabled(true);
                    break;
                case possible:
                    if (!newTags.contains(tag)) {
                        tagWrapper.setState(TagState.unpossible);
                        tagLink.setEnabled(false);
                    } else {
                        tagLink.setCustomEnabledLinkCSS(inactiveCSS);
                        tagLink.setEnabled(true);
                    }
                    break;
                case unpossible:
                    if (newTags.contains(tag)) {
                        tagWrapper.setState(TagState.possible);
                        tagLink.setCustomEnabledLinkCSS(inactiveCSS);
                        tagLink.setEnabled(true);
                    } else {
                        tagLink.setEnabled(false);
                    }
                    break;
            }
        }
    }
    return filteredArtefacts;
}
Also used : EPArtefactTagCloud(org.olat.portfolio.manager.EPArtefactTagCloud) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Link(org.olat.core.gui.components.link.Link)

Example 35 with AbstractArtefact

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

the class EPMultipleArtefactSmallReadOnlyPreviewController method init.

private void init(UserRequest ureq) {
    if (artefactCtrls != null)
        disposeArtefactControllers();
    if (optionLinkCtrls != null)
        disposeOptionLinkControllers();
    optionLinkCtrls = new ArrayList<Controller>();
    artefactCtrls = new ArrayList<Controller>();
    List<List<Panel>> artefactCtrlCompLines = new ArrayList<List<Panel>>();
    List<Panel> artefactCtrlCompLine = new ArrayList<Panel>();
    int i = 1;
    for (AbstractArtefact artefact : artefacts) {
        EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
        Controller artCtrl;
        // check for special art-display:
        boolean special = artHandler.isProvidingSpecialMapViewController();
        if (special) {
            artCtrl = artHandler.getSpecialMapViewController(ureq, getWindowControl(), artefact);
            if (artCtrl != null) {
                // add the optionsLink to the artefact
                EPArtefactViewOptionsLinkController optionsLinkCtrl = new EPArtefactViewOptionsLinkController(ureq, getWindowControl(), artefact, secCallback, struct);
                vC.put("optionsLink" + i, optionsLinkCtrl.getInitialComponent());
                listenTo(optionsLinkCtrl);
                optionLinkCtrls.add(optionsLinkCtrl);
            }
        } else {
            artCtrl = new EPArtefactViewReadOnlyController(ureq, getWindowControl(), artefact, struct, secCallback, true);
        }
        if (artCtrl != null) {
            artefactCtrls.add(artCtrl);
            Component artefactCtrlComponent = artCtrl.getInitialComponent();
            listenTo(artCtrl);
            Panel namedPanel = new Panel("artCtrl" + i);
            namedPanel.setContent(artefactCtrlComponent);
            if (special) {
                if (!artefactCtrlCompLine.isEmpty()) {
                    artefactCtrlCompLines.add(artefactCtrlCompLine);
                }
                artefactCtrlCompLines.add(Collections.singletonList(namedPanel));
                artefactCtrlCompLine = new ArrayList<Panel>();
            } else {
                if (artefactCtrlCompLine.size() == 3) {
                    if (!artefactCtrlCompLine.isEmpty()) {
                        artefactCtrlCompLines.add(artefactCtrlCompLine);
                    }
                    artefactCtrlCompLine = new ArrayList<Panel>();
                }
                artefactCtrlCompLine.add(namedPanel);
            }
            vC.put("artCtrl" + i, namedPanel);
            if (special) {
                // need a flag in a lopp for the velociy template
                vC.put("specialartCtrl" + i, artefactCtrlComponent);
            }
            i++;
        }
    }
    if (!artefactCtrlCompLine.isEmpty()) {
        artefactCtrlCompLines.add(artefactCtrlCompLine);
    }
    vC.contextPut("artefactCtrlCompLines", artefactCtrlCompLines);
}
Also used : ArrayList(java.util.ArrayList) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) Panel(org.olat.core.gui.components.panel.Panel) ArrayList(java.util.ArrayList) List(java.util.List) Component(org.olat.core.gui.components.Component)

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