use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.
the class PortfolioServiceTest method binderAndSectionAndPageAccessRights.
@Test
public void binderAndSectionAndPageAccessRights() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-3");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-4");
Identity reviewer = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-5");
String title = "My published binder";
String summary = "My live";
Binder binder = portfolioService.createNewBinder(title, summary, null, owner);
dbInstance.commit();
portfolioService.appendNewSection("Section", "Coached section", null, null, binder);
dbInstance.commit();
List<Section> sections = portfolioService.getSections(binder);
Section section = sections.get(0);
portfolioService.appendNewPage(owner, "Reviewed page", "", null, null, section);
portfolioService.addAccessRights(section, coach, PortfolioRoles.coach);
dbInstance.commit();
List<Page> pages = portfolioService.getPages(section);
Page page = pages.get(0);
portfolioService.addAccessRights(page, reviewer, PortfolioRoles.reviewer);
// load right
List<AccessRights> rights = portfolioService.getAccessRights(binder);
Assert.assertNotNull(rights);
Assert.assertEquals(4, rights.size());
boolean foundOwner = false;
boolean foundCoach = false;
boolean foundReviewer = false;
for (AccessRights right : rights) {
if (PortfolioRoles.owner.equals(right.getRole()) && owner.equals(right.getIdentity())) {
foundOwner = true;
} else if (PortfolioRoles.coach.equals(right.getRole()) && coach.equals(right.getIdentity())) {
foundCoach = true;
} else if (PortfolioRoles.reviewer.equals(right.getRole()) && reviewer.equals(right.getIdentity())) {
foundReviewer = true;
}
}
Assert.assertTrue(foundOwner);
Assert.assertTrue(foundCoach);
Assert.assertTrue(foundReviewer);
}
use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.
the class PortfolioResultDetailsController method doOpenMap.
private void doOpenMap(UserRequest ureq, Binder binder) {
if (stackPanel instanceof TooledStackedPanel) {
binder = portfolioService.getBinderByKey(binder.getKey());
portfolioService.updateBinderUserInformations(binder, getIdentity());
List<AccessRights> rights = portfolioService.getAccessRights(binder, getIdentity());
BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCourseCoach(binder, rights);
BinderConfiguration config = BinderConfiguration.createConfig(binder);
BinderController binderCtrl = new BinderController(ureq, getWindowControl(), (TooledStackedPanel) stackPanel, secCallback, binder, config);
String displayName = StringHelper.escapeHtml(binder.getTitle());
stackPanel.pushController(displayName, binderCtrl);
binderCtrl.activate(ureq, null, null);
}
}
use of org.olat.modules.portfolio.model.AccessRights in project OpenOLAT by OpenOLAT.
the class SharedBindersController method doSelectBinder.
private BinderController doSelectBinder(UserRequest ureq, SharedItemRow row) {
Binder binder = portfolioService.getBinderByKey(row.getBinderKey());
if (binder == null) {
showWarning("warning.portfolio.not.found");
return null;
} else {
removeAsListenerAndDispose(binderCtrl);
portfolioService.updateBinderUserInformations(binder, getIdentity());
row.setRecentLaunch(new Date());
OLATResourceable binderOres = OresHelper.createOLATResourceableInstance("Binder", binder.getKey());
WindowControl swControl = addToHistory(ureq, binderOres, null);
List<AccessRights> rights = portfolioService.getAccessRights(binder, getIdentity());
BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCoach(binder, rights);
BinderConfiguration config = BinderConfiguration.createConfig(binder);
binderCtrl = new BinderController(ureq, swControl, stackPanel, secCallback, binder, config);
String displayName = StringHelper.escapeHtml(binder.getTitle());
stackPanel.pushController(displayName, binderCtrl);
return binderCtrl;
}
}
use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.
the class PortfolioResultDetailsController method doOpenMap.
private void doOpenMap(UserRequest ureq, Binder binder) {
if (stackPanel instanceof TooledStackedPanel) {
binder = portfolioService.getBinderByKey(binder.getKey());
portfolioService.updateBinderUserInformations(binder, getIdentity());
List<AccessRights> rights = portfolioService.getAccessRights(binder, getIdentity());
BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCourseCoach(binder, rights);
BinderConfiguration config = BinderConfiguration.createConfig(binder);
BinderController binderCtrl = new BinderController(ureq, getWindowControl(), (TooledStackedPanel) stackPanel, secCallback, binder, config);
String displayName = StringHelper.escapeHtml(binder.getTitle());
stackPanel.pushController(displayName, binderCtrl);
binderCtrl.activate(ureq, null, null);
}
}
use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.
the class BinderDAO method getBinderAccesRights.
public List<AccessRights> getBinderAccesRights(Page page) {
if (page == null) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("select binder.key, section.key, page.key, membership.role, ident, invitation from pfpage as page").append(" inner join page.section as section").append(" inner join section.binder as binder").append(" inner join binder.baseGroup as baseGroup").append(" inner join baseGroup.members as membership").append(" inner join membership.identity as ident").append(" inner join fetch ident.user as identUser").append(" left join binvitation as invitation on (invitation.baseGroup.key=binder.baseGroup.key and identUser.email=invitation.mail)").append(" where page.key=:pageKey");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("pageKey", page.getKey());
List<Object[]> objects = query.getResultList();
List<AccessRights> rightList = new ArrayList<>(objects.size());
for (Object[] object : objects) {
Long binderKey = (Long) object[0];
Long sectionKey = (Long) object[1];
Long pageKey = (Long) object[2];
String role = (String) object[3];
Identity member = (Identity) object[4];
Invitation invitation = (Invitation) object[5];
AccessRights rights = new AccessRights();
rights.setRole(PortfolioRoles.valueOf(role));
rights.setBinderKey(binderKey);
rights.setSectionKey(sectionKey);
rights.setPageKey(pageKey);
rights.setIdentity(member);
rights.setInvitation(invitation);
rightList.add(rights);
}
return rightList;
}
Aggregations