Search in sources :

Example 6 with EPStructureElement

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

the class EPStructureManager method getReferencedMapsForArtefact.

protected List<PortfolioStructure> getReferencedMapsForArtefact(AbstractArtefact artefact) {
    List<PortfolioStructure> pfList = getAllReferencesForArtefact(artefact);
    List<PortfolioStructure> mapList = new ArrayList<PortfolioStructure>();
    for (Iterator<?> iterator = pfList.iterator(); iterator.hasNext(); ) {
        EPStructureElement portfolioStructure = (EPStructureElement) iterator.next();
        EPStructureElement actStruct = portfolioStructure;
        while (actStruct.getRoot() != null) {
            EPStructureElement actRoot = actStruct.getRoot();
            if (actRoot != null) {
                actStruct = actRoot;
            }
        }
        if (!mapList.contains(actStruct))
            mapList.add(actStruct);
    }
    return mapList;
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList)

Example 7 with EPStructureElement

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

the class EPStructureManager method moveArtefactFromStructToStruct.

protected boolean moveArtefactFromStructToStruct(AbstractArtefact artefact, PortfolioStructure oldParStruct, PortfolioStructure newParStruct) {
    EPStructureElement oldEPSt = (EPStructureElement) dbInstance.loadObject((EPStructureElement) oldParStruct);
    Identity author = oldEPSt.getInternalArtefacts().get(0).getAuthor();
    // old model without author, doesn't work!
    if (author == null)
        return false;
    String reflexion = getReflexionForArtefactToStructureLink(artefact, oldParStruct);
    removeArtefactFromStructure(artefact, oldParStruct);
    boolean allOk = false;
    allOk = addArtefactToStructure(author, artefact, newParStruct);
    if (allOk)
        return setReflexionForArtefactToStructureLink(artefact, newParStruct, reflexion);
    return allOk;
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) Identity(org.olat.core.id.Identity)

Example 8 with EPStructureElement

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

the class EPStructureManager method getRestrictionStatistics.

protected Integer[] getRestrictionStatistics(PortfolioStructure structure) {
    if (structure instanceof EPStructureElement) {
        EPStructureElement structEl = (EPStructureElement) structure;
        structEl = (EPStructureElement) reloadPortfolioStructure(structEl);
        final List<CollectRestriction> restrictions = structEl.getCollectRestrictions();
        if (restrictions != null && !restrictions.isEmpty()) {
            int todo = 0;
            int done = 0;
            List<AbstractArtefact> artefacts = getArtefacts(structEl);
            for (CollectRestriction cR : restrictions) {
                if (RestrictionsConstants.MIN.equals(cR.getRestriction()) || RestrictionsConstants.EQUAL.equals(cR.getRestriction())) {
                    todo += cR.getAmount();
                    int actualCRCount = countRestrictionType(artefacts, cR);
                    done += actualCRCount;
                }
            }
            return new Integer[] { done, todo };
        }
    }
    return null;
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

Example 9 with EPStructureElement

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

the class EPStructureManager method addArtefactToStructure.

/**
 * Add a link between a structure element and an artefact
 * @param author
 * @param artefact
 * @param structure
 * @return
 */
protected boolean addArtefactToStructure(Identity author, AbstractArtefact artefact, PortfolioStructure structure) {
    if (author == null || artefact == null || structure == null)
        throw new NullPointerException();
    if (structure instanceof EPStructureElement) {
        EPStructureElement structureEl = (EPStructureElement) structure;
        boolean canAdd = canAddArtefact(structureEl, artefact);
        if (!canAdd) {
            return false;
        }
        // save eventual changes
        // TODO update the changes before dbInstance.updateObject(structureEl);
        // reconnect to the session
        structureEl = (EPStructureElement) dbInstance.loadObject(structureEl);
        EPStructureToArtefactLink link = new EPStructureToArtefactLink();
        link.setArtefact(artefact);
        link.setStructureElement(structureEl);
        link.setAuthor(author);
        structureEl.getInternalArtefacts().add(link);
        dbInstance.updateObject(structureEl);
        return true;
    }
    return false;
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPStructureToArtefactLink(org.olat.portfolio.model.structel.EPStructureToArtefactLink)

Example 10 with EPStructureElement

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

the class EPStructureManager method reOrderStructures.

protected boolean reOrderStructures(PortfolioStructure parent, PortfolioStructure orderSubject, int orderDest) {
    EPStructureElement structureEl = (EPStructureElement) dbInstance.loadObject((EPStructureElement) parent);
    List<EPStructureToStructureLink> structureLinks = structureEl.getInternalChildren();
    int oldPos = indexOf(structureLinks, orderSubject);
    if (oldPos != orderDest && oldPos != -1) {
        EPStructureToStructureLink link = structureLinks.remove(oldPos);
        if (oldPos < orderDest) {
            orderDest--;
        }
        if (orderDest < 0) {
            orderDest = 0;
        } else if (orderDest > structureLinks.size()) {
            // place at end
            orderDest = structureLinks.size() - 1;
        }
        structureLinks.add(orderDest, link);
        dbInstance.updateObject(structureEl);
        return true;
    }
    return false;
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPStructureToStructureLink(org.olat.portfolio.model.structel.EPStructureToStructureLink)

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