Search in sources :

Example 21 with PortfolioStructureMap

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

the class PortfolioHandler method createResource.

@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
    EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    EPStructureManager eSTMgr = CoreSpringFactory.getImpl(EPStructureManager.class);
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    OLATResource resource = eSTMgr.createPortfolioMapTemplateResource();
    RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
    PortfolioStructureMap mapTemp = eSTMgr.createAndPersistPortfolioMapTemplateFromEntry(initialAuthor, re);
    // add a page, as each map should have at least one per default!
    Translator pt = Util.createPackageTranslator(EPCreateMapController.class, locale);
    String pageTitle = pt.translate("new.page.title");
    String pageDescription = pt.translate("new.page.desc");
    ePFMgr.createAndPersistPortfolioPage(mapTemp, pageTitle, pageDescription);
    DBFactory.getInstance().commit();
    return re;
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Translator(org.olat.core.gui.translator.Translator) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager) EPStructureManager(org.olat.portfolio.manager.EPStructureManager) RepositoryService(org.olat.repository.RepositoryService)

Example 22 with PortfolioStructureMap

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

the class EPImportTest method testImportFromOpenOLAT_81_Hibernate3.

@Test
public void testImportFromOpenOLAT_81_Hibernate3() throws URISyntaxException {
    URL mapUrl = EPImportTest.class.getResource("map_81.xml.zip");
    assertNotNull(mapUrl);
    File mapFile = new File(mapUrl.toURI());
    PortfolioStructure rootStructure = EPXStreamHandler.getAsObject(mapFile, false);
    OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
    // import the map
    PortfolioStructureMap importedMap = epFrontendManager.importPortfolioMapTemplate(rootStructure, resource);
    Assert.assertNotNull(importedMap);
    dbInstance.commitAndCloseSession();
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 23 with PortfolioStructureMap

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

the class EPPolicyManagerTest method getOwners.

@Test
public void getOwners() {
    // create a map
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Policy-User-1-");
    PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "Title", "Description");
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();
    List<Identity> owners = policyManager.getOwners(originalMap);
    Assert.assertNotNull(owners);
    Assert.assertEquals(1, owners.size());
    Assert.assertEquals(user, owners.get(0));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 24 with PortfolioStructureMap

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

the class EPPolicyManagerTest method isMapShared_HQL.

@Test
public void isMapShared_HQL() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Policy-User-2-");
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "Title", "Description");
    dbInstance.commitAndCloseSession();
    boolean shared = policyManager.isMapShared(map.getOlatResource());
    Assert.assertFalse(shared);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 25 with PortfolioStructureMap

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

the class EPMultipleMapController method activateMap.

private void activateMap(UserRequest ureq, Long mapKey) {
    if (mapKey == null)
        return;
    boolean foundTheMap = false;
    // we have a key, find the corresponding map with the current option (restrcited view or not)
    for (PortfolioStructureMap map : userMaps) {
        if (map.getKey().equals(mapKey) || (map.getResourceableId().equals(mapKey))) {
            activateMap(ureq, map);
            fireEvent(ureq, new EPMapEvent(EPStructureEvent.SELECT, map));
            foundTheMap = true;
            break;
        }
    }
    if (!foundTheMap) {
        // map not found, switch the option and retry to found the map
        restrictShareView = !restrictShareView;
        initOrUpdateMaps(ureq);
        for (PortfolioStructureMap map : userMaps) {
            if (map.getKey().equals(mapKey) || (map.getResourceableId().equals(mapKey))) {
                activateMap(ureq, map);
                fireEvent(ureq, new EPMapEvent(EPStructureEvent.SELECT, map));
                break;
            }
        }
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap)

Aggregations

PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)118 Test (org.junit.Test)64 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)54 Identity (org.olat.core.id.Identity)34 RepositoryEntry (org.olat.repository.RepositoryEntry)30 OLATResource (org.olat.resource.OLATResource)30 ArrayList (java.util.ArrayList)18 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)18 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)18 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)16 Date (java.util.Date)10 Invitation (org.olat.basesecurity.Invitation)8 Binder (org.olat.modules.portfolio.Binder)8 EPTargetResource (org.olat.portfolio.model.structel.EPTargetResource)8 EPSecurityCallback (org.olat.portfolio.EPSecurityCallback)6 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)6 CalendarController (org.olat.commons.calendar.ui.CalendarController)4 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)4 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)4 Link (org.olat.core.gui.components.link.Link)4