Search in sources :

Example 16 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.

the class EPStructureManager method copy.

/**
 * Copy/Import structure elements recursively
 * @param refLink
 * @param targetEl
 * @param withArtefacts Copy the artefacts
 * @param importEl Don't load elements from the DB
 * @param cloneRestrictions should the collect-restrictions be applied? you could also do this manually by copyCollectRestriction()
 */
private void copy(EPStructureToStructureLink refLink, EPStructureElement targetEl, boolean withArtefacts, boolean importEl, boolean cloneRestrictions) {
    EPStructureElement childSourceEl = (EPStructureElement) refLink.getChild();
    EPStructureElement clonedChildEl = instantiateClone(refLink.getChild());
    if (clonedChildEl == null) {
        log.warn("Attempt to clone an unsupported structure type: " + refLink.getChild(), null);
    } else {
        OLATResource resource = resourceManager.createOLATResourceInstance(clonedChildEl.getClass());
        clonedChildEl.setOlatResource(resource);
        // set root
        if (targetEl.getRoot() == null) {
            // it's the root element
            clonedChildEl.setRoot(targetEl);
        } else {
            clonedChildEl.setRoot(targetEl.getRoot());
        }
        if (targetEl.getRootMap() == null && targetEl instanceof PortfolioStructureMap) {
            clonedChildEl.setRootMap((PortfolioStructureMap) targetEl);
        } else {
            clonedChildEl.setRootMap(targetEl.getRootMap());
        }
        if (!importEl)
            clonedChildEl.setStructureElSource(childSourceEl.getKey());
        if (cloneRestrictions)
            copyOrUpdateCollectRestriction(childSourceEl, clonedChildEl, true);
        if (importEl) {
            importEPStructureElementRecursively(childSourceEl, clonedChildEl);
        } else {
            copyEPStructureElementRecursively(childSourceEl, clonedChildEl, withArtefacts, cloneRestrictions);
        }
        EPStructureToStructureLink link = new EPStructureToStructureLink();
        link.setParent(targetEl);
        link.setChild(clonedChildEl);
        targetEl.getInternalChildren().add(link);
    }
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) OLATResource(org.olat.resource.OLATResource) EPStructureToStructureLink(org.olat.portfolio.model.structel.EPStructureToStructureLink)

Example 17 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.

the class EPStructureManager method createPortfolioPage.

/**
 * Create a page element
 * @param title
 * @param description
 * @return The structure element
 */
protected PortfolioStructure createPortfolioPage(PortfolioStructure root, String title, String description) {
    EPPage el = new EPPage();
    el.setRoot((EPStructureElement) root);
    if (root != null && root.getRootMap() == null && root instanceof PortfolioStructureMap) {
        el.setRootMap((PortfolioStructureMap) root);
    } else if (root != null) {
        el.setRootMap(root.getRootMap());
    }
    return fillStructureElement(el, title, description);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPPage(org.olat.portfolio.model.structel.EPPage)

Example 18 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.

the class EPFrontendManager method createAndPersistPortfolioDefaultMap.

/**
 * Create a map for a user
 * @param root
 * @param identity
 * @param title
 * @param description
 * @return
 */
public PortfolioStructureMap createAndPersistPortfolioDefaultMap(Identity identity, String title, String description) {
    PortfolioStructureMap map = structureManager.createPortfolioDefaultMap(identity, title, description);
    structureManager.savePortfolioStructure(map);
    return map;
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap)

Example 19 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.

the class EPFrontendManager method closeMapAfterDeadline.

/**
 * Close all maps after the deadline if there is a deadline. It can be a long running
 * process if a lot of maps are involved.
 */
public void closeMapAfterDeadline() {
    List<PortfolioStructureMap> mapsToClose = structureManager.getOpenStructuredMapAfterDeadline();
    int count = 0;
    for (PortfolioStructureMap mapToClose : mapsToClose) {
        submitMap(mapToClose, false, Role.auto);
        if (count % 5 == 0) {
            // this possibly takes longer than connection timeout, so do intermediatecommits.
            dbInstance.intermediateCommit();
        }
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap)

Example 20 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.

the class EPFrontendManager method createAndPersistPortfolioStructuredMap.

/**
 * Create a structured map, based on template.
 *
 * @param identity The author/owner of the map
 * @param title
 * @param description
 * @return The structure element
 */
public PortfolioStructureMap createAndPersistPortfolioStructuredMap(PortfolioStructureMap template, Identity identity, String title, String description, OLATResourceable targetOres, String targetSubPath, String targetBusinessPath) {
    PortfolioStructureMap map = structureManager.createPortfolioStructuredMap(template, identity, title, description, targetOres, targetSubPath, targetBusinessPath);
    structureManager.savePortfolioStructure(map);
    return map;
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap)

Aggregations

PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)118 Test (org.junit.Test)64 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)54 Identity (org.olat.core.id.Identity)34 RepositoryEntry (org.olat.repository.RepositoryEntry)30 OLATResource (org.olat.resource.OLATResource)30 ArrayList (java.util.ArrayList)18 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)18 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)18 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)16 Date (java.util.Date)10 Invitation (org.olat.basesecurity.Invitation)8 Binder (org.olat.modules.portfolio.Binder)8 EPTargetResource (org.olat.portfolio.model.structel.EPTargetResource)8 EPSecurityCallback (org.olat.portfolio.EPSecurityCallback)6 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)6 CalendarController (org.olat.commons.calendar.ui.CalendarController)4 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)4 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)4 Link (org.olat.core.gui.components.link.Link)4