Search in sources :

Example 11 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap 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 12 with PortfolioStructureMap

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

the class EPStructureManagerTest method testAddAuthorToMap.

@Test
public void testAddAuthorToMap() {
    // save the map
    PortfolioStructureMap map = epStructureManager.createPortfolioMapTemplate(ident1, "add-author-map-1", "add-an-author-to-map-template");
    epStructureManager.savePortfolioStructure(map);
    dbInstance.commitAndCloseSession();
    // add an author
    epStructureManager.addAuthor(map, ident2);
    dbInstance.commitAndCloseSession();
    // check that the author are in the
    OLATResource resource = resourceManager.findResourceable(map.getResourceableId(), map.getResourceableTypeName());
    assertNotNull(resource);
    RepositoryEntry re = repositoryManager.lookupRepositoryEntry(resource, false);
    assertNotNull(re);
    List<Identity> authors = repositoryService.getMembers(re, GroupRoles.owner.name());
    assertEquals(2, authors.size());
    // owner
    assertTrue(authors.contains(ident1));
    // owner
    assertTrue(authors.contains(ident2));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 13 with PortfolioStructureMap

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

the class EPStructureManagerTest method testUseStructureMapTemplate.

@Test
public void testUseStructureMapTemplate() {
    // save parent and 20 children
    PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(ident1, "paged-parent-structure-el", "parent-structure-element");
    epStructureManager.savePortfolioStructure(template);
    dbInstance.commitAndCloseSession();
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, ident1, "cloned-map", "cloned-map-from-template", null, null, null);
    ((EPStructuredMap) map).setReturnDate(new Date());
    EPTargetResource targetResource = ((EPStructuredMap) map).getTargetResource();
    targetResource.setResourceableTypeName("CourseModule");
    targetResource.setResourceableId(234l);
    targetResource.setSubPath("3894580");
    targetResource.setBusinessPath("[RepositoryEntry:23647598][CourseNode:934598]");
    epStructureManager.savePortfolioStructure(map);
    dbInstance.commitAndCloseSession();
    // test
    PortfolioStructureMap retrievedMap = (PortfolioStructureMap) epFrontendManager.loadPortfolioStructureByKey(map.getKey());
    assertNotNull(retrievedMap);
    assertNotNull(((EPStructuredMap) retrievedMap).getReturnDate());
    assertNotNull(((EPStructuredMap) retrievedMap).getStructuredMapSource());
    assertNotNull(((EPStructuredMap) retrievedMap).getTargetResource());
    EPTargetResource retriviedTargetResource = ((EPStructuredMap) retrievedMap).getTargetResource();
    assertEquals("CourseModule", retriviedTargetResource.getResourceableTypeName());
    assertEquals(new Long(234l), retriviedTargetResource.getResourceableId());
    assertEquals("3894580", retriviedTargetResource.getSubPath());
    assertEquals("[RepositoryEntry:23647598][CourseNode:934598]", retriviedTargetResource.getBusinessPath());
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) Date(java.util.Date) Test(org.junit.Test)

Example 14 with PortfolioStructureMap

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

the class PortfolioTextForm method loadMapOrBinder.

protected void loadMapOrBinder() {
    RepositoryEntry mapEntry = courseNode.getReferencedRepositoryEntry();
    if (mapEntry != null) {
        if (BinderTemplateResource.TYPE_NAME.equals(mapEntry.getOlatResource().getResourceableTypeName())) {
            Binder binder = portfolioService.getBinderByResource(mapEntry.getOlatResource());
            if (binder != null) {
                inUse = portfolioService.isTemplateInUse(binder, courseEntry, courseNode.getIdent());
            }
            withDeadline = false;
        } else {
            PortfolioStructureMap template = (PortfolioStructureMap) ePFMgr.loadPortfolioStructure(mapEntry.getOlatResource());
            Long courseResId = courseEntry.getOlatResource().getResourceableId();
            OLATResourceable courseOres = OresHelper.createOLATResourceableInstance(CourseModule.class, courseResId);
            if (template != null) {
                inUse = ePFMgr.isTemplateInUse(template, courseOres, courseNode.getIdent(), null);
            }
            withDeadline = true;
        }
    } else {
        withDeadline = true;
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Binder(org.olat.modules.portfolio.Binder) OLATResourceable(org.olat.core.id.OLATResourceable) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 15 with PortfolioStructureMap

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

the class InvitationDAOTest method cleanUpInvitation.

/**
 * Check the HQL code of the the method, and that it doesn't delete to much invitations
 */
@Test
public void cleanUpInvitation() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Policy-User-2-");
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "Title", "Description");
    Invitation invitation = invitationDao.createAndPersistInvitation();
    dbInstance.commit();
    invitation.setFirstName("John");
    invitation.setLastName("Smith Portfolio");
    EPMapPolicy policy = new EPMapPolicy();
    policy.setType(EPMapPolicy.Type.invitation);
    policy.setInvitation(invitation);
    policyManager.updateMapPolicies(map, Collections.singletonList(policy));
    dbInstance.commitAndCloseSession();
    // convert invitation to identity
    Identity invitee = invitationDao.createIdentityFrom(invitation, Locale.ENGLISH);
    dbInstance.commitAndCloseSession();
    // and check
    boolean visible = epFrontendManager.isMapVisible(invitee, map.getOlatResource());
    Assert.assertTrue(visible);
    // clean the invitations
    invitationDao.cleanUpInvitations();
    dbInstance.commitAndCloseSession();
    // check that the invitation not was not deleted
    boolean afterVisible = epFrontendManager.isMapVisible(invitee, map.getOlatResource());
    Assert.assertTrue(afterVisible);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Invitation(org.olat.basesecurity.Invitation) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)118 Test (org.junit.Test)64 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)54 Identity (org.olat.core.id.Identity)34 RepositoryEntry (org.olat.repository.RepositoryEntry)30 OLATResource (org.olat.resource.OLATResource)30 ArrayList (java.util.ArrayList)18 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)18 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)18 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)16 Date (java.util.Date)10 Invitation (org.olat.basesecurity.Invitation)8 Binder (org.olat.modules.portfolio.Binder)8 EPTargetResource (org.olat.portfolio.model.structel.EPTargetResource)8 EPSecurityCallback (org.olat.portfolio.EPSecurityCallback)6 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)6 CalendarController (org.olat.commons.calendar.ui.CalendarController)4 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)4 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)4 Link (org.olat.core.gui.components.link.Link)4