Search in sources :

Example 86 with PortfolioStructureMap

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

the class EPStructureManagerTest method testCreateStructureMapTemplate.

@Test
public void testCreateStructureMapTemplate() {
    // save parent and 20 children
    PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(ident1, "paged-parent-structure-el", "parent-structure-element");
    epStructureManager.savePortfolioStructure(template);
    dbInstance.commitAndCloseSession();
    // not very usefull but...
    assertNotNull(template);
    // check if the olat resource is persisted
    OLATResource resource = resourceManager.findResourceable(template.getResourceableId(), template.getResourceableTypeName());
    assertNotNull(resource);
    // check if the repository entry is persisted
    RepositoryEntry re = repositoryManager.lookupRepositoryEntry(resource, false);
    assertNotNull(re);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 87 with PortfolioStructureMap

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

the class EPStructureManagerTest method testRemoveAuthorToMap.

@Test
public void testRemoveAuthorToMap() {
    // 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());
    dbInstance.commitAndCloseSession();
    // and remove the author
    epStructureManager.removeAuthor(map, ident2);
    dbInstance.commitAndCloseSession();
    List<Identity> singleAuthor = repositoryService.getMembers(re, GroupRoles.owner.name());
    assertEquals(1, singleAuthor.size());
    // owner
    assertTrue(singleAuthor.contains(ident1));
    // owner
    assertFalse(singleAuthor.contains(ident2));
    securityManager.getSecurityGroupsForIdentity(ident1);
    repositoryManager.queryReferencableResourcesLimitType(ident1, new Roles(false, false, false, false, false, false, false), null, null, null, null);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) OLATResource(org.olat.resource.OLATResource) GroupRoles(org.olat.basesecurity.GroupRoles) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 88 with PortfolioStructureMap

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

the class UserDeletionManagerTest method testDeleteIdentity.

@Test
public void testDeleteIdentity() {
    String username = "id-to-del-" + UUID.randomUUID();
    String email = username + "@frentix.com";
    User user = userManager.createUser("first" + username, "last" + username, email);
    user.setProperty(UserConstants.COUNTRY, "");
    user.setProperty(UserConstants.CITY, "Basel");
    user.setProperty(UserConstants.INSTITUTIONALNAME, "Del-23");
    user.setProperty(UserConstants.INSTITUTIONALUSERIDENTIFIER, "Del-24");
    Identity identity = securityManager.createAndPersistIdentityAndUser(username, null, user, BaseSecurityModule.getDefaultAuthProviderIdentifier(), username, "secret");
    dbInstance.commitAndCloseSession();
    // add some stuff
    // a default map
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioDefaultMap(identity, "A map to delete", "This map must be deleted");
    Assert.assertNotNull(map);
    // a template
    PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(identity, "A template to delete", "This template must be deleted");
    epStructureManager.savePortfolioStructure(template);
    // an artefact
    AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(identity, "Forum");
    dbInstance.commit();
    Assert.assertNotNull(artefact);
    // a group
    BusinessGroup group = businessGroupService.createBusinessGroup(identity, "Group", "Group", -1, -1, false, false, null);
    Assert.assertNotNull(group);
    dbInstance.commitAndCloseSession();
    // delete the identity
    userDeletionManager.deleteIdentity(identity);
    dbInstance.commit();
    // check
    Identity deletedIdentity = securityManager.loadIdentityByKey(identity.getKey());
    Assert.assertNotNull(deletedIdentity);
    // check that the artefacts are deleted
    List<AbstractArtefact> artefacts = epFrontendManager.getArtefactPoolForUser(deletedIdentity);
    Assert.assertNull(artefacts);
    // check that the maps are deleted (1)
    List<PortfolioStructure> maps = epFrontendManager.getStructureElementsForUser(deletedIdentity, ElementType.DEFAULT_MAP);
    Assert.assertNotNull(maps);
    Assert.assertEquals(0, maps.size());
    // check that the maps are deleted (2)
    PortfolioStructure deletedMap = epStructureManager.loadPortfolioStructureByKey(map.getKey());
    Assert.assertNull(deletedMap);
    // check membership of group
    boolean isMember = businessGroupService.isIdentityInBusinessGroup(deletedIdentity, group);
    Assert.assertFalse(isMember);
    User deletedUser = deletedIdentity.getUser();
    String institutionalName = deletedUser.getProperty(UserConstants.INSTITUTIONALNAME, null);
    Assert.assertFalse(StringHelper.containsNonWhitespace(institutionalName));
    String institutionalId = deletedUser.getProperty(UserConstants.INSTITUTIONALUSERIDENTIFIER, null);
    Assert.assertFalse(StringHelper.containsNonWhitespace(institutionalId));
    String deletedEmail = deletedUser.getProperty(UserConstants.EMAIL, null);
    Assert.assertNotNull(deletedEmail);
    Assert.assertFalse(email.equals(deletedEmail));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) User(org.olat.core.id.User) BusinessGroup(org.olat.group.BusinessGroup) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 89 with PortfolioStructureMap

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

the class EPStructureManager method getOpenStructuredMapAfterDeadline.

protected List<PortfolioStructureMap> getOpenStructuredMapAfterDeadline() {
    StringBuilder sb = new StringBuilder();
    sb.append("select map from ").append(EPStructuredMap.class.getName()).append(" as map");
    sb.append(" where (map.status is null or not(map.status = 'closed'))").append(" and map.deadLine<:currentDate");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setDate("currentDate", new Date());
    @SuppressWarnings("unchecked") List<PortfolioStructureMap> maps = query.list();
    return maps;
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) DBQuery(org.olat.core.commons.persistence.DBQuery) Date(java.util.Date)

Example 90 with PortfolioStructureMap

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

the class EPStructureManager method loadPortfolioStructuredMap.

public PortfolioStructureMap loadPortfolioStructuredMap(IdentityRef identity, PortfolioStructureMap template, OLATResourceable targetOres, String targetSubPath, String targetBusinessPath) {
    if (template == null)
        throw new NullPointerException();
    if (!(template instanceof EPStructuredMapTemplate))
        throw new AssertException("Only template are acceptable");
    StringBuilder sb = new StringBuilder();
    sb.append("select map from ").append(EPStructuredMap.class.getName()).append(" map").append(" left join fetch map.targetResource as targetResource").append(" inner join map.groups as relGroup on relGroup.defaultGroup=true").append(" inner join relGroup.group as baseGroup").append(" where map.structuredMapSource=:template");
    if (targetOres != null) {
        sb.append(" and targetResource.resourceableId=:resourceId").append(" and targetResource.resourceableTypeName=:resourceType");
    }
    if (targetSubPath != null) {
        sb.append(" and targetResource.subPath=:subPath");
    }
    if (targetBusinessPath != null) {
        sb.append(" and targetResource.businessPath=:businessPath");
    }
    sb.append(" and exists (select membership from bgroupmember as membership ").append("    where baseGroup=membership.group and membership.identity.key=:identityKey and membership.role='").append(GroupRoles.owner.name()).append("'").append(" )");
    TypedQuery<PortfolioStructureMap> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), PortfolioStructureMap.class).setParameter("template", template).setParameter("identityKey", identity.getKey());
    if (targetOres != null) {
        query.setParameter("resourceId", targetOres.getResourceableId());
        query.setParameter("resourceType", targetOres.getResourceableTypeName());
    }
    if (targetSubPath != null) {
        query.setParameter("subPath", targetSubPath);
    }
    if (targetBusinessPath != null) {
        query.setParameter("businessPath", targetBusinessPath);
    }
    List<PortfolioStructureMap> maps = query.getResultList();
    // if not found, it is an empty list
    return maps.isEmpty() ? null : maps.get(0);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) AssertException(org.olat.core.logging.AssertException) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate)

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