Search in sources :

Example 11 with PortfolioStructure

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

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 12 with PortfolioStructure

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

the class EPFrontendManagerTest method removePolicyWithInvitation.

@Test
public void removePolicyWithInvitation() {
    // create a map
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Remove policies", "Description");
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(map, "Page policies", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();
    // save a list of policies
    List<EPMapPolicy> policies = new ArrayList<EPMapPolicy>();
    // invitation
    Invitation invitation = invitationDao.createAndPersistInvitation();
    invitation.setFirstName("John");
    invitation.setLastName("Doe");
    invitation.setMail("john2@doe.ch");
    EPMapPolicy invitationPolicy = new EPMapPolicy();
    invitationPolicy.setType(Type.invitation);
    invitationPolicy.setInvitation(invitation);
    policies.add(invitationPolicy);
    map = epFrontendManager.updateMapPolicies(map, policies);
    dbInstance.commitAndCloseSession();
    // remove the policy
    policies.clear();
    epFrontendManager.updateMapPolicies(map, policies);
    dbInstance.commitAndCloseSession();
    // check if the policies and the invitation are deleted
    List<EPMapPolicy> deletedPolicies = epFrontendManager.getMapPolicies(map);
    assertNotNull(deletedPolicies);
    assertTrue(deletedPolicies.isEmpty());
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPMapPolicy(org.olat.portfolio.manager.EPMapPolicy) ArrayList(java.util.ArrayList) Invitation(org.olat.basesecurity.Invitation) Test(org.junit.Test)

Example 13 with PortfolioStructure

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

the class EPFrontendManagerTest method deleteMap_template.

/**
 * Delete a portfolio template
 */
@Test
public void deleteMap_template() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("frtuse-6");
    // save parent and 20 children
    OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
    RepositoryEntry re = repositoryService.create(id, null, "", "Template to delete", "", resource, RepositoryEntry.ACC_OWNERS);
    PortfolioStructureMap template = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(id, re);
    PortfolioStructure page = epFrontendManager.createAndPersistPortfolioPage(template, "Page while be deleted", "Page description");
    dbInstance.commitAndCloseSession();
    // reload and check
    PortfolioStructure reloadedTemplate = epFrontendManager.loadPortfolioStructureByKey(template.getKey());
    Assert.assertNotNull(reloadedTemplate);
    OLATResource reloadedResource = reloadedTemplate.getOlatResource();
    Assert.assertNotNull(reloadedResource);
    Assert.assertEquals(template, reloadedTemplate);
    List<PortfolioStructure> reloadedPages = epFrontendManager.loadStructureChildren(reloadedTemplate);
    Assert.assertNotNull(reloadedPages);
    Assert.assertEquals(1, reloadedPages.size());
    Assert.assertEquals(page, reloadedPages.get(0));
    // delete
    RepositoryEntry reloadedRe = repositoryService.loadByKey(re.getKey());
    Roles roles = new Roles(true, false, false, false, false, false, false);
    repositoryService.deletePermanently(reloadedRe, id, roles, Locale.GERMAN);
    dbInstance.commit();
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 14 with PortfolioStructure

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

the class EPStructureManagerTest method testMoveUp.

@Test
public void testMoveUp() {
    // save parent and 5 children
    PortfolioStructure parentEl = epFrontendManager.createAndPersistPortfolioStructureElement(null, "move-up-parent-structure-el-1", "move-up-structure-element");
    List<PortfolioStructure> children = new ArrayList<PortfolioStructure>();
    for (int i = 0; i < 5; i++) {
        PortfolioStructure childEl = epFrontendManager.createAndPersistPortfolioStructureElement(parentEl, "paged-structure-el-" + i, "paged-child-structure-element");
        children.add(childEl);
    }
    dbInstance.commitAndCloseSession();
    // check if the paging return the right children
    List<PortfolioStructure> childrenSubset = epFrontendManager.loadStructureChildren(parentEl);
    assertNotNull(childrenSubset);
    assertEquals(5, childrenSubset.size());
    assertEquals(children.get(0).getKey(), childrenSubset.get(0).getKey());
    assertEquals(children.get(1).getKey(), childrenSubset.get(1).getKey());
    assertEquals(children.get(2).getKey(), childrenSubset.get(2).getKey());
    assertEquals(children.get(3).getKey(), childrenSubset.get(3).getKey());
    assertEquals(children.get(4).getKey(), childrenSubset.get(4).getKey());
    dbInstance.commitAndCloseSession();
    // move up the first place
    epStructureManager.moveUp(parentEl, children.get(0));
    dbInstance.commitAndCloseSession();
    // check that all is the same
    List<PortfolioStructure> persistedChildren1 = epFrontendManager.loadStructureChildren(parentEl);
    assertNotNull(persistedChildren1);
    assertEquals(5, persistedChildren1.size());
    assertEquals(children.get(0).getKey(), persistedChildren1.get(0).getKey());
    assertEquals(children.get(1).getKey(), persistedChildren1.get(1).getKey());
    assertEquals(children.get(2).getKey(), persistedChildren1.get(2).getKey());
    assertEquals(children.get(3).getKey(), persistedChildren1.get(3).getKey());
    assertEquals(children.get(4).getKey(), persistedChildren1.get(4).getKey());
    dbInstance.commitAndCloseSession();
    // move the second to the first place
    epStructureManager.moveUp(parentEl, children.get(1));
    dbInstance.commitAndCloseSession();
    // check that all is the same
    List<PortfolioStructure> persistedChildren2 = epFrontendManager.loadStructureChildren(parentEl);
    assertNotNull(persistedChildren2);
    assertEquals(5, persistedChildren2.size());
    assertEquals(children.get(1).getKey(), persistedChildren2.get(0).getKey());
    assertEquals(children.get(0).getKey(), persistedChildren2.get(1).getKey());
    assertEquals(children.get(2).getKey(), persistedChildren2.get(2).getKey());
    assertEquals(children.get(3).getKey(), persistedChildren2.get(3).getKey());
    assertEquals(children.get(4).getKey(), persistedChildren2.get(4).getKey());
    dbInstance.commitAndCloseSession();
    // move up the last
    epStructureManager.moveUp(parentEl, children.get(4));
    epStructureManager.savePortfolioStructure(parentEl);
    dbInstance.commitAndCloseSession();
    // check that all is the same
    List<PortfolioStructure> persistedChildren3 = epFrontendManager.loadStructureChildren(parentEl);
    assertNotNull(persistedChildren3);
    assertEquals(5, persistedChildren3.size());
    assertEquals(children.get(1).getKey(), persistedChildren3.get(0).getKey());
    assertEquals(children.get(0).getKey(), persistedChildren3.get(1).getKey());
    assertEquals(children.get(2).getKey(), persistedChildren3.get(2).getKey());
    assertEquals(children.get(4).getKey(), persistedChildren3.get(3).getKey());
    assertEquals(children.get(3).getKey(), persistedChildren3.get(4).getKey());
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 15 with PortfolioStructure

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

the class EPStructureManagerTest method testCreateAndSaveElement.

@Test
public void testCreateAndSaveElement() {
    PortfolioStructure el = epFrontendManager.createAndPersistPortfolioStructureElement(null, "structure-el", "structure-element");
    dbInstance.commitAndCloseSession();
    assertNotNull(el);
    assertNotNull(el.getOlatResource());
    PortfolioStructure retrievedEl = epFrontendManager.loadPortfolioStructureByKey(el.getKey());
    assertNotNull(retrievedEl);
    assertNotNull(retrievedEl.getOlatResource());
    OLATResource resource = resourceManager.findResourceable(el.getResourceableId(), el.getResourceableTypeName());
    assertNotNull(resource);
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) Test(org.junit.Test)

Aggregations

PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)236 Test (org.junit.Test)90 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)70 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)54 ArrayList (java.util.ArrayList)40 OLATResource (org.olat.resource.OLATResource)30 Identity (org.olat.core.id.Identity)26 RepositoryEntry (org.olat.repository.RepositoryEntry)24 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)22 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)16 EPPage (org.olat.portfolio.model.structel.EPPage)16 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)12 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)12 DBQuery (org.olat.core.commons.persistence.DBQuery)10 EPFrontendManager (org.olat.portfolio.manager.EPFrontendManager)10 Date (java.util.Date)8 Document (org.apache.lucene.document.Document)8 Link (org.olat.core.gui.components.link.Link)8 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)8 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)8