Search in sources :

Example 36 with AbstractArtefact

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

the class EPTOCTreeModel method loadChildNode.

protected void loadChildNode(PortfolioStructure structure, TreeNode structureNode) {
    structureNode.removeAllChildren();
    List<PortfolioStructure> structs = ePFMgr.loadStructureChildren(structure);
    for (PortfolioStructure portfolioStructure : structs) {
        loadNode(portfolioStructure, structureNode);
    }
    List<AbstractArtefact> artList = ePFMgr.getArtefacts(structure);
    for (AbstractArtefact artefact : artList) {
        String artefactIdent = structureNode.getIdent() + artefact.getKey().toString();
        GenericTreeNode artefactNode = new GenericTreeNode(artefactIdent, artefact.getTitle(), artefact);
        artefactNode.setIconCssClass("o_icon o_ep_artefact " + artefact.getIcon());
        structureNode.addChild(artefactNode);
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 37 with AbstractArtefact

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

the class EPTOCReadOnlyController method buildTOCModel.

/**
 * builds the tocList recursively containing artefacts, pages and
 * struct-Elements
 *
 * @param pStruct
 * @param tocList
 *            list with TOCElement's to use in velocity
 * @param level
 * @param withArtefacts
 *            set false, to skip artefacts
 */
private void buildTOCModel(PortfolioStructure pStruct, List<TOCElement> tocList, int level) {
    level++;
    if (displayArtefactsInTOC) {
        List<AbstractArtefact> artList = ePFMgr.getArtefacts(pStruct);
        if (artList != null && artList.size() != 0) {
            for (AbstractArtefact artefact : artList) {
                String key = String.valueOf(artefact.getKey());
                String title = StringHelper.escapeHtml(artefact.getTitle());
                Link iconLink = LinkFactory.createCustomLink("arte_" + key, LINK_CMD_OPEN_ARTEFACT, "", Link.NONTRANSLATED, vC, this);
                iconLink.setIconRightCSS("o_icon o_icon_start");
                iconLink.setUserObject(pStruct);
                Link titleLink = LinkFactory.createCustomLink("arte_t_" + key, LINK_CMD_OPEN_ARTEFACT, title, Link.NONTRANSLATED, vC, this);
                titleLink.setUserObject(pStruct);
                TOCElement actualTOCEl = new TOCElement(level, "artefact", titleLink, iconLink, null, null);
                tocList.add(actualTOCEl);
            }
        }
    }
    List<PortfolioStructure> childs = ePFMgr.loadStructureChildren(pStruct);
    if (childs != null && childs.size() != 0) {
        for (PortfolioStructure portfolioStructure : childs) {
            String type = "";
            if (portfolioStructure instanceof EPPage) {
                type = CONST_FOR_VC_STYLE_PAGE;
            } else {
                // a structure element
                type = CONST_FOR_VC_STYLE_STRUCT;
            }
            String key = String.valueOf(portfolioStructure.getKey());
            String title = StringHelper.escapeHtml(portfolioStructure.getTitle());
            Link iconLink = LinkFactory.createCustomLink("portstruct" + key, LINK_CMD_OPEN_STRUCT, "", Link.NONTRANSLATED, vC, this);
            iconLink.setIconRightCSS("o_icon o_icon_start");
            iconLink.setUserObject(portfolioStructure);
            Link titleLink = LinkFactory.createCustomLink("portstruct_t_" + key, LINK_CMD_OPEN_STRUCT, title, Link.NONTRANSLATED, vC, this);
            titleLink.setUserObject(portfolioStructure);
            Link commentLink = null;
            if (portfolioStructure instanceof EPPage && secCallback.canCommentAndRate()) {
                UserCommentsCount comments = getUserCommentsCount(portfolioStructure);
                String count = comments == null ? "0" : comments.getCount().toString();
                String label = translate("commentLink", new String[] { count });
                commentLink = LinkFactory.createCustomLink("commentLink" + key, LINK_CMD_OPEN_COMMENTS, label, Link.NONTRANSLATED, vC, this);
                commentLink.setIconLeftCSS("o_icon o_icon_comments");
                commentLink.setUserObject(portfolioStructure);
            }
            // prefetch children to keep reference on them
            List<TOCElement> tocChildList = new ArrayList<TOCElement>();
            buildTOCModel(portfolioStructure, tocChildList, level);
            TOCElement actualTOCEl = new TOCElement(level, type, titleLink, iconLink, commentLink, tocChildList);
            tocList.add(actualTOCEl);
            if (tocChildList.size() != 0) {
                tocList.addAll(tocChildList);
            }
        }
    }
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList) Link(org.olat.core.gui.components.link.Link) UserCommentsCount(org.olat.core.commons.services.commentAndRating.model.UserCommentsCount)

Example 38 with AbstractArtefact

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

the class CertificateAndEfficiencyStatementListController method doCollectArtefact.

private void doCollectArtefact(UserRequest ureq, String title, Long efficiencyStatementKey) {
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(EfficiencyStatementArtefact.ARTEFACT_TYPE);
    if (artHandler != null && artHandler.isEnabled() && assessedIdentity.equals(getIdentity())) {
        AbstractArtefact artefact = artHandler.createArtefact();
        // only author can create artefact
        artefact.setAuthor(getIdentity());
        // no business path becouse we cannot launch an efficiency statement
        artefact.setCollectionDate(new Date());
        artefact.setTitle(translate("artefact.title", new String[] { title }));
        EfficiencyStatement fullStatement = esm.getUserEfficiencyStatementByKey(efficiencyStatementKey);
        artHandler.prefillArtefactAccordingToSource(artefact, fullStatement);
        ePFCollCtrl = new ArtefactWizzardStepsController(ureq, getWindowControl(), artefact, (VFSContainer) null);
        listenTo(ePFCollCtrl);
    }
}
Also used : ArtefactWizzardStepsController(org.olat.portfolio.ui.artefacts.collect.ArtefactWizzardStepsController) VFSContainer(org.olat.core.util.vfs.VFSContainer) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Date(java.util.Date) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) CertificateAndEfficiencyStatement(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement)

Example 39 with AbstractArtefact

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

the class CertificateAndEfficiencyStatementController method popupArtefactCollector.

/**
 * opens the collect-artefact wizard
 *
 * @param ureq
 */
private void popupArtefactCollector(UserRequest ureq) {
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(EfficiencyStatementArtefact.ARTEFACT_TYPE);
    if (artHandler != null && artHandler.isEnabled()) {
        AbstractArtefact artefact = artHandler.createArtefact();
        // only author can create artefact
        artefact.setAuthor(getIdentity());
        // no business path becouse we cannot launch an efficiency statement
        artefact.setCollectionDate(new Date());
        artefact.setTitle(translate("artefact.title", new String[] { efficiencyStatement.getCourseTitle() }));
        artHandler.prefillArtefactAccordingToSource(artefact, efficiencyStatement);
        ePFCollCtrl = new ArtefactWizzardStepsController(ureq, getWindowControl(), artefact, (VFSContainer) null);
        listenTo(ePFCollCtrl);
        // set flag for js-window-resizing (see velocity)
        mainVC.contextPut("collectwizard", true);
    }
}
Also used : ArtefactWizzardStepsController(org.olat.portfolio.ui.artefacts.collect.ArtefactWizzardStepsController) VFSContainer(org.olat.core.util.vfs.VFSContainer) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Date(java.util.Date)

Example 40 with AbstractArtefact

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

the class EPArtefactManagerTest method testCreateForumArtefact.

@Test
public void testCreateForumArtefact() {
    EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler("Forum");
    AbstractArtefact artefact = handler.createArtefact();
    artefact.setAuthor(ident1);
    assertNotNull(artefact);
    assertTrue(artefact instanceof ForumArtefact);
    // update the artefact
    AbstractArtefact persistedArtefact = epFrontendManager.updateArtefact(artefact);
    assertNotNull(persistedArtefact);
    assertTrue(persistedArtefact instanceof ForumArtefact);
    dbInstance.commitAndCloseSession();
    // reload the artefact
    AbstractArtefact loadedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
    assertNotNull(loadedArtefact);
    assertTrue(loadedArtefact instanceof ForumArtefact);
    // get the VFS container of the artefact
    VFSContainer container = epFrontendManager.getArtefactContainer(loadedArtefact);
    assertNotNull(container);
    if (container instanceof LocalFolderImpl) {
        LocalFolderImpl folder = (LocalFolderImpl) container;
        assertNotNull(folder.getBasefile());
        assertTrue(folder.getBasefile().exists());
        assertTrue(folder.getBasefile().isDirectory());
    }
}
Also used : ForumArtefact(org.olat.modules.fo.portfolio.ForumArtefact) VFSContainer(org.olat.core.util.vfs.VFSContainer) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) Test(org.junit.Test)

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