Search in sources :

Example 66 with PortfolioStructure

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

the class EPFrontendManagerTest method isTemplateInUse.

@Test
public void isTemplateInUse() {
    // create a template
    OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
    // create a repository entry
    RepositoryEntry addedEntry = repositoryService.create(ident1, null, "-", "Template in user", "Template in use", resource, RepositoryEntry.ACC_OWNERS);
    // create the template owned by ident1
    PortfolioStructureMap template = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(ident1, addedEntry);
    dbInstance.commitAndCloseSession();
    // add a page to it
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(template, "Page title", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();
    // check: the template is not in use
    assertFalse(epFrontendManager.isTemplateInUse(template, null, null, null));
    // use the template: assign the template to ident2
    PortfolioStructureMap map = epFrontendManager.assignStructuredMapToUser(ident2, template, addedEntry, null, null, null);
    assertNotNull(map);
    dbInstance.commitAndCloseSession();
    // check: the template is  in use
    assertTrue(epFrontendManager.isTemplateInUse(template, null, null, null));
}
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 67 with PortfolioStructure

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

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

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

the class EPFrontendManagerTest method isMapOwner.

@Test
public void isMapOwner() {
    // create a map
    PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Title", "Description");
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();
    // check if ident1 is owner
    assertTrue(epFrontendManager.isMapOwner(ident1, originalMap.getOlatResource()));
    // check if ident2 is not owner
    assertFalse(epFrontendManager.isMapOwner(ident2, originalMap.getOlatResource()));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Test(org.junit.Test)

Example 69 with PortfolioStructure

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

the class EPFrontendManagerTest method mergeTwoUserPolicies.

@Test
public void mergeTwoUserPolicies() {
    // 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>();
    // first user policy
    EPMapPolicy userPolicy1 = new EPMapPolicy();
    userPolicy1.setType(Type.user);
    userPolicy1.getIdentities().add(ident2);
    userPolicy1.getIdentities().add(ident3);
    policies.add(userPolicy1);
    // second user policy
    EPMapPolicy userPolicy2 = new EPMapPolicy();
    userPolicy2.setType(Type.user);
    userPolicy2.getIdentities().add(ident1);
    policies.add(userPolicy2);
    epFrontendManager.updateMapPolicies(map, policies);
    dbInstance.commitAndCloseSession();
    // check if the policies are correctly merged
    List<EPMapPolicy> mergedPolicies = epFrontendManager.getMapPolicies(map);
    assertNotNull(mergedPolicies);
    assertEquals(1, mergedPolicies.size());
    EPMapPolicy mergedPolicy = mergedPolicies.get(0);
    List<Identity> identities = mergedPolicy.getIdentities();
    assertEquals(3, identities.size());
    int count1, count2, count3;
    count1 = count2 = count3 = 0;
    for (Identity identity : identities) {
        if (identity.equalsByPersistableKey(ident1)) {
            count1++;
        } else if (identity.equalsByPersistableKey(ident2)) {
            count2++;
        } else if (identity.equalsByPersistableKey(ident3)) {
            count3++;
        }
    }
    assertEquals(1, count1);
    assertEquals(1, count2);
    assertEquals(1, count3);
}
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) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 70 with PortfolioStructure

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

the class EPImportTest method testCopy.

@Test
public void testCopy() throws URISyntaxException {
    Identity ident = JunitTestHelper.createAndPersistIdentityAsRndUser("ImPort-1");
    // save the map
    PortfolioStructureMap map = epStructureManager.createPortfolioMapTemplate(ident, "import-map-1", "map-template");
    epStructureManager.savePortfolioStructure(map);
    dbInstance.commitAndCloseSession();
    // check that the author are in the
    OLATResource resource = resourceManager.findResourceable(map.getResourceableId(), map.getResourceableTypeName());
    RepositoryEntry re = repositoryManager.lookupRepositoryEntry(resource, false);
    Assert.assertNotNull(re);
    dbInstance.commitAndCloseSession();
    RepositoryEntry copy = repositoryService.copy(re, ident, "ImPort - (Copy 1)");
    Assert.assertNotNull(copy);
    dbInstance.commitAndCloseSession();
    PortfolioStructure copiedMap = epFrontendManager.loadPortfolioStructure(copy.getOlatResource());
    Assert.assertNotNull(copiedMap);
}
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) Identity(org.olat.core.id.Identity) 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