Search in sources :

Example 41 with PortfolioStructureMap

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

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 42 with PortfolioStructureMap

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

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 43 with PortfolioStructureMap

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

the class EPStructureManagerTest method testUseStructureMapTemplate.

@Test
public void testUseStructureMapTemplate() {
    // save parent and 20 children
    PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(ident1, "paged-parent-structure-el", "parent-structure-element");
    epStructureManager.savePortfolioStructure(template);
    dbInstance.commitAndCloseSession();
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, ident1, "cloned-map", "cloned-map-from-template", null, null, null);
    ((EPStructuredMap) map).setReturnDate(new Date());
    EPTargetResource targetResource = ((EPStructuredMap) map).getTargetResource();
    targetResource.setResourceableTypeName("CourseModule");
    targetResource.setResourceableId(234l);
    targetResource.setSubPath("3894580");
    targetResource.setBusinessPath("[RepositoryEntry:23647598][CourseNode:934598]");
    epStructureManager.savePortfolioStructure(map);
    dbInstance.commitAndCloseSession();
    // test
    PortfolioStructureMap retrievedMap = (PortfolioStructureMap) epFrontendManager.loadPortfolioStructureByKey(map.getKey());
    assertNotNull(retrievedMap);
    assertNotNull(((EPStructuredMap) retrievedMap).getReturnDate());
    assertNotNull(((EPStructuredMap) retrievedMap).getStructuredMapSource());
    assertNotNull(((EPStructuredMap) retrievedMap).getTargetResource());
    EPTargetResource retriviedTargetResource = ((EPStructuredMap) retrievedMap).getTargetResource();
    assertEquals("CourseModule", retriviedTargetResource.getResourceableTypeName());
    assertEquals(new Long(234l), retriviedTargetResource.getResourceableId());
    assertEquals("3894580", retriviedTargetResource.getSubPath());
    assertEquals("[RepositoryEntry:23647598][CourseNode:934598]", retriviedTargetResource.getBusinessPath());
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) Date(java.util.Date) Test(org.junit.Test)

Example 44 with PortfolioStructureMap

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

the class EPStructureManagerTest method loadPortfolioStructure_resourceable.

@Test
public void loadPortfolioStructure_resourceable() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-res-tmp-");
    // a template
    PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(user, "resourced-el", "resource-element");
    epStructureManager.savePortfolioStructure(template);
    dbInstance.commitAndCloseSession();
    OLATResource resource = template.getOlatResource();
    PortfolioStructure structure = epStructureManager.loadPortfolioStructure(resource);
    Assert.assertNotNull(structure);
    Assert.assertEquals(template, structure);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 45 with PortfolioStructureMap

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

the class EPStructureManager method createPortfolioStructure.

/**
 * Create a basic structure element
 * @param title
 * @param description
 * @return The structure element
 */
protected PortfolioStructure createPortfolioStructure(PortfolioStructure root, String title, String description) {
    EPStructureElement el = new EPStructureElement();
    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 : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) 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