Search in sources :

Example 76 with PortfolioStructure

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

the class EPStructureToArtefactTest method moveUpArtefact.

@Test
public void moveUpArtefact() {
    // save parent and 5 children
    PortfolioStructure structureEl = epFrontendManager.createAndPersistPortfolioStructureElement(null, "move-up-structure-el-1", "move-up-structure-element");
    List<AbstractArtefact> children = new ArrayList<AbstractArtefact>();
    for (int i = 0; i < 5; i++) {
        AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "Forum");
        artefact.setTitle("move-up-artefact-1-" + i);
        artefact = epFrontendManager.updateArtefact(artefact);
        epFrontendManager.addArtefactToStructure(ident1, artefact, structureEl);
        children.add(artefact);
    }
    dbInstance.commitAndCloseSession();
    // move up the first place
    epStructureManager.moveUp(structureEl, children.get(0));
    dbInstance.commitAndCloseSession();
    // check that all is the same
    List<AbstractArtefact> persistedChildren1 = epFrontendManager.getArtefacts(structureEl);
    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(structureEl, children.get(1));
    dbInstance.commitAndCloseSession();
    // check that all is the same
    List<AbstractArtefact> persistedChildren2 = epFrontendManager.getArtefacts(structureEl);
    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(structureEl, children.get(4));
    dbInstance.commitAndCloseSession();
    // check that all is the same
    List<AbstractArtefact> persistedChildren3 = epFrontendManager.getArtefacts(structureEl);
    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) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 77 with PortfolioStructure

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

the class EPPolicyManagerTest method getOwners.

@Test
public void getOwners() {
    // create a map
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Policy-User-1-");
    PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "Title", "Description");
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();
    List<Identity> owners = policyManager.getOwners(originalMap);
    Assert.assertNotNull(owners);
    Assert.assertEquals(1, owners.size());
    Assert.assertEquals(user, owners.get(0));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 78 with PortfolioStructure

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

the class EPStructureManagerTest method testGetStructureElementsForUser.

@Test
public void testGetStructureElementsForUser() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-1-");
    PortfolioStructure el = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "users-test-map", "a-map-to-test-get-afterwards");
    Assert.assertNotNull(el);
    dbInstance.commitAndCloseSession();
    List<SecurityGroup> secGroups = securityManager.getSecurityGroupsForIdentity(user);
    Assert.assertNotNull(secGroups);
    Assert.assertTrue(secGroups.size() >= 1);
    List<PortfolioStructure> elRes = epStructureManager.getStructureElementsForUser(user, ElementType.DEFAULT_MAP);
    Assert.assertNotNull(elRes);
    Assert.assertEquals(1, elRes.size());
    Assert.assertEquals("users-test-map", elRes.get(0).getTitle());
    // get another map
    PortfolioStructure el2 = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "users-test-map-2", "2-a-map-to-test-get-afterwards");
    Assert.assertNotNull(el2);
    dbInstance.commitAndCloseSession();
    List<PortfolioStructure> elRes2 = epStructureManager.getStructureElementsForUser(user);
    Assert.assertNotNull(elRes2);
    Assert.assertEquals(2, elRes2.size());
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Identity(org.olat.core.id.Identity) SecurityGroup(org.olat.basesecurity.SecurityGroup) Test(org.junit.Test)

Example 79 with PortfolioStructure

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

the class EPStructureManagerTest method testGetStructureElementsForUser_byElementTypes.

@Test
public void testGetStructureElementsForUser_byElementTypes() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-1-");
    PortfolioStructure el = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "users-def-map", "");
    Assert.assertNotNull(el);
    dbInstance.commitAndCloseSession();
    // by default map
    List<PortfolioStructure> defaultRes = epStructureManager.getStructureElementsForUser(user, ElementType.DEFAULT_MAP);
    Assert.assertNotNull(defaultRes);
    Assert.assertEquals(1, defaultRes.size());
    Assert.assertEquals("users-def-map", defaultRes.get(0).getTitle());
    // by default map and structured
    List<PortfolioStructure> multipleRes = epStructureManager.getStructureElementsForUser(user, ElementType.DEFAULT_MAP, ElementType.STRUCTURED_MAP);
    Assert.assertNotNull(multipleRes);
    Assert.assertEquals(1, multipleRes.size());
    Assert.assertEquals("users-def-map", multipleRes.get(0).getTitle());
    // by structured
    List<PortfolioStructure> structuredRes = epStructureManager.getStructureElementsForUser(user, ElementType.STRUCTURED_MAP);
    Assert.assertNotNull(structuredRes);
    Assert.assertTrue(structuredRes.isEmpty());
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 80 with PortfolioStructure

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

the class EPStructureManagerTest method testCreateAndRetrieveElement.

@Test
public void testCreateAndRetrieveElement() {
    PortfolioStructure el = epFrontendManager.createAndPersistPortfolioStructureElement(null, "structure-el-2", "structure-element-2");
    dbInstance.commitAndCloseSession();
    PortfolioStructure el2 = epStructureManager.loadPortfolioStructure(el.getOlatResource());
    assertNotNull(el2);
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) 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