Search in sources :

Example 1 with EPMapPolicy

use of org.olat.portfolio.manager.EPMapPolicy in project OpenOLAT by OpenOLAT.

the class EPFrontendManagerTest method saveMapPolicy.

@Test
public void saveMapPolicy() {
    // create a map
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Policies", "Description");
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(map, "Page policies", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();
    // policies are empty
    List<EPMapPolicy> policies = epFrontendManager.getMapPolicies(map);
    // owner policy
    assertEquals(0, policies.size());
    // save a user policy
    EPMapPolicy userPolicy = new EPMapPolicy();
    userPolicy.setType(Type.user);
    userPolicy.getIdentities().add(ident2);
    epFrontendManager.updateMapPolicies(map, Collections.singletonList(userPolicy));
    dbInstance.commitAndCloseSession();
    // one policy
    List<EPMapPolicy> policies1 = epFrontendManager.getMapPolicies(map);
    assertEquals(1, policies1.size());
    // check visiblity (is owner)
    assertTrue(epFrontendManager.isMapVisible(ident1, map.getOlatResource()));
    // check visibility (is in policy)
    assertTrue(epFrontendManager.isMapVisible(ident2, map.getOlatResource()));
    // check not visible (not in policy)
    assertFalse(epFrontendManager.isMapVisible(ident3, map.getOlatResource()));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPMapPolicy(org.olat.portfolio.manager.EPMapPolicy) Test(org.junit.Test)

Example 2 with EPMapPolicy

use of org.olat.portfolio.manager.EPMapPolicy in project OpenOLAT by OpenOLAT.

the class EPFrontendManagerTest method allUserPolicies.

@Test
public void allUserPolicies() {
    // create a map
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Policies", "Description");
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(map, "Page policies", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();
    // check visiblity (is owner)
    assertTrue(epFrontendManager.isMapVisible(ident1, map.getOlatResource()));
    // check visibility (no policy)
    assertFalse(epFrontendManager.isMapVisible(ident2, map.getOlatResource()));
    // check not visible (no policy)
    assertFalse(epFrontendManager.isMapVisible(ident3, map.getOlatResource()));
    // add all user policy
    EPMapPolicy userPolicy = new EPMapPolicy();
    userPolicy.setType(Type.allusers);
    epFrontendManager.updateMapPolicies(map, Collections.singletonList(userPolicy));
    dbInstance.commitAndCloseSession();
    // one policy
    List<EPMapPolicy> policies1 = epFrontendManager.getMapPolicies(map);
    assertEquals(1, policies1.size());
    // check visiblity (is owner)
    assertTrue(epFrontendManager.isMapVisible(ident1, map.getOlatResource()));
    // check visibility (is user)
    assertTrue(epFrontendManager.isMapVisible(ident2, map.getOlatResource()));
    // check not visible (is user)
    assertTrue(epFrontendManager.isMapVisible(ident3, map.getOlatResource()));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPMapPolicy(org.olat.portfolio.manager.EPMapPolicy) Test(org.junit.Test)

Example 3 with EPMapPolicy

use of org.olat.portfolio.manager.EPMapPolicy 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 4 with EPMapPolicy

use of org.olat.portfolio.manager.EPMapPolicy in project openolat by klemens.

the class EPFrontendManagerTest method deleteMap_pageAndPolicy.

/**
 * Delete a map with policies
 */
@Test
public void deleteMap_pageAndPolicy() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("frtuse-5");
    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.commitAndCloseSession();
    // add policy
    List<EPMapPolicy> policies = new ArrayList<EPMapPolicy>();
    EPMapPolicy userPolicy = new EPMapPolicy();
    userPolicy.setType(Type.user);
    userPolicy.getIdentities().add(ident2);
    userPolicy.getIdentities().add(ident3);
    policies.add(userPolicy);
    epFrontendManager.updateMapPolicies(map, policies);
    dbInstance.commitAndCloseSession();
    // reload and check
    PortfolioStructure reloadedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
    Assert.assertNotNull(reloadedMap);
    OLATResource reloadedResource = reloadedMap.getOlatResource();
    Assert.assertNotNull(reloadedResource);
    Assert.assertEquals(map, reloadedMap);
    boolean shared = epFrontendManager.isMapShared(reloadedResource);
    Assert.assertTrue(shared);
    boolean visibleToIdent2 = epFrontendManager.isMapVisible(ident2, reloadedResource);
    Assert.assertTrue(visibleToIdent2);
    // delete the map
    epFrontendManager.deletePortfolioStructure(reloadedMap);
    dbInstance.commit();
    boolean deletedShared = epFrontendManager.isMapShared(reloadedResource);
    Assert.assertFalse(deletedShared);
    boolean deletedVisibleToIdent2 = epFrontendManager.isMapVisible(ident2, reloadedResource);
    Assert.assertFalse(deletedVisibleToIdent2);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) EPMapPolicy(org.olat.portfolio.manager.EPMapPolicy) ArrayList(java.util.ArrayList) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 5 with EPMapPolicy

use of org.olat.portfolio.manager.EPMapPolicy in project openolat by klemens.

the class EPFrontendManagerTest method saveMapPolicy.

@Test
public void saveMapPolicy() {
    // create a map
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Policies", "Description");
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(map, "Page policies", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();
    // policies are empty
    List<EPMapPolicy> policies = epFrontendManager.getMapPolicies(map);
    // owner policy
    assertEquals(0, policies.size());
    // save a user policy
    EPMapPolicy userPolicy = new EPMapPolicy();
    userPolicy.setType(Type.user);
    userPolicy.getIdentities().add(ident2);
    epFrontendManager.updateMapPolicies(map, Collections.singletonList(userPolicy));
    dbInstance.commitAndCloseSession();
    // one policy
    List<EPMapPolicy> policies1 = epFrontendManager.getMapPolicies(map);
    assertEquals(1, policies1.size());
    // check visiblity (is owner)
    assertTrue(epFrontendManager.isMapVisible(ident1, map.getOlatResource()));
    // check visibility (is in policy)
    assertTrue(epFrontendManager.isMapVisible(ident2, map.getOlatResource()));
    // check not visible (not in policy)
    assertFalse(epFrontendManager.isMapVisible(ident3, map.getOlatResource()));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPMapPolicy(org.olat.portfolio.manager.EPMapPolicy) Test(org.junit.Test)

Aggregations

EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)14 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)14 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)14 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)10 Invitation (org.olat.basesecurity.Invitation)4 Identity (org.olat.core.id.Identity)4 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)4 OLATResource (org.olat.resource.OLATResource)2