Search in sources :

Example 1 with EPPage

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

the class EPStructureManager method instantiateClone.

private EPStructureElement instantiateClone(PortfolioStructure source) {
    EPStructureElement targetEl = null;
    // don't forget the inheritence
    if (source instanceof EPPage) {
        targetEl = new EPPage();
        targetEl.setTitle(((EPPage) source).getTitle());
        targetEl.setDescription(((EPPage) source).getDescription());
    } else if (source instanceof EPStructureElement) {
        targetEl = new EPStructureElement();
        targetEl.setTitle(((EPStructureElement) source).getTitle());
        targetEl.setDescription(((EPStructureElement) source).getDescription());
    }
    return targetEl;
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPPage(org.olat.portfolio.model.structel.EPPage)

Example 2 with EPPage

use of org.olat.portfolio.model.structel.EPPage 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 3 with EPPage

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

the class OLATUpgrade_7_1_1 method processStructure.

/**
 * call the needed methods to really do the magic.
 */
private void processStructure(PortfolioStructure structuredMap) {
    List<PortfolioStructure> linkedChildren = ePFMgr.loadStructureChildren(structuredMap);
    for (PortfolioStructure childStruct : linkedChildren) {
        // reload dbchildren in each run, because of filtering
        List<PortfolioStructure> dbChildren;
        if (childStruct instanceof EPPage) {
            dbChildren = loadMapChildrenByInternalFK(childStruct, structuredMap);
        } else {
            dbChildren = loadMapChildrenByInternalFK(childStruct, structuredMap.getRoot());
        }
        // filter the struct that is already linked by a struct->struct link
        // and filter such with other struct-source
        filterLinkedStructs(childStruct, dbChildren);
        log.audit("       found " + dbChildren.size() + " faulty children (of " + childStruct + ") linked by internal fk to be merged and removed afterwards.");
        // merge artefacts to the linked struct
        mergeLinkedArtefactsToFinalStruct(childStruct, dbChildren);
        // collect comments on structures and merge to target
        mergeCommentsToFinalStruct(childStruct, dbChildren);
        // ratings are not merged, see OLAT-6306
        // remove the old elements
        removeWrongElements(dbChildren);
        // fix root-reference on EPStructureElements
        if (!(childStruct instanceof EPPage)) {
            if (childStruct.getRoot().equals(childStruct.getRootMap())) {
                EPStructureElement realParentRoot = (EPStructureElement) ePFMgr.loadStructureParent(childStruct);
                ((EPStructureElement) childStruct).setRoot(realParentRoot);
                ePFMgr.savePortfolioStructure(childStruct);
            }
        }
    }
    // loop children
    DBFactory.getInstance().intermediateCommit();
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPPage(org.olat.portfolio.model.structel.EPPage) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 4 with EPPage

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

the class OLATUpgrade_7_1_1 method mergeCommentsToFinalStruct.

private void mergeCommentsToFinalStruct(PortfolioStructure finalStruct, List<PortfolioStructure> wrongStructs) {
    if (wrongStructs == null || wrongStructs.isEmpty())
        return;
    List<UserComment> collectedComments = new ArrayList<UserComment>();
    // collect all comments out there
    for (PortfolioStructure portfolioStructure : wrongStructs) {
        // no comments on StructureElements!
        if (!(portfolioStructure instanceof EPPage))
            return;
        List<UserComment> oldComments = commentAndRatingService.getComments(portfolioStructure.getRootMap(), portfolioStructure.getKey().toString());
        collectedComments.addAll(oldComments);
        commentAndRatingService.deleteAllComments(portfolioStructure.getRootMap(), portfolioStructure.getKey().toString());
    }
    log.audit("       found " + collectedComments.size() + " comments for this structure, will be merged to new destination.");
    if (collectedComments.size() == 0)
        return;
    Identity ident = collectedComments.get(0).getCreator();
    UserComment topComment = commentAndRatingService.createComment(ident, finalStruct.getRootMap(), finalStruct.getKey().toString(), "The following comments were restored from a migration task to rescue lost data.");
    // attach all to this info-comment
    for (UserComment userComment : collectedComments) {
        UserComment attachedComment = commentAndRatingService.replyTo(topComment, userComment.getCreator(), userComment.getComment());
        // set original date
        attachedComment.setCreationDate(userComment.getCreationDate());
        commentAndRatingService.updateComment(attachedComment, attachedComment.getComment());
    }
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) UserComment(org.olat.core.commons.services.commentAndRating.model.UserComment) ArrayList(java.util.ArrayList) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Identity(org.olat.core.id.Identity)

Example 5 with EPPage

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

the class EPTOCController method refreshAddElements.

/**
 * refreshing the add elements link to actual structure
 * @param ureq
 * @param struct maybe null -> hiding the add-button
 */
private void refreshAddElements(UserRequest ureq, PortfolioStructure struct) {
    tocV.remove(tocV.getComponent("addElement"));
    removeAsListenerAndDispose(addElCtrl);
    if (struct != null) {
        addElCtrl = new EPAddElementsController(ureq, getWindowControl(), struct);
        if (struct instanceof EPPage) {
            if (secCallback.canAddStructure()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_STRUCTUREELEMENT);
            }
            if (secCallback.canAddArtefact()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
            }
        } else if (struct instanceof EPAbstractMap) {
            if (secCallback.canAddPage()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_PAGE);
            }
        } else {
            // its a structure element
            if (secCallback.canAddArtefact()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
            }
        }
        listenTo(addElCtrl);
        tocV.put("addElement", addElCtrl.getInitialComponent());
    }
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) EPAddElementsController(org.olat.portfolio.ui.structel.EPAddElementsController)

Aggregations

EPPage (org.olat.portfolio.model.structel.EPPage)24 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)16 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)8 ArrayList (java.util.ArrayList)4 Link (org.olat.core.gui.components.link.Link)4 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)4 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)4 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)4 Test (org.junit.Test)2 UserComment (org.olat.core.commons.services.commentAndRating.model.UserComment)2 UserCommentsCount (org.olat.core.commons.services.commentAndRating.model.UserCommentsCount)2 TreeDropEvent (org.olat.core.gui.components.tree.TreeDropEvent)2 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)2 WindowControl (org.olat.core.gui.control.WindowControl)2 Identity (org.olat.core.id.Identity)2 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)2 EPAddElementsController (org.olat.portfolio.ui.structel.EPAddElementsController)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 OLATResource (org.olat.resource.OLATResource)2