Search in sources :

Example 36 with EPStructureElement

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

the class EPStructureManager method move.

private void move(PortfolioStructure parentStructure, PortfolioStructure childStructure, boolean up) {
    if (childStructure == null || parentStructure == null)
        throw new NullPointerException();
    if (parentStructure instanceof EPStructureElement) {
        // save eventual changes
        dbInstance.updateObject(parentStructure);
        // reconnect to the session
        EPStructureElement structureEl = (EPStructureElement) dbInstance.loadObject((EPStructureElement) parentStructure);
        List<EPStructureToStructureLink> structureLinks = structureEl.getInternalChildren();
        int index = indexOf(structureLinks, childStructure);
        if (up && index > 0) {
            // swap the link with the previous link in the list
            Collections.swap(structureLinks, index, index - 1);
            dbInstance.updateObject(structureEl);
        } else if (!up && (index >= 0 && index < (structureLinks.size() - 1))) {
            // swap the link with the next link in the list
            Collections.swap(structureLinks, index, index + 1);
            dbInstance.updateObject(structureEl);
        }
    }
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPStructureToStructureLink(org.olat.portfolio.model.structel.EPStructureToStructureLink)

Example 37 with EPStructureElement

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

the class EPStructureManager method addCollectRestriction.

/**
 * Add or update a restriction to the collection of artefacts for a given structure element
 * @param structure
 * @param artefactType
 * @param restriction
 * @param amount
 */
public void addCollectRestriction(PortfolioStructure structure, String artefactType, String restriction, int amount) {
    if (structure == null)
        throw new NullPointerException("Structure cannot be null");
    EPStructureElement structEl = (EPStructureElement) structure;
    List<CollectRestriction> restrictions = structEl.getCollectRestrictions();
    CollectRestriction cr = new CollectRestriction();
    cr.setArtefactType(artefactType);
    cr.setRestriction(restriction);
    cr.setAmount(amount);
    restrictions.add(cr);
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

Example 38 with EPStructureElement

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

the class EPStructureManager method getReflexionForArtefactToStructureLink.

protected String getReflexionForArtefactToStructureLink(AbstractArtefact artefact, PortfolioStructure structure) {
    if (structure == null)
        return null;
    EPStructureElement structureEl = (EPStructureElement) dbInstance.loadObject((EPStructureElement) structure);
    List<EPStructureToArtefactLink> links = structureEl.getInternalArtefacts();
    for (EPStructureToArtefactLink epStructureToArtefactLink : links) {
        if (epStructureToArtefactLink.getArtefact().getKey().equals(artefact.getKey())) {
            return epStructureToArtefactLink.getReflexion();
        }
    }
    return null;
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPStructureToArtefactLink(org.olat.portfolio.model.structel.EPStructureToArtefactLink)

Example 39 with EPStructureElement

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

the class EPStructureManager method syncStructureRecursively.

/**
 * Sync the tree structure recursively with or without artefacts
 * @param sourceEl
 * @param targetEl
 * @param withArtefacts
 */
protected void syncStructureRecursively(PortfolioStructure source, PortfolioStructure target, boolean withArtefacts) {
    // all changes are overwritten
    EPStructureElement sourceEl = (EPStructureElement) source;
    // update the source
    dbInstance.updateObject(target);
    // reconnect to the session
    EPStructureElement targetEl = (EPStructureElement) dbInstance.loadObject((EPStructureElement) target);
    syncEPStructureElementRecursively(sourceEl, targetEl, withArtefacts);
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement)

Example 40 with EPStructureElement

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

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)

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