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));
}
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();
}
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();
}
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()));
}
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);
}
Aggregations