Search in sources :

Example 16 with EPPage

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

the class EPMapViewController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    super.event(ureq, source, event);
    if (event instanceof EPStructureChangeEvent && event.getCommand().equals(EPStructureChangeEvent.ADDED)) {
        EPStructureChangeEvent changeEvent = (EPStructureChangeEvent) event;
        PortfolioStructure structure = changeEvent.getPortfolioStructure();
        // don't do reloadMapAndRefreshUI(ureq) here; no db-commit yet! no refresh -> stale object!
        if (structure instanceof EPPage) {
            // jump to the edit mode for new pages
            initOrUpdateEditMode(ureq, structure);
        }
    } else if (event instanceof EPStructureEvent && event.getCommand().equals(EPStructureEvent.CHANGE)) {
        // reload map
        reloadMapAndRefreshUI(ureq);
    } else if (source == editCtrl && event.equals(Event.CHANGED_EVENT)) {
        // refresh view on changes in TOC or style
        reloadMapAndRefreshUI(ureq);
        PortfolioStructure selectedPage = editCtrl.getSelectedStructure();
        initOrUpdateEditMode(ureq, selectedPage);
    } else if (source == confirmationSubmissionCtr) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            doSubmitAssess(ureq);
        }
    }
    // fire to multiple maps controller, so it can refresh itself!
    fireEvent(ureq, event);
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 17 with EPPage

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

the class EPMultiplePageController method setAndInitNormalPage.

/**
 * @param ureq
 * @param pageNumberToInit
 * @param withComments
 */
private void setAndInitNormalPage(UserRequest ureq, int pageNumberToInit, boolean withComments) {
    PageTab tab = pageList.get(pageNumberToInit);
    PortfolioStructure structureElement = ePFMgr.loadPortfolioStructureByKey(tab);
    if (structureElement instanceof EPPage) {
        EPPage page = (EPPage) structureElement;
        PortfolioStructure map = ePFMgr.loadStructureParent(tab);
        WindowControl bwControl = addToHistory(ureq, OresHelper.createOLATResourceableInstance(EPPage.class, page.getKey()), null);
        currentActivePageCtrl = new EPPageViewController(ureq, bwControl, map, page, withComments, secCallback);
        listenTo(currentActivePageCtrl);
        // enable toc and changelog links
        disableLink_TOC(false);
        disableLINK_LC(false);
    }
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) WindowControl(org.olat.core.gui.control.WindowControl)

Example 18 with EPPage

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

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 19 with EPPage

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

the class EPFrontendManagerTest method testAssignMapTemplateToUser.

@Test
public void testAssignMapTemplateToUser() {
    // create a template
    OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
    // create a repository entry
    RepositoryEntry addedEntry = repositoryService.create(ident1, null, "-", "template-1", "map-template-1", resource, RepositoryEntry.ACC_OWNERS);
    dbInstance.commitAndCloseSession();
    // create the template owned by ident1
    PortfolioStructureMap templateEl = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(ident1, addedEntry);
    // first page
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(templateEl, "template-page-1", "template-page-1");
    // structure element 1 from page 1
    PortfolioStructure struct11 = epFrontendManager.createAndPersistPortfolioStructureElement(page1, "template-structure-1.1", "template-structure-1.1");
    epStructureManager.addCollectRestriction(struct11, "Forum", "minimum", 2);
    epStructureManager.savePortfolioStructure(struct11);
    // structure element 2 from page 1
    PortfolioStructure struct12 = epFrontendManager.createAndPersistPortfolioStructureElement(page1, "template-structure-1.2", "template-structure-1.2");
    assertNotNull(struct12);
    // first page
    PortfolioStructure page2 = epFrontendManager.createAndPersistPortfolioPage(templateEl, "template-page-2", "template-page-2");
    // structure element 1 from page 2
    PortfolioStructure struct21 = epFrontendManager.createAndPersistPortfolioStructureElement(page2, "template-structure-2.1", "template-structure-2.1");
    epStructureManager.addCollectRestriction(struct21, "bc", "maximum", 4);
    epStructureManager.savePortfolioStructure(struct21);
    // save the template
    dbInstance.commitAndCloseSession();
    // make the copy
    PortfolioStructureMap map = epFrontendManager.assignStructuredMapToUser(ident2, templateEl, addedEntry, null, null, null);
    dbInstance.commitAndCloseSession();
    assertNotNull(map);
    // check the copy
    PortfolioStructure retrievedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
    assertNotNull(retrievedMap);
    assertTrue(retrievedMap instanceof EPStructuredMap);
    assertNotNull(((EPStructuredMap) retrievedMap).getStructuredMapSource());
    assertEquals(templateEl.getKey(), ((EPStructuredMap) retrievedMap).getStructuredMapSource().getKey());
    // check pages of the copied map
    List<PortfolioStructure> pages = epFrontendManager.loadStructureChildren(retrievedMap);
    assertNotNull(pages);
    assertEquals(2, pages.size());
    assertTrue(pages.get(0) instanceof EPPage);
    assertTrue(pages.get(1) instanceof EPPage);
    assertEquals("template-page-1", ((EPStructureElement) pages.get(0)).getTitle());
    assertEquals("template-page-2", ((EPStructureElement) pages.get(1)).getTitle());
    // check root
    assertNotNull(((EPStructureElement) pages.get(0)).getRoot());
    assertEquals(retrievedMap.getKey(), ((EPStructureElement) pages.get(0)).getRoot().getKey());
    // check children of the pages
    List<PortfolioStructure> structs1 = epFrontendManager.loadStructureChildren(pages.get(0));
    assertNotNull(structs1);
    assertEquals(2, structs1.size());
    assertTrue(structs1.get(0) instanceof EPStructureElement);
    assertTrue(structs1.get(1) instanceof EPStructureElement);
    EPStructureElement struct11El = (EPStructureElement) structs1.get(0);
    assertEquals("template-structure-1.1", struct11El.getTitle());
    assertEquals("template-structure-1.2", ((EPStructureElement) structs1.get(1)).getTitle());
    // check root
    assertNotNull(((EPStructureElement) structs1.get(0)).getRoot());
    assertEquals(retrievedMap.getKey(), ((EPStructureElement) structs1.get(0)).getRoot().getKey());
    assertNotNull(((EPStructureElement) structs1.get(1)).getRoot());
    assertEquals(retrievedMap.getKey(), ((EPStructureElement) structs1.get(1)).getRoot().getKey());
    // check collect restriction
    assertNotNull(struct11El.getCollectRestrictions());
    assertEquals("Forum", struct11El.getCollectRestrictions().get(0).getArtefactType());
    assertEquals("minimum", struct11El.getCollectRestrictions().get(0).getRestriction());
    assertEquals(2, struct11El.getCollectRestrictions().get(0).getAmount());
    List<PortfolioStructure> structs2 = epFrontendManager.loadStructureChildren(pages.get(1));
    assertNotNull(structs2);
    assertEquals(1, structs2.size());
    assertTrue(structs2.get(0) instanceof EPStructureElement);
    EPStructureElement struct21El = (EPStructureElement) structs2.get(0);
    assertEquals("template-structure-2.1", struct21El.getTitle());
    // check root
    assertNotNull(struct21El.getRoot());
    assertEquals(retrievedMap.getKey(), struct21El.getRoot().getKey());
    // check collect restriction
    assertNotNull(struct21El.getCollectRestrictions());
    assertEquals("bc", struct21El.getCollectRestrictions().get(0).getArtefactType());
    assertEquals("maximum", struct21El.getCollectRestrictions().get(0).getRestriction());
    assertEquals(4, struct21El.getCollectRestrictions().get(0).getAmount());
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPPage(org.olat.portfolio.model.structel.EPPage) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 20 with EPPage

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

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)

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