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);
}
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);
}
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));
}
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;
}
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);
}
Aggregations