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