Search in sources :

Example 26 with EPStructureElement

use of org.olat.portfolio.model.structel.EPStructureElement in project openolat by klemens.

the class EPFrontendManager method createAndPersistPortfolioStructureElement.

/**
 * create a structure-element
 * @param root
 * @param title
 * @param description
 * @return
 */
public PortfolioStructure createAndPersistPortfolioStructureElement(PortfolioStructure root, String title, String description) {
    EPStructureElement newStruct = (EPStructureElement) structureManager.createPortfolioStructure(root, title, description);
    if (root != null)
        structureManager.addStructureToStructure(root, newStruct, -1);
    structureManager.savePortfolioStructure(newStruct);
    return newStruct;
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement)

Example 27 with EPStructureElement

use of org.olat.portfolio.model.structel.EPStructureElement in project openolat by klemens.

the class EPFrontendManager method getValidStyleName.

/**
 * get a valid name of style for a given PortfolioStructure
 * if style is not enabled anymore, the default will be used.
 * @param struct
 * @return the set style or the default from config if nothing is set.
 */
public String getValidStyleName(PortfolioStructure struct) {
    // first style in list is the default, can be named default.
    List<String> allStyles = portfolioModule.getAvailableMapStyles();
    if (allStyles == null || allStyles.size() == 0)
        throw new AssertException("at least one style (that also exists in brasato.css must be configured for maps.");
    String styleName = ((EPStructureElement) struct).getStyle();
    if (StringHelper.containsNonWhitespace(styleName) && allStyles.contains(styleName)) {
        return styleName;
    }
    return allStyles.get(0);
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) AssertException(org.olat.core.logging.AssertException)

Example 28 with EPStructureElement

use of org.olat.portfolio.model.structel.EPStructureElement in project openolat by klemens.

the class EPStructureManager method removeStructure.

/**
 * Remove a child structure from its parent structure.
 * @param parentStructure
 * @param childStructure
 */
// this has to be done recursively for pages, structs also!
// also remove the artefacts from each!
public void removeStructure(PortfolioStructure parentStructure, PortfolioStructure childStructure) {
    if (childStructure == null)
        throw new NullPointerException();
    // child not persisted
    if (childStructure.getKey() == null)
        return;
    // cannot remove with no parent!
    if (parentStructure == null)
        return;
    if (childStructure instanceof EPStructureElement) {
        // save eventual changes
        dbInstance.updateObject(parentStructure);
        // reconnect to the session
        EPStructureToStructureLink linkToDelete = null;
        EPStructureElement parentStructureEl = (EPStructureElement) dbInstance.loadObject((EPStructureElement) parentStructure);
        for (Iterator<EPStructureToStructureLink> linkIt = parentStructureEl.getInternalChildren().iterator(); linkIt.hasNext(); ) {
            EPStructureToStructureLink link = linkIt.next();
            if (link.getChild().getKey().equals(childStructure.getKey())) {
                linkIt.remove();
                linkToDelete = link;
                break;
            }
        }
        // I have not set the cascade all delete
        if (linkToDelete != null) {
            dbInstance.updateObject(parentStructureEl);
            dbInstance.deleteObject(linkToDelete);
        }
    }
    if (parentStructure == childStructure) {
        deleteRootStructure(childStructure);
        return;
    }
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPStructureToStructureLink(org.olat.portfolio.model.structel.EPStructureToStructureLink)

Example 29 with EPStructureElement

use of org.olat.portfolio.model.structel.EPStructureElement in project openolat by klemens.

the class OLATUpgrade_7_1_1 method fixTemplateEntry.

private void fixTemplateEntry(PortfolioStructure template) {
    List<PortfolioStructure> temps = new ArrayList<PortfolioStructure>();
    recurseIntoTemplateAndCheck(new ArrayList<PortfolioStructure>(), temps, template);
    for (PortfolioStructure portfolioStructure : temps) {
        ((EPStructureElement) portfolioStructure).setStructureElSource(null);
        ePFMgr.savePortfolioStructure(portfolioStructure);
    }
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList)

Example 30 with EPStructureElement

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

the class EPStructureManager method createPortfolioStructure.

/**
 * Create a basic structure element
 * @param title
 * @param description
 * @return The structure element
 */
protected PortfolioStructure createPortfolioStructure(PortfolioStructure root, String title, String description) {
    EPStructureElement el = new EPStructureElement();
    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 : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap)

Aggregations

EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)66 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)18 EPStructureToStructureLink (org.olat.portfolio.model.structel.EPStructureToStructureLink)16 EPStructureToArtefactLink (org.olat.portfolio.model.structel.EPStructureToArtefactLink)12 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)8 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)8 EPPage (org.olat.portfolio.model.structel.EPPage)8 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)6 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)6 Identity (org.olat.core.id.Identity)4 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)4 OLATResource (org.olat.resource.OLATResource)4 Date (java.util.Date)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)2 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2