Search in sources :

Example 96 with PortfolioStructureMap

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

the class EPFrontendManagerTest method closedArtefacts.

@Test
public void closedArtefacts() {
    // create two artefacts
    AbstractArtefact artefact1 = epFrontendManager.createAndPersistArtefact(ident1, "text");
    assertNotNull(artefact1);
    AbstractArtefact artefact2 = epFrontendManager.createAndPersistArtefact(ident1, "bc");
    assertNotNull(artefact2);
    dbInstance.commitAndCloseSession();
    // create a map with a page and the page has two artefacts
    PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title", "Description");
    PortfolioStructure newPage = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
    boolean successfullLink1 = epFrontendManager.addArtefactToStructure(ident1, artefact1, newPage);
    assertTrue(successfullLink1);
    boolean successfullLink2 = epFrontendManager.addArtefactToStructure(ident1, artefact2, newPage);
    assertTrue(successfullLink2);
    dbInstance.commitAndCloseSession();
    // check if the artefact is in a closed map
    assertFalse(epFrontendManager.isArtefactClosed(artefact1));
    assertFalse(epFrontendManager.isArtefactClosed(artefact2));
    // closed the map artificially
    ((EPDefaultMap) originalMap).setStatus(StructureStatusEnum.CLOSED);
    dbInstance.updateObject(originalMap);
    dbInstance.commitAndCloseSession();
    // check if the artefact is in a closed map
    assertTrue(epFrontendManager.isArtefactClosed(artefact1));
    assertTrue(epFrontendManager.isArtefactClosed(artefact2));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPDefaultMap(org.olat.portfolio.model.structel.EPDefaultMap) Test(org.junit.Test)

Example 97 with PortfolioStructureMap

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

the class EPFrontendManagerTest method deleteMap_withOldPolicy.

@Test
public void deleteMap_withOldPolicy() {
    // create map
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("frtuse-7");
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(id, "Delete map", "Description");
    PortfolioStructure page = epFrontendManager.createAndPersistPortfolioPage(map, "Page while be deleted", "Page description");
    AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(id, "Forum");
    epFrontendManager.addArtefactToStructure(id, artefact, page);
    dbInstance.commit();
    // create an old policy manually
    SecurityGroup secGroup = securityManager.createAndPersistSecurityGroup();
    Policy policy = securityManager.createAndPersistPolicy(secGroup, "allusers_" + Constants.PERMISSION_READ, map.getOlatResource());
    Assert.assertNotNull(policy);
    dbInstance.commitAndCloseSession();
    // delete the map
    PortfolioStructure reloadedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
    epFrontendManager.deletePortfolioStructure(reloadedMap);
    dbInstance.commit();
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Policy(org.olat.basesecurity.Policy) EPMapPolicy(org.olat.portfolio.manager.EPMapPolicy) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Identity(org.olat.core.id.Identity) SecurityGroup(org.olat.basesecurity.SecurityGroup) Test(org.junit.Test)

Example 98 with PortfolioStructureMap

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

the class EPFrontendManagerTest method testCopyMap.

@Test
public void testCopyMap() {
    // create two artefacts
    AbstractArtefact artefact1 = epFrontendManager.createAndPersistArtefact(ident1, "text");
    assertNotNull(artefact1);
    AbstractArtefact artefact2 = epFrontendManager.createAndPersistArtefact(ident1, "bc");
    assertNotNull(artefact2);
    dbInstance.commitAndCloseSession();
    // create a map with a page and the page has two artefacts
    PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title", "Description");
    PortfolioStructure newPage = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
    boolean successfullLink1 = epFrontendManager.addArtefactToStructure(ident1, artefact1, newPage);
    assertTrue(successfullLink1);
    boolean successfullLink2 = epFrontendManager.addArtefactToStructure(ident1, artefact2, newPage);
    assertTrue(successfullLink2);
    dbInstance.commitAndCloseSession();
    // 1 test: copy the map one shoot
    PortfolioStructureMap copyMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title copy", "Description copy");
    epFrontendManager.copyStructureRecursively(originalMap, copyMap, true);
    assertNotNull(copyMap.getKey());
    dbInstance.commitAndCloseSession();
    // 2 test: copy the map two shoota
    PortfolioStructureMap copyMap2 = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title copy 2", "Description copy 2");
    dbInstance.commitAndCloseSession();
    assertNotNull(copyMap2.getKey());
    epFrontendManager.copyStructureRecursively(originalMap, copyMap2, true);
    dbInstance.commitAndCloseSession();
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Test(org.junit.Test)

Example 99 with PortfolioStructureMap

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

the class EPFrontendManagerTest method isStructuredMapOwner.

/**
 * Same workflow as the repository. This workflow is pretty critical.
 */
@Test
public void isStructuredMapOwner() {
    OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
    // create a repository entry
    RepositoryEntry addedEntry = repositoryService.create(ident1, null, "-", "test repo", "desc repo", resource, RepositoryEntry.ACC_OWNERS);
    dbInstance.commitAndCloseSession();
    // create the template owned by ident1
    PortfolioStructureMap template = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(ident1, addedEntry);
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(template, "Page title", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();
    // assign the template to ident2
    PortfolioStructureMap map = epFrontendManager.assignStructuredMapToUser(ident2, template, addedEntry, null, null, null);
    assertNotNull(map);
    dbInstance.commitAndCloseSession();
    // check if ident2 is owner of the map
    assertTrue(epFrontendManager.isMapOwner(ident2, map.getOlatResource()));
    // check if ident1 is not the owner of the map
    assertFalse(epFrontendManager.isMapOwner(ident1, map.getOlatResource()));
    // check if ident1 is owner of the template
    assertTrue(epFrontendManager.isMapOwner(ident1, template.getOlatResource()));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 100 with PortfolioStructureMap

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

the class EPFrontendManagerTest method deleteMap_pageAndArtefact.

/**
 * Create a map with a page and an artefact. Delete it.
 */
@Test
public void deleteMap_pageAndArtefact() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("frtuse-4");
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(id, "Delete map", "Description");
    PortfolioStructure page = epFrontendManager.createAndPersistPortfolioPage(map, "Page while be deleted", "Page description");
    assertNotNull(page);
    dbInstance.commitAndCloseSession();
    // create artefact
    AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(id, "Forum");
    dbInstance.commitAndCloseSession();
    // create the link
    epFrontendManager.addArtefactToStructure(id, artefact, page);
    dbInstance.commitAndCloseSession();
    // reload and check
    PortfolioStructure reloadedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
    Assert.assertNotNull(reloadedMap);
    Assert.assertEquals(map, reloadedMap);
    List<PortfolioStructure> reloadedPages = epFrontendManager.loadStructureChildren(reloadedMap);
    Assert.assertNotNull(reloadedPages);
    Assert.assertEquals(1, reloadedPages.size());
    PortfolioStructure reloadedPage = reloadedPages.get(0);
    Assert.assertEquals(page, reloadedPage);
    List<AbstractArtefact> reloadedArtefacts = epFrontendManager.getArtefacts(reloadedPage);
    Assert.assertNotNull(reloadedArtefacts);
    Assert.assertEquals(1, reloadedArtefacts.size());
    AbstractArtefact reloadedArtefact = reloadedArtefacts.get(0);
    Assert.assertEquals(artefact, reloadedArtefact);
    dbInstance.commitAndCloseSession();
    // delete the map
    epFrontendManager.deletePortfolioStructure(reloadedMap);
    dbInstance.commit();
    // what is deleted?
    AbstractArtefact notDeletedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
    Assert.assertNotNull(notDeletedArtefact);
    PortfolioStructure deletedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
    Assert.assertNull(deletedMap);
    PortfolioStructure deletedPage = epFrontendManager.loadPortfolioStructureByKey(page.getKey());
    Assert.assertNull(deletedPage);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

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